Merge branch 'worktree-agent-a1b6c249e2bec6658'
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import '../ui/adaptive/window_margins.dart';
|
||||
import '../ui/theme/app_design.dart';
|
||||
import '../ui/theme/app_design_controller.dart';
|
||||
import '../ui/theme/app_font_controller.dart';
|
||||
import '../ui/scale/ui_scale.dart';
|
||||
@@ -55,11 +54,12 @@ class MyApp extends StatelessWidget {
|
||||
final designs = this.designs ?? AppDesignController.instance;
|
||||
return ListenableBuilder(
|
||||
listenable: Listenable.merge([fonts, designs]),
|
||||
builder: (context, _) => _host(designs.design, fonts.family),
|
||||
builder: (context, _) => _host(designs, fonts.family),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _host(AppDesign design, String? fontFamily) {
|
||||
Widget _host(AppDesignController designs, String? fontFamily) {
|
||||
final design = designs.design;
|
||||
final router = routerConfig;
|
||||
if (router != null) {
|
||||
return MaterialApp.router(
|
||||
@@ -68,6 +68,7 @@ class MyApp extends StatelessWidget {
|
||||
builder: _scaled,
|
||||
theme: design.light(fontFamily: fontFamily),
|
||||
darkTheme: design.dark(fontFamily: fontFamily),
|
||||
themeAnimationDuration: designs.themeAnimationDuration,
|
||||
themeMode: ThemeMode.system,
|
||||
routerConfig: router,
|
||||
);
|
||||
@@ -78,6 +79,7 @@ class MyApp extends StatelessWidget {
|
||||
builder: _scaled,
|
||||
theme: design.light(fontFamily: fontFamily),
|
||||
darkTheme: design.dark(fontFamily: fontFamily),
|
||||
themeAnimationDuration: designs.themeAnimationDuration,
|
||||
themeMode: ThemeMode.system,
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: destinationBodies,
|
||||
|
||||
@@ -227,6 +227,7 @@ class _DetachedWindowAppState extends State<DetachedWindowApp> {
|
||||
),
|
||||
theme: designs.design.light(fontFamily: fonts.family),
|
||||
darkTheme: designs.design.dark(fontFamily: fonts.family),
|
||||
themeAnimationDuration: designs.themeAnimationDuration,
|
||||
themeMode: ThemeMode.system,
|
||||
// The window's one page is named by its route, so the address bar
|
||||
// (and a reload) keeps the detached location instead of `/`.
|
||||
|
||||
@@ -389,6 +389,7 @@ class _PipelinesRootState extends State<PipelinesRoot> {
|
||||
),
|
||||
theme: designs.design.light(fontFamily: fonts.family),
|
||||
darkTheme: designs.design.dark(fontFamily: fonts.family),
|
||||
themeAnimationDuration: designs.themeAnimationDuration,
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: flow,
|
||||
),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The find-in-diff field `/` opens: the query, "3 of 12", previous and next
|
||||
/// match, and close. Enter goes to the next match, Shift+Enter to the
|
||||
@@ -37,7 +38,9 @@ class DiffSearchBar extends StatelessWidget {
|
||||
: '$position of $count';
|
||||
return Material(
|
||||
elevation: 3,
|
||||
borderRadius: BorderRadius.circular(28),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(28)),
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 4, 4),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
import 'chat_bar_tint.dart';
|
||||
|
||||
/// The conversation bar's model and mode controls read as the bar's other
|
||||
@@ -18,7 +19,13 @@ ButtonStyle chatBarTextButtonStyle(
|
||||
// The same 12 px each side as an icon button's glyph inside its 48 px
|
||||
// target, so text sits off its hover/press shape as it does top and bottom.
|
||||
padding: compact ? null : chatBarButtonPadding,
|
||||
minimumSize: compact ? null : const Size.square(kMinInteractiveDimension),
|
||||
minimumSize: compact
|
||||
? null
|
||||
: Size.square(
|
||||
AppDesignTokens.of(context).density.dense
|
||||
? 32
|
||||
: kMinInteractiveDimension,
|
||||
),
|
||||
);
|
||||
|
||||
/// Horizontal padding inside the bar's text buttons (model, mode).
|
||||
|
||||
@@ -1061,7 +1061,15 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
builder: (context, constraints) => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
_attach(context),
|
||||
// A dense design's 32px attach centres
|
||||
// on the 40px send button's line.
|
||||
if (AppDesignTokens.of(context).density.dense)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 4),
|
||||
child: _attach(context),
|
||||
)
|
||||
else
|
||||
_attach(context),
|
||||
Expanded(
|
||||
child: Focus(
|
||||
canRequestFocus: false,
|
||||
@@ -1329,7 +1337,12 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
// The pill draws the field's surface; the field adds no border.
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
contentPadding: const EdgeInsets.symmetric(vertical: 12),
|
||||
// A dense design's slim composer: one line as tall as the 40px send
|
||||
// button (every design pins it), so the pill is 48px. Its compact
|
||||
// density takes 4px off each of these 14.
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: AppDesignTokens.of(context).density.dense ? 14 : 12,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'chat_find_controller.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The chat's find bar, like the terminal's: the query field, the match
|
||||
/// count, Match case, the older/newer and close buttons. Matches count from
|
||||
@@ -68,7 +69,9 @@ class _ChatFindBarState extends State<ChatFindBar> {
|
||||
child: Material(
|
||||
elevation: 3,
|
||||
color: scheme.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(8)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 12, end: 4),
|
||||
child: ListenableBuilder(
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'chat_shell_terminal_find.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The terminal's find bar: the query field (Enter finds the next match,
|
||||
/// Shift+Enter the previous, Esc closes), the match count, Match case and
|
||||
@@ -69,7 +70,9 @@ class _ChatShellTerminalFindBarState extends State<ChatShellTerminalFindBar> {
|
||||
child: Material(
|
||||
elevation: 3,
|
||||
color: scheme.surfaceContainerHigh,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(8)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 12, end: 4),
|
||||
child: ListenableBuilder(
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import '../../../../ui/adaptive/segmented_bar_overflow.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../ui/status/app_spinner.dart';
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
class ChatBarAction extends StatelessWidget implements SegmentedOverflowable {
|
||||
const ChatBarAction({
|
||||
@@ -220,7 +221,9 @@ class ChatUndoBar extends StatelessWidget {
|
||||
);
|
||||
return Material(
|
||||
elevation: 3,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(8)),
|
||||
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
child: content,
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'session_row_style.dart';
|
||||
import '../../domain/chat_list_activity.dart';
|
||||
import 'chat_sessions_body.dart';
|
||||
import 'chat_sessions_controller.dart';
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// A small, scrollable device-local rail. Full titles remain accessible.
|
||||
class ChatCompactSidebar extends StatelessWidget {
|
||||
@@ -148,7 +149,9 @@ class ChatCompactSidebar extends StatelessWidget {
|
||||
data: row,
|
||||
feedback: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(20)),
|
||||
child: Chip(
|
||||
avatar: ChatCompactAvatar(
|
||||
title: title,
|
||||
|
||||
@@ -19,6 +19,7 @@ import 'session_harness_icon.dart';
|
||||
import 'session_pane_menu.dart';
|
||||
import 'session_row_style.dart';
|
||||
import 'chat_awaiting.dart';
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// One chat in the list, in the app's shared row on both hosts: the harness
|
||||
/// avatar, the title with its recency, one muted line, and the actions menu.
|
||||
@@ -91,7 +92,9 @@ class ChatSessionRow extends StatelessWidget {
|
||||
data: session,
|
||||
feedback: Material(
|
||||
elevation: 4,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(20)),
|
||||
child: Chip(
|
||||
avatar: ChatSessionAvatar(session: session),
|
||||
label: Text(chatSessionTitle(session)),
|
||||
|
||||
@@ -69,7 +69,9 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
final transcript = AppDesignTokens.of(context).transcript;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final density = tokens.density;
|
||||
final transcript = tokens.transcript;
|
||||
final card = transcript == TranscriptStyle.manuscript
|
||||
? PaperEditorialNote(
|
||||
label: label,
|
||||
@@ -84,11 +86,18 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
||||
color: scheme.surfaceContainerLow,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
borderRadius: tokens.corners(
|
||||
const BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
side: BorderSide(color: scheme.outlineVariant),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 8, 14, 10),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
density.inset(14),
|
||||
density.space(8),
|
||||
density.inset(14),
|
||||
density.space(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -166,7 +166,11 @@ class ChatCodeCopyRegion extends StatelessWidget {
|
||||
key: const Key('chat-code-header'),
|
||||
color: headerFill(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 12, end: 4),
|
||||
// Its label starts at the code's own inset (tighter when dense).
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: AppDesignTokens.of(context).density.space(12),
|
||||
end: 4,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: label),
|
||||
|
||||
@@ -272,7 +272,9 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
code: code,
|
||||
label: Text(markdownCodeLabel(language), style: labelStyle),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: EdgeInsets.all(
|
||||
AppDesignTokens.of(context).density.space(12),
|
||||
),
|
||||
child: ChatTranscriptHorizontalScrollView(
|
||||
label: 'code block',
|
||||
child: Text.rich(
|
||||
@@ -570,9 +572,15 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
/// a tighter line, as a technical book does.
|
||||
TextStyle _codeStyle(BuildContext context) {
|
||||
const mono = TextStyle(fontFamily: appMonospaceFamily);
|
||||
final reading = AppDesignTokens.of(context).reading;
|
||||
if (reading.family == null) return mono;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final reading = tokens.reading;
|
||||
final size = DefaultTextStyle.of(context).style.fontSize ?? 16;
|
||||
// A dense design sets code at its body size (13 beside 14px prose): the
|
||||
// monospace runs wider than the prose face.
|
||||
if (reading.family == null && tokens.density.dense) {
|
||||
return mono.copyWith(fontSize: size * 13 / 14, height: 1.4);
|
||||
}
|
||||
if (reading.family == null) return mono;
|
||||
return mono.copyWith(
|
||||
fontSize: size * 0.82,
|
||||
height: 1.45,
|
||||
|
||||
@@ -55,15 +55,26 @@ class ChatUserBubble extends StatelessWidget {
|
||||
break;
|
||||
}
|
||||
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
|
||||
// inside the bubble keeps its ink and background.
|
||||
// inside the bubble keeps its ink and background. A dense design draws
|
||||
// a tighter bubble in its own corners.
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final density = tokens.density;
|
||||
return Material(
|
||||
color: chatBubbleFill(
|
||||
context,
|
||||
Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: const RoundedRectangleBorder(borderRadius: _radius),
|
||||
child: Padding(padding: _padding, child: child),
|
||||
shape: RoundedRectangleBorder(borderRadius: tokens.corners(_radius)),
|
||||
child: Padding(
|
||||
padding: density.dense
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: density.inset(_padding.left),
|
||||
vertical: density.space(_padding.top),
|
||||
)
|
||||
: _padding,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -89,8 +100,10 @@ TextStyle? chatMessageTextStyle(BuildContext context) => AppDesignTokens.of(
|
||||
|
||||
/// The empty-line gap between two paragraphs of a reply: about one line of
|
||||
/// body text at [fontSize] (else the ambient text size), scaled by the
|
||||
/// operator's text scaling, so chunks read as separate paragraphs.
|
||||
/// operator's text scaling, so chunks read as separate paragraphs. A design
|
||||
/// may set a tighter gap ([ReadingType.paragraphGap]).
|
||||
double chatParagraphGap(BuildContext context, [double? fontSize]) {
|
||||
final size = fontSize ?? DefaultTextStyle.of(context).style.fontSize ?? 14;
|
||||
return MediaQuery.textScalerOf(context).scale(size) * 0.9;
|
||||
return MediaQuery.textScalerOf(context).scale(size) *
|
||||
AppDesignTokens.of(context).reading.paragraphGap;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ class ChatMessageView extends StatelessWidget {
|
||||
// A terminal or manuscript transcript reads top to bottom: the
|
||||
// operator's prompt line or block quote starts at the same edge as the
|
||||
// answer and spans its column.
|
||||
final transcript = AppDesignTokens.of(context).transcript;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final transcript = tokens.transcript;
|
||||
final trailingUser =
|
||||
user && !automated && transcript == TranscriptStyle.bubbles;
|
||||
// No visible role label: side and surface say who spoke and the row's
|
||||
@@ -104,9 +105,12 @@ class ChatMessageView extends StatelessWidget {
|
||||
label: '$role message',
|
||||
child: Padding(
|
||||
// A manuscript leaves a little more air between turns, as a page
|
||||
// spaces its paragraphs, since no bubble sets them apart.
|
||||
// spaces its paragraphs, since no bubble sets them apart; a dense
|
||||
// design a little less.
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: transcript == TranscriptStyle.manuscript ? 12 : 6,
|
||||
vertical: transcript == TranscriptStyle.manuscript
|
||||
? 12
|
||||
: tokens.density.space(6),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => Align(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -123,7 +124,8 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
: DateTime.now().difference(started);
|
||||
final seconds = duration.inSeconds.clamp(0, 2147483647);
|
||||
final label = '${data.label}${widget.streaming ? ' ${seconds}s' : ''}';
|
||||
switch (AppDesignTokens.of(context).transcript) {
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
switch (tokens.transcript) {
|
||||
case TranscriptStyle.prompt:
|
||||
return TerminalActivityRows(
|
||||
data: data,
|
||||
@@ -145,8 +147,12 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
}
|
||||
// Desktop hover hugs the label; phones keep the full-width touch row.
|
||||
final compact = prefersCompactHitTargets(context);
|
||||
// A dense design draws the line slimmer on a pointer device; a touch
|
||||
// device keeps a 40px target.
|
||||
final density = tokens.density;
|
||||
final dense = density.dense;
|
||||
final content = ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: 32),
|
||||
constraints: BoxConstraints(minHeight: dense ? 20 : 32),
|
||||
child: Row(
|
||||
mainAxisSize: compact ? MainAxisSize.min : MainAxisSize.max,
|
||||
children: [
|
||||
@@ -157,7 +163,7 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
child: const ChatResponsePending(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: density.space(8)),
|
||||
],
|
||||
Flexible(
|
||||
child: Text(
|
||||
@@ -179,8 +185,13 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
final button = TextButton(
|
||||
key: const Key('chat-turn-activity'),
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 48),
|
||||
padding: const EdgeInsets.all(chatAgentContentInset),
|
||||
minimumSize: Size(0, dense ? math.max(28, density.minTouchRow) : 48),
|
||||
padding: dense
|
||||
? const EdgeInsets.symmetric(
|
||||
horizontal: chatAgentContentInset,
|
||||
vertical: 4,
|
||||
)
|
||||
: const EdgeInsets.all(chatAgentContentInset),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
),
|
||||
|
||||
@@ -109,9 +109,9 @@ class _ChatTurnChipState extends State<ChatTurnChip> {
|
||||
).corners(BorderRadius.circular(8)),
|
||||
onTap: _show,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: chatAgentContentInset,
|
||||
vertical: 6,
|
||||
vertical: AppDesignTokens.of(context).density.space(6),
|
||||
),
|
||||
child: content,
|
||||
),
|
||||
|
||||
@@ -107,6 +107,7 @@ class _DefinitionGraphViewState extends State<DefinitionGraphView> {
|
||||
edges: edges,
|
||||
extents: extents,
|
||||
labelExtents: labelExtents,
|
||||
metrics: graphMetricsOf(context),
|
||||
);
|
||||
return (layout, routing);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
import '../layout/layout_models.dart';
|
||||
import '../layout/linear_graph_layout.dart';
|
||||
import '../routing/route_models.dart';
|
||||
|
||||
/// Centralized graph spacing, not component dimensions. Rank separation follows
|
||||
@@ -27,6 +29,25 @@ RoutingConfig graphCanvasRoutingConfig() => RoutingConfig(
|
||||
boundsPadding: 12,
|
||||
);
|
||||
|
||||
/// The drawing's spacings under the design at [context]: the web's metrics,
|
||||
/// or a dense design's tighter gaps, lanes and padding (Compact), so its
|
||||
/// smaller nodes are not left adrift in a comfortable layout.
|
||||
LinearGraphMetrics graphMetricsOf(BuildContext context) =>
|
||||
AppDesignTokens.of(context).density.dense
|
||||
? _denseGraphMetrics
|
||||
: const LinearGraphMetrics();
|
||||
|
||||
const LinearGraphMetrics _denseGraphMetrics = LinearGraphMetrics(
|
||||
hGap: 32,
|
||||
pad: 16,
|
||||
laneSpacing: 20,
|
||||
terminalGap: 16,
|
||||
trackStep: 16,
|
||||
portSpacing: 8,
|
||||
labelPadding: 6,
|
||||
labelGap: 2,
|
||||
);
|
||||
|
||||
/// The native theme roles one definition graph canvas needs.
|
||||
///
|
||||
/// No palette, font family or size is defined here: every value comes from the
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
import '../domain/graph_definition.dart';
|
||||
|
||||
/// One content-sized stage node as an ordinary native control.
|
||||
@@ -56,7 +59,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
button: true,
|
||||
selected: selected,
|
||||
label: _label,
|
||||
child: _materialCard(onPressed, content),
|
||||
child: _materialCard(context, onPressed, content),
|
||||
),
|
||||
);
|
||||
return active ? StageActivityHalo(child: control) : control;
|
||||
@@ -66,13 +69,29 @@ class GraphStageNode extends StatelessWidget {
|
||||
/// which assumes one line and cuts into a wrapped label's first and last
|
||||
/// line. A card keeps the rounded-rectangle surface the web node uses, and
|
||||
/// [selected] only chooses between two stock emphasis levels.
|
||||
Widget _materialCard(VoidCallback onPressed, Widget content) {
|
||||
Widget _materialCard(
|
||||
BuildContext context,
|
||||
VoidCallback onPressed,
|
||||
Widget content,
|
||||
) {
|
||||
// A dense design draws a smaller node: half the inset and a 32px
|
||||
// least height on a pointer device (40px on touch).
|
||||
final density = AppDesignTokens.of(context).density;
|
||||
final body = InkWell(
|
||||
onTap: onPressed,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: kMinInteractiveDimension),
|
||||
constraints: BoxConstraints(
|
||||
minHeight: density.dense
|
||||
? math.max(32, density.minTouchRow)
|
||||
: kMinInteractiveDimension,
|
||||
),
|
||||
child: Padding(
|
||||
padding: _contentPadding,
|
||||
padding: density.dense
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: density.space(_contentPadding.left) + 4,
|
||||
vertical: density.space(_contentPadding.top),
|
||||
)
|
||||
: _contentPadding,
|
||||
child: Align(
|
||||
// A terminal box widens to give each incoming route its own port;
|
||||
// its label stays centred in it.
|
||||
|
||||
@@ -140,6 +140,7 @@ class _RunGraphViewState extends State<RunGraphView> {
|
||||
edges: edges,
|
||||
extents: extents,
|
||||
labelExtents: labelExtents,
|
||||
metrics: graphMetricsOf(context),
|
||||
);
|
||||
return (layout, routing);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import '../../../ui/status/run_status_icon.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../../chat/ui/transcript/chat_markdown_view.dart';
|
||||
import '../domain/check_step_output.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The note under a command whose recorded output the server cut short.
|
||||
const String checkOutputTruncated =
|
||||
@@ -99,7 +100,9 @@ class RunCheckCommandRow extends StatelessWidget {
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(8)),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
|
||||
@@ -12,6 +12,7 @@ import '../../../ui/layout/sticky_section.dart';
|
||||
import '../../../ui/text/live_elapsed_builder.dart';
|
||||
import '../../../ui/text/monospace.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The Summary tab: the run's identity, the recorded facts as one grid,
|
||||
/// the stored original prompt with its copy control and the collapsible Input
|
||||
@@ -231,7 +232,9 @@ Widget _materialBlock(BuildContext context, DetailSummaryRow row) {
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.surfaceContainerHighest,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(8)),
|
||||
),
|
||||
child: SelectableText(
|
||||
row.value,
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../ui/text/live_elapsed_builder.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show formatDuration;
|
||||
import '../domain/run_models.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The Timeline tab's recorded visits, one shared list row per visit.
|
||||
///
|
||||
@@ -116,7 +117,9 @@ class RunTimelineRow extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withValues(alpha: 0.14),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(10)),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../../../core/transport/pipelines_client.dart'
|
||||
show configuredGatewayEndpoint;
|
||||
import '../../../ui/layout/app_list_avatar.dart';
|
||||
import '../../../ui/layout/app_overflow_menu.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
import '../../artifacts/domain/artifact_kind.dart';
|
||||
import '../../artifacts/domain/artifact_record.dart';
|
||||
import '../../artifacts/ui/artifact_tile.dart';
|
||||
@@ -48,9 +49,11 @@ Widget? searchArtifactThumbnail(BuildContext context, JsonMap hit) {
|
||||
return null;
|
||||
}
|
||||
return ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(BorderRadius.circular(8)),
|
||||
child: SizedBox.square(
|
||||
dimension: kAppListAvatarSize,
|
||||
dimension: appListAvatarSize(context),
|
||||
child: ArtifactThumbnail(
|
||||
key: ValueKey('search.thumbnail.${hit['target']}'),
|
||||
artifact: record,
|
||||
|
||||
@@ -56,6 +56,7 @@ class SettingsDesignSection extends StatelessWidget {
|
||||
subtitle: Text(design.description),
|
||||
secondary: DesignSwatchPreview(
|
||||
swatch: design.swatch(Theme.of(context).brightness),
|
||||
lines: design.swatchLines,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -64,12 +65,14 @@ class SettingsDesignSection extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// A design's small preview in the picker: its page with a line of its ink
|
||||
/// and a dot of its accent, framed by a hairline.
|
||||
/// A design's small preview in the picker: its page with [lines] lines of
|
||||
/// its ink (the last one short) and a dot of its accent, framed by a
|
||||
/// hairline. A dense design draws more, tighter lines in the same page.
|
||||
class DesignSwatchPreview extends StatelessWidget {
|
||||
const DesignSwatchPreview({super.key, required this.swatch});
|
||||
const DesignSwatchPreview({super.key, required this.swatch, this.lines = 2});
|
||||
|
||||
final DesignSwatch swatch;
|
||||
final int lines;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ExcludeSemantics(
|
||||
@@ -89,10 +92,14 @@ class DesignSwatchPreview extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(height: 2, color: swatch.ink),
|
||||
for (var line = 1; line < lines; line += 1)
|
||||
Container(height: lines > 2 ? 1 : 2, color: swatch.ink),
|
||||
FractionallySizedBox(
|
||||
widthFactor: 0.6,
|
||||
child: Container(height: 2, color: swatch.ink),
|
||||
child: Container(
|
||||
height: lines > 2 ? 1 : 2,
|
||||
color: swatch.ink,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -33,16 +33,17 @@ class SettingsGroup extends StatelessWidget {
|
||||
final footer = this.footer;
|
||||
final theme = Theme.of(context);
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final inset = settingsRowInsetOf(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
if (title != null)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||
settingsRowInset,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
inset,
|
||||
0,
|
||||
settingsRowInset,
|
||||
settingsTitleGap,
|
||||
inset,
|
||||
tokens.density.space(settingsTitleGap),
|
||||
),
|
||||
child: Semantics(
|
||||
header: true,
|
||||
@@ -74,7 +75,7 @@ class SettingsGroup extends StatelessWidget {
|
||||
Divider(
|
||||
height: 1,
|
||||
thickness: 1,
|
||||
indent: settingsRowInset,
|
||||
indent: inset,
|
||||
color: theme.colorScheme.outlineVariant,
|
||||
),
|
||||
child,
|
||||
@@ -92,11 +93,12 @@ class SettingsGroup extends StatelessWidget {
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
final text = DefaultTextStyle.merge(style: style, child: footer);
|
||||
final inset = settingsRowInsetOf(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||
settingsRowInset,
|
||||
settingsFieldGap + 2,
|
||||
settingsRowInset,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
inset,
|
||||
AppDesignTokens.of(context).density.space(settingsFieldGap + 2),
|
||||
inset,
|
||||
0,
|
||||
),
|
||||
child: text,
|
||||
@@ -124,8 +126,8 @@ class SettingsGroupItem extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.symmetric(
|
||||
horizontal: settingsRowInset,
|
||||
vertical: 12,
|
||||
horizontal: settingsRowInsetOf(context),
|
||||
vertical: AppDesignTokens.of(context).density.space(12),
|
||||
),
|
||||
child: child,
|
||||
),
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
/// at a reading width beside the section index.
|
||||
library;
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// The widest the column of groups grows on a wide window.
|
||||
const double settingsContentMaxWidth = 720;
|
||||
|
||||
@@ -50,3 +54,12 @@ const double settingsPreloadViewports = 1;
|
||||
|
||||
/// How long a changing endpoint must settle before a server section reloads.
|
||||
const Duration settingsEndpointDebounce = Duration(milliseconds: 600);
|
||||
|
||||
/// [settingsSectionGap] under the design at [context] (tighter when dense).
|
||||
double settingsSectionGapOf(BuildContext context) =>
|
||||
AppDesignTokens.of(context).density.space(settingsSectionGap);
|
||||
|
||||
/// [settingsRowInset] under the design at [context]: a dense design's rows
|
||||
/// (its ListTiles' 12px padding) and their headers keep the same edge.
|
||||
double settingsRowInsetOf(BuildContext context) =>
|
||||
AppDesignTokens.of(context).density.inset(settingsRowInset);
|
||||
|
||||
@@ -34,7 +34,7 @@ class SettingsPageBody extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
for (final (index, child) in children.indexed) ...<Widget>[
|
||||
if (index > 0) const SizedBox(height: settingsSectionGap),
|
||||
if (index > 0) SizedBox(height: settingsSectionGapOf(context)),
|
||||
child,
|
||||
],
|
||||
],
|
||||
|
||||
@@ -171,7 +171,7 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: settingsSectionGap),
|
||||
SizedBox(height: settingsSectionGapOf(context)),
|
||||
Expanded(child: _list(visible, insets)),
|
||||
],
|
||||
),
|
||||
@@ -201,7 +201,7 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
||||
Widget _list(List<SettingsSection> visible, EdgeInsets insets) {
|
||||
if (visible.isEmpty) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(settingsRowInset),
|
||||
padding: EdgeInsets.all(settingsRowInsetOf(context)),
|
||||
child: Text('No settings match "${_search.text.trim()}".'),
|
||||
);
|
||||
}
|
||||
@@ -222,7 +222,7 @@ class _SettingsSearchPageState extends State<SettingsSearchPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
for (final (index, section) in visible.indexed) ...<Widget>[
|
||||
if (index > 0) const SizedBox(height: settingsSectionGap),
|
||||
if (index > 0) SizedBox(height: settingsSectionGapOf(context)),
|
||||
KeyedSubtree(
|
||||
key: _keyFor(section.id),
|
||||
child: _isActive(section)
|
||||
|
||||
@@ -354,7 +354,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
child: ShellRailScope(
|
||||
shown: rail,
|
||||
bodyWidth: rail
|
||||
? media.size.width - kNavigationRailSpace
|
||||
? media.size.width - navigationRailSpaceOf(context)
|
||||
: null,
|
||||
child: scaffold,
|
||||
),
|
||||
|
||||
@@ -10,6 +10,15 @@ const double kNavigationRailWidth = 96;
|
||||
/// The rail with its divider: what the rail takes from a wide window's width.
|
||||
const double kNavigationRailSpace = kNavigationRailWidth + 1;
|
||||
|
||||
/// The rail's width under the design at [context]: [kNavigationRailWidth],
|
||||
/// or a dense design's narrower, icon-only rail.
|
||||
double navigationRailWidthOf(BuildContext context) =>
|
||||
AppDesignTokens.of(context).density.railWidth;
|
||||
|
||||
/// The rail with its divider under the design at [context].
|
||||
double navigationRailSpaceOf(BuildContext context) =>
|
||||
navigationRailWidthOf(context) + 1;
|
||||
|
||||
/// The narrowest window that shows the destination rail: the list-detail
|
||||
/// minimum for the body beside it, plus the rail and its divider (the space the
|
||||
/// shell takes from the window). Narrower windows keep the floating destination
|
||||
@@ -66,6 +75,7 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final index = shellTabDestinations.indexOf(selected);
|
||||
final surface = Theme.of(context).colorScheme.surface;
|
||||
final density = AppDesignTokens.of(context).density;
|
||||
// The surface runs under the top inset too: the padding only moves the
|
||||
// rail's content below the system's top, so no unpainted strip shows above
|
||||
// the rail's background.
|
||||
@@ -75,11 +85,12 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: SizedBox(
|
||||
width: kNavigationRailWidth,
|
||||
width: density.railWidth,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => _rail(
|
||||
index,
|
||||
surface,
|
||||
density,
|
||||
pinSettings:
|
||||
constraints.maxHeight >=
|
||||
kNavigationRailPinnedSettingsMinHeight,
|
||||
@@ -90,39 +101,46 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _rail(int index, Color surface, {required bool pinSettings}) =>
|
||||
NavigationRail(
|
||||
key: const ValueKey('shell.navigation-rail'),
|
||||
backgroundColor: surface,
|
||||
minWidth: kNavigationRailWidth,
|
||||
labelType: NavigationRailLabelType.all,
|
||||
selectedIndex: index < 0 ? null : index,
|
||||
onDestinationSelected: (value) =>
|
||||
onSelected(shellTabDestinations[value]),
|
||||
destinations: [
|
||||
for (final destination in shellTabDestinations)
|
||||
NavigationRailDestination(
|
||||
icon: KeyedSubtree(
|
||||
key: ValueKey('shell.destination.${destination.name}'),
|
||||
// The bar it replaces named each tab in a tooltip too.
|
||||
// The destination's label already names it for assistive
|
||||
// technology; the tooltip must not repeat it.
|
||||
child: Tooltip(
|
||||
message: destinationDetails(destination).label,
|
||||
excludeFromSemantics: true,
|
||||
child: icon(destination),
|
||||
),
|
||||
),
|
||||
label: Text(destinationDetails(destination).label),
|
||||
Widget _rail(
|
||||
int index,
|
||||
Color surface,
|
||||
DesignDensity density, {
|
||||
required bool pinSettings,
|
||||
}) => NavigationRail(
|
||||
key: const ValueKey('shell.navigation-rail'),
|
||||
backgroundColor: surface,
|
||||
minWidth: density.railWidth,
|
||||
// An icon-only rail names each tab in its tooltip alone.
|
||||
labelType: density.railLabels
|
||||
? NavigationRailLabelType.all
|
||||
: NavigationRailLabelType.none,
|
||||
selectedIndex: index < 0 ? null : index,
|
||||
onDestinationSelected: (value) => onSelected(shellTabDestinations[value]),
|
||||
destinations: [
|
||||
for (final destination in shellTabDestinations)
|
||||
NavigationRailDestination(
|
||||
icon: KeyedSubtree(
|
||||
key: ValueKey('shell.destination.${destination.name}'),
|
||||
// The bar it replaces named each tab in a tooltip too.
|
||||
// The destination's label already names it for assistive
|
||||
// technology; the tooltip must not repeat it.
|
||||
child: Tooltip(
|
||||
message: destinationDetails(destination).label,
|
||||
excludeFromSemantics: true,
|
||||
child: icon(destination),
|
||||
),
|
||||
],
|
||||
scrollable: true,
|
||||
trailingAtBottom: pinSettings,
|
||||
trailing: _SettingsRailItem(
|
||||
selected: selected == AppDestination.settings,
|
||||
onTap: () => onSelected(AppDestination.settings),
|
||||
),
|
||||
label: Text(destinationDetails(destination).label),
|
||||
),
|
||||
);
|
||||
],
|
||||
scrollable: true,
|
||||
trailingAtBottom: pinSettings,
|
||||
trailing: _SettingsRailItem(
|
||||
density: density,
|
||||
selected: selected == AppDestination.settings,
|
||||
onTap: () => onSelected(AppDestination.settings),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Settings at the rail's foot, drawn as a [NavigationRailDestination] is: an
|
||||
@@ -130,8 +148,13 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
/// It is not a [NavigationRailDestination] itself because the rail's
|
||||
/// destination list is the tabs, and `trailing` is what the rail pins.
|
||||
class _SettingsRailItem extends StatelessWidget {
|
||||
const _SettingsRailItem({required this.selected, required this.onTap});
|
||||
const _SettingsRailItem({
|
||||
required this.density,
|
||||
required this.selected,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
final DesignDensity density;
|
||||
final bool selected;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@@ -146,6 +169,33 @@ class _SettingsRailItem extends StatelessWidget {
|
||||
color: foreground,
|
||||
fontWeight: selected ? FontWeight.w600 : FontWeight.w500,
|
||||
);
|
||||
final indicator = Container(
|
||||
width: 56,
|
||||
height: 32,
|
||||
alignment: Alignment.center,
|
||||
decoration: ShapeDecoration(
|
||||
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
|
||||
color: selected ? scheme.secondaryContainer : null,
|
||||
),
|
||||
child: Icon(item.icon, color: foreground),
|
||||
);
|
||||
final Widget mark = density.railLabels
|
||||
? Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
indicator,
|
||||
const SizedBox(height: 4),
|
||||
Text(item.label, style: textStyle),
|
||||
],
|
||||
)
|
||||
// An icon-only rail names Settings in a tooltip, as its tabs.
|
||||
: Center(
|
||||
child: Tooltip(
|
||||
message: item.label,
|
||||
excludeFromSemantics: true,
|
||||
child: indicator,
|
||||
),
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
selected: selected,
|
||||
@@ -155,28 +205,10 @@ class _SettingsRailItem extends StatelessWidget {
|
||||
key: const ValueKey('shell.destination.settings'),
|
||||
onTap: onTap,
|
||||
child: SizedBox(
|
||||
width: kNavigationRailWidth,
|
||||
width: density.railWidth,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 56,
|
||||
height: 32,
|
||||
alignment: Alignment.center,
|
||||
decoration: ShapeDecoration(
|
||||
shape: AppDesignTokens.of(
|
||||
context,
|
||||
).shape(const StadiumBorder()),
|
||||
color: selected ? scheme.secondaryContainer : null,
|
||||
),
|
||||
child: Icon(item.icon, color: foreground),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(item.label, style: textStyle),
|
||||
],
|
||||
),
|
||||
padding: EdgeInsets.symmetric(vertical: density.space(12)),
|
||||
child: mark,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/theme/app_design_tokens.dart';
|
||||
import 'window_kind.dart';
|
||||
|
||||
const double windowCornerRadius = 12;
|
||||
|
||||
/// A floating window's corners under the design at [context]:
|
||||
/// [windowCornerRadius], or a dense design's own corners.
|
||||
BorderRadius windowCorners(BuildContext context) => AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(const BorderRadius.all(Radius.circular(windowCornerRadius)));
|
||||
|
||||
/// The height of a window's title bar: a compact row of icon buttons, taller
|
||||
/// with larger text.
|
||||
double windowTitleBarHeight(BuildContext context) =>
|
||||
MediaQuery.textScalerOf(context).scale(40).clamp(40.0, 64.0);
|
||||
/// with larger text (a dense design's slimmer bar grows the same way).
|
||||
double windowTitleBarHeight(BuildContext context) {
|
||||
final height = AppDesignTokens.of(context).density.titleBarHeight;
|
||||
return MediaQuery.textScalerOf(
|
||||
context,
|
||||
).scale(height).clamp(height, height + 24);
|
||||
}
|
||||
|
||||
/// A floating window's card and title bar: the title (drag to move, double
|
||||
/// click to maximise), the kind's actions, then Maximise and the X. The X
|
||||
@@ -45,10 +56,11 @@ class WindowFrame extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final colors = theme.colorScheme;
|
||||
final dense = AppDesignTokens.of(context).density.dense;
|
||||
return Material(
|
||||
elevation: 8,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
borderRadius: BorderRadius.circular(windowCornerRadius),
|
||||
borderRadius: windowCorners(context),
|
||||
color: colors.surfaceContainer,
|
||||
child: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
@@ -63,7 +75,7 @@ class WindowFrame extends StatelessWidget {
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: _title(theme)),
|
||||
Expanded(child: _title(theme, dense)),
|
||||
for (final action in actions)
|
||||
IconButton(
|
||||
tooltip: action.label,
|
||||
@@ -91,7 +103,7 @@ class WindowFrame extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _title(ThemeData theme) => MouseRegion(
|
||||
Widget _title(ThemeData theme, bool dense) => MouseRegion(
|
||||
cursor: maximized ? SystemMouseCursors.basic : SystemMouseCursors.move,
|
||||
child: GestureDetector(
|
||||
key: const ValueKey('window-title'),
|
||||
@@ -104,11 +116,15 @@ class WindowFrame extends StatelessWidget {
|
||||
onPanEnd: maximized ? null : (_) => onMoveEnd(),
|
||||
onDoubleTap: onToggleMaximized,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 12, end: 8),
|
||||
padding: EdgeInsetsDirectional.only(start: dense ? 8 : 12, end: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, size: 18, color: theme.colorScheme.onSurfaceVariant),
|
||||
const SizedBox(width: 8),
|
||||
Icon(
|
||||
icon,
|
||||
size: dense ? 16 : 18,
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
SizedBox(width: dense ? 6 : 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
@@ -137,7 +153,7 @@ class WindowOutline extends StatelessWidget {
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: colors.outlineVariant),
|
||||
borderRadius: BorderRadius.circular(windowCornerRadius),
|
||||
borderRadius: windowCorners(context),
|
||||
),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
|
||||
@@ -133,7 +133,7 @@ class _WindowHostState extends State<WindowHost> {
|
||||
// right, so they never sit under the rail.
|
||||
// The shell takes the rail and its divider (kNavigationRailSpace).
|
||||
final leading = widget.reservesRail && showsNavigationRail(context)
|
||||
? kNavigationRailSpace
|
||||
? navigationRailSpaceOf(context)
|
||||
: 0.0;
|
||||
final bounds = Size(
|
||||
constraints.maxWidth - leading,
|
||||
|
||||
@@ -2,11 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'window_frame.dart'
|
||||
show
|
||||
WindowOutline,
|
||||
WindowResizeGrip,
|
||||
windowCornerRadius,
|
||||
windowTitleBarHeight;
|
||||
show WindowOutline, WindowResizeGrip, windowCorners, windowTitleBarHeight;
|
||||
import 'window_scope.dart';
|
||||
|
||||
/// A floating window's own page stack. Pages pushed from the window's
|
||||
@@ -122,15 +118,15 @@ class WindowPageBox extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final body = WindowBodyScope.maybeOf(context);
|
||||
if (body == null) return child;
|
||||
const radius = Radius.circular(windowCornerRadius);
|
||||
final corners = windowCorners(context);
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fromRect(
|
||||
rect: body,
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
bottomLeft: radius,
|
||||
bottomRight: radius,
|
||||
borderRadius: BorderRadius.only(
|
||||
bottomLeft: corners.bottomLeft,
|
||||
bottomRight: corners.bottomRight,
|
||||
),
|
||||
child: MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(
|
||||
|
||||
@@ -423,7 +423,9 @@ class _SegmentedBarState extends State<SegmentedBar> {
|
||||
titleShare ??
|
||||
(widget.separateActionIslands ? .10 : SegmentedBar.minTitleShare);
|
||||
final besideTitle =
|
||||
width - (leading == null ? 0 : segmentedPieceHeight() + 8) - 8;
|
||||
width -
|
||||
(leading == null ? 0 : segmentedPieceHeight(context) + 8) -
|
||||
8;
|
||||
// Actions that cannot move (a model picker) may take the room down
|
||||
// to the title's minimum share; the rest leave for the More menu
|
||||
// before the title goes under its own width.
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_design_tokens.dart';
|
||||
import 'glass_pill.dart';
|
||||
import 'segmented_bar_motion.dart';
|
||||
|
||||
/// The smallest height of every piece of a [SegmentedBar]: the platform's
|
||||
/// minimum touch target, so a round Back is a circle.
|
||||
double segmentedPieceHeight() => kMinInteractiveDimension;
|
||||
/// minimum touch target, so a round Back is a circle. Under a dense design
|
||||
/// at [context] the pieces are 40px: its 32px controls with a 4px edge, still
|
||||
/// a comfortable touch target.
|
||||
double segmentedPieceHeight([BuildContext? context]) =>
|
||||
context != null && AppDesignTokens.of(context).density.dense
|
||||
? 40
|
||||
: kMinInteractiveDimension;
|
||||
|
||||
/// One rounded piece of a segmented bar: a [GlassPill] at least the
|
||||
/// platform's touch-target size.
|
||||
@@ -19,7 +25,7 @@ class SegmentedPill extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final height = segmentedPieceHeight();
|
||||
final height = segmentedPieceHeight(context);
|
||||
// A stadium whose content is as wide as it is tall is a circle.
|
||||
return GlassPill(
|
||||
fill: fill,
|
||||
@@ -75,6 +81,10 @@ Widget? impliedSegmentedLeading(BuildContext context) {
|
||||
/// The title pill's horizontal padding on each side.
|
||||
const double segmentedTitlePadding = 16;
|
||||
|
||||
/// [segmentedTitlePadding] under the design at [context] (12px when dense).
|
||||
double segmentedTitlePaddingOf(BuildContext context) =>
|
||||
AppDesignTokens.of(context).density.inset(segmentedTitlePadding);
|
||||
|
||||
/// The width the title pill needs to show [title] and [subtitle] whole (at
|
||||
/// the text scale at [context]).
|
||||
double segmentedTitleWidth(
|
||||
@@ -113,7 +123,7 @@ double segmentedTitleWidth(
|
||||
measure(' ', subtitleStyle));
|
||||
final text = measure(title, titleStyle);
|
||||
return (text > subWidth ? text : subWidth).ceilToDouble() +
|
||||
segmentedTitlePadding * 2;
|
||||
segmentedTitlePaddingOf(context) * 2;
|
||||
}
|
||||
|
||||
/// The title, with an optional one-line subtitle, in one pill; pressing it
|
||||
@@ -156,8 +166,8 @@ class SegmentedTitlePill extends StatelessWidget {
|
||||
);
|
||||
final subtitle = this.subtitle ?? '';
|
||||
final content = Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: segmentedTitlePadding,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: segmentedTitlePaddingOf(context),
|
||||
vertical: 4,
|
||||
),
|
||||
child: Row(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_design_tokens.dart';
|
||||
|
||||
/// The app's one search field.
|
||||
///
|
||||
@@ -53,8 +54,10 @@ class AppSearchField extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
const radius = BorderRadius.all(Radius.circular(28));
|
||||
const stadium = OutlineInputBorder(
|
||||
final radius = AppDesignTokens.of(
|
||||
context,
|
||||
).denseCorners(const BorderRadius.all(Radius.circular(28)));
|
||||
final stadium = OutlineInputBorder(
|
||||
borderRadius: radius,
|
||||
borderSide: BorderSide.none,
|
||||
);
|
||||
|
||||
@@ -5,6 +5,11 @@ import '../theme/app_design_tokens.dart';
|
||||
/// avatar ([CircleAvatar]'s default).
|
||||
const double kAppListAvatarSize = 40;
|
||||
|
||||
/// The leading avatar's size under the design at [context]:
|
||||
/// [kAppListAvatarSize], or a dense design's smaller one.
|
||||
double appListAvatarSize(BuildContext context) =>
|
||||
AppDesignTokens.of(context).density.avatarSize;
|
||||
|
||||
/// A list row's leading identity: an icon or an initial on a tinted circle,
|
||||
/// with an optional corner badge (a chat's activity indicator).
|
||||
///
|
||||
@@ -52,16 +57,19 @@ class AppListAvatar extends StatelessWidget {
|
||||
(foreground == null
|
||||
? Theme.of(context).colorScheme.surfaceContainerHighest
|
||||
: mark.withValues(alpha: 0.14));
|
||||
// The mark keeps the same proportion of the circle at every density.
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final size = tokens.density.avatarSize;
|
||||
final scale = size / kAppListAvatarSize;
|
||||
final initialStyle =
|
||||
(Theme.of(context).textTheme.titleMedium ?? const TextStyle()).copyWith(
|
||||
color: mark,
|
||||
fontSize: 18,
|
||||
fontSize: 18 * scale,
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1,
|
||||
);
|
||||
// A flat design (Terminal) frames the mark in a square box instead of a
|
||||
// tinted circle.
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final decoration = tokens.flat
|
||||
? BoxDecoration(
|
||||
border: Border.all(color: mark.withValues(alpha: 0.55)),
|
||||
@@ -69,18 +77,18 @@ class AppListAvatar extends StatelessWidget {
|
||||
)
|
||||
: BoxDecoration(color: fill, shape: BoxShape.circle);
|
||||
final circle = SizedBox.square(
|
||||
dimension: kAppListAvatarSize,
|
||||
dimension: size,
|
||||
child: DecoratedBox(
|
||||
decoration: decoration,
|
||||
child: Center(
|
||||
// The glyph is identity, not reading text: it scales down to stay
|
||||
// inside the circle under large text instead of overflowing it.
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
padding: EdgeInsets.all(8 * scale),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.scaleDown,
|
||||
child: IconTheme.merge(
|
||||
data: IconThemeData(color: mark, size: 22),
|
||||
data: IconThemeData(color: mark, size: 22 * scale),
|
||||
child: DefaultTextStyle(style: initialStyle, child: child),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -156,6 +156,7 @@ class AppListRow extends StatelessWidget {
|
||||
selected: selected,
|
||||
emphasized: emphasized,
|
||||
);
|
||||
final metrics = _RowMetrics.of(context);
|
||||
return Semantics(
|
||||
container: true,
|
||||
selected: selected,
|
||||
@@ -166,14 +167,16 @@ class AppListRow extends StatelessWidget {
|
||||
final minimal = constraints.maxWidth < kAppListRowMinimalWidth;
|
||||
final showLeading = leading != null && !minimal;
|
||||
final showMenu = menu != null && !minimal;
|
||||
final start = compact ? 12.0 : kAppListRowInset;
|
||||
final avatarGap = compact ? _compactAvatarGap : _avatarGap;
|
||||
final start = compact ? metrics.compactInset : metrics.inset;
|
||||
final avatarGap = compact
|
||||
? metrics.compactAvatarGap
|
||||
: metrics.avatarGap;
|
||||
final content = Padding(
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: start,
|
||||
end: showMenu ? 4 : kAppListRowInset,
|
||||
top: kAppListRowVerticalPadding,
|
||||
bottom: kAppListRowVerticalPadding,
|
||||
end: showMenu ? 4 : metrics.inset,
|
||||
top: metrics.vertical,
|
||||
bottom: metrics.vertical,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -187,7 +190,7 @@ class AppListRow extends StatelessWidget {
|
||||
padding: EdgeInsetsDirectional.only(end: avatarGap),
|
||||
child: leading,
|
||||
),
|
||||
Expanded(child: _text(styles, compact)),
|
||||
Expanded(child: _text(styles, metrics, compact)),
|
||||
if (showMenu)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 4),
|
||||
@@ -227,7 +230,12 @@ class AppListRow extends StatelessWidget {
|
||||
key: tapKey,
|
||||
onTap: onTap,
|
||||
onLongPress: onLongPress,
|
||||
child: content,
|
||||
child: metrics.minHeight > 0
|
||||
? ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: metrics.minHeight),
|
||||
child: Center(widthFactor: 1, child: content),
|
||||
)
|
||||
: content,
|
||||
),
|
||||
);
|
||||
// The colour bar runs the row's whole height, divider included, and
|
||||
@@ -261,7 +269,7 @@ class AppListRow extends StatelessWidget {
|
||||
// not known here, so a selectable row's divider starts at the inset.
|
||||
final textStart = selectionControl != null
|
||||
? start
|
||||
: start + (showLeading ? kAppListAvatarSize + avatarGap : 0);
|
||||
: start + (showLeading ? metrics.avatar + avatarGap : 0);
|
||||
final line = Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: textStart),
|
||||
child: SizedBox(
|
||||
@@ -306,7 +314,7 @@ class AppListRow extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _text(_RowStyles styles, bool compact) {
|
||||
Widget _text(_RowStyles styles, _RowMetrics metrics, bool compact) {
|
||||
final line = compact ? (compactSubtitle ?? subtitle) : subtitle;
|
||||
final time = _time(styles);
|
||||
final titleLine = LayoutBuilder(
|
||||
@@ -339,7 +347,7 @@ class AppListRow extends StatelessWidget {
|
||||
final detailLine = detail == null || (compact && !compactDetail)
|
||||
? null
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: _lineGap),
|
||||
padding: EdgeInsets.only(top: metrics.lineGap),
|
||||
child: DefaultTextStyle(
|
||||
style: styles.subtitle,
|
||||
maxLines: 1,
|
||||
@@ -354,7 +362,7 @@ class AppListRow extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
titleLine,
|
||||
const SizedBox(height: _lineGap),
|
||||
SizedBox(height: metrics.lineGap),
|
||||
timeLine,
|
||||
],
|
||||
);
|
||||
@@ -364,7 +372,7 @@ class AppListRow extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
titleLine,
|
||||
const SizedBox(height: _lineGap),
|
||||
SizedBox(height: metrics.lineGap),
|
||||
Row(
|
||||
children: [
|
||||
if (subtitleLeading != null)
|
||||
@@ -394,6 +402,57 @@ class AppListRow extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// The row's spacing under the design's density: the comfortable constants,
|
||||
/// or a dense design's tighter ones (a 36px single-line row and a ~52px
|
||||
/// two-line row on a pointer device; at least 40px on touch).
|
||||
class _RowMetrics {
|
||||
const _RowMetrics({
|
||||
required this.inset,
|
||||
required this.compactInset,
|
||||
required this.avatarGap,
|
||||
required this.compactAvatarGap,
|
||||
required this.vertical,
|
||||
required this.lineGap,
|
||||
required this.avatar,
|
||||
required this.minHeight,
|
||||
});
|
||||
|
||||
factory _RowMetrics.of(BuildContext context) {
|
||||
final density = AppDesignTokens.of(context).density;
|
||||
if (!density.dense) return _comfortable;
|
||||
return _RowMetrics(
|
||||
inset: density.inset(kAppListRowInset),
|
||||
compactInset: density.inset(12),
|
||||
avatarGap: density.space(_avatarGap),
|
||||
compactAvatarGap: density.space(_compactAvatarGap),
|
||||
vertical: density.space(kAppListRowVerticalPadding),
|
||||
lineGap: 0,
|
||||
avatar: density.avatarSize,
|
||||
minHeight: density.minTouchRow,
|
||||
);
|
||||
}
|
||||
|
||||
static const _comfortable = _RowMetrics(
|
||||
inset: kAppListRowInset,
|
||||
compactInset: 12,
|
||||
avatarGap: _avatarGap,
|
||||
compactAvatarGap: _compactAvatarGap,
|
||||
vertical: kAppListRowVerticalPadding,
|
||||
lineGap: _lineGap,
|
||||
avatar: kAppListAvatarSize,
|
||||
minHeight: 0,
|
||||
);
|
||||
|
||||
final double inset;
|
||||
final double compactInset;
|
||||
final double avatarGap;
|
||||
final double compactAvatarGap;
|
||||
final double vertical;
|
||||
final double lineGap;
|
||||
final double avatar;
|
||||
final double minHeight;
|
||||
}
|
||||
|
||||
/// The row's text styles, from the host's own type scale.
|
||||
class _RowStyles {
|
||||
const _RowStyles(this.title, this.subtitle, this.time, this.divider);
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design_tokens.dart';
|
||||
import 'app_theme.dart';
|
||||
import 'compact_theme.dart';
|
||||
import 'paper_theme.dart';
|
||||
import 'terminal_theme.dart';
|
||||
|
||||
@@ -49,6 +50,14 @@ enum AppDesign {
|
||||
'paper',
|
||||
'Paper',
|
||||
'Warm paper, serif reading text and ink colours; calm for long reads.',
|
||||
),
|
||||
|
||||
/// The Classic look packed tight for a big monitor: smaller type, thin
|
||||
/// rows, 18px icons, an icon-only rail and modest corners.
|
||||
compact(
|
||||
'compact',
|
||||
'Compact',
|
||||
'Classic’s Material look, dense: small type, thin rows, more on screen.',
|
||||
);
|
||||
|
||||
const AppDesign(this.id, this.label, this.description);
|
||||
@@ -100,8 +109,15 @@ enum AppDesign {
|
||||
(standard, Brightness.dark) => appDarkTheme(fontFamily: fontFamily),
|
||||
(terminal, _) => terminalTheme(brightness),
|
||||
(paper, _) => paperTheme(brightness, fontFamily: fontFamily),
|
||||
(compact, _) => compactTheme(brightness, fontFamily: fontFamily),
|
||||
};
|
||||
|
||||
/// Whether this design packs the interface densely
|
||||
/// ([DesignDensity.dense]); its theme hosts switch to and from it without
|
||||
/// a blend ([AppDesignController.themeAnimationDuration]).
|
||||
bool get dense =>
|
||||
light().extension<AppDesignTokens>()?.density.dense ?? false;
|
||||
|
||||
/// Whether the device's interface font applies under this design (Paper
|
||||
/// keeps it for its interface text and sets reading text in its serif).
|
||||
bool get usesInterfaceFont => this != terminal;
|
||||
@@ -111,7 +127,7 @@ enum AppDesign {
|
||||
DesignSwatch swatch(Brightness brightness) {
|
||||
final dark = brightness == Brightness.dark;
|
||||
return switch (this) {
|
||||
standard =>
|
||||
standard || compact =>
|
||||
dark
|
||||
? const DesignSwatch(
|
||||
Color(0xFF141416),
|
||||
@@ -149,6 +165,10 @@ enum AppDesign {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
/// How many lines of ink the picker's preview draws: Compact's packs more
|
||||
/// into the same page.
|
||||
int get swatchLines => this == compact ? 4 : 2;
|
||||
}
|
||||
|
||||
/// A design's three defining colours, for the picker's small preview.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart' show kThemeAnimationDuration;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'app_design.dart';
|
||||
@@ -87,7 +88,24 @@ class AppDesignController extends ChangeNotifier {
|
||||
void preview(AppDesign? design) {
|
||||
final shown = this.design;
|
||||
_preview = design;
|
||||
if (this.design != shown) notifyListeners();
|
||||
if (this.design != shown) _shown(shown);
|
||||
}
|
||||
|
||||
/// How long the theme hosts blend into the current design (their
|
||||
/// `themeAnimationDuration`): Material's blend between designs of the same
|
||||
/// density, none for a switch into or out of a dense design. A dense
|
||||
/// design's sizes (icons, controls) have no value in a comfortable theme to
|
||||
/// blend from, so a blend would pass every icon through size zero, and in
|
||||
/// the browser (skwasm) laying out the near-zero icon glyphs could hang.
|
||||
Duration get themeAnimationDuration =>
|
||||
_snapTheme ? Duration.zero : kThemeAnimationDuration;
|
||||
bool _snapTheme = false;
|
||||
|
||||
/// The shown design changed from [before]: decide the hosts' blend and
|
||||
/// tell them.
|
||||
void _shown(AppDesign before) {
|
||||
_snapTheme = before.dense || design.dense;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// The last choice could not be stored on this device.
|
||||
@@ -100,8 +118,9 @@ class AppDesignController extends ChangeNotifier {
|
||||
if (revision != _revision || id == null) return;
|
||||
final design = AppDesign.fromId(id);
|
||||
if (design == _design) return;
|
||||
final shown = this.design;
|
||||
_design = design;
|
||||
if (_preview == null) notifyListeners();
|
||||
if (_preview == null) _shown(shown);
|
||||
}
|
||||
|
||||
/// Applies [design] now and stores it.
|
||||
@@ -111,7 +130,7 @@ class AppDesignController extends ChangeNotifier {
|
||||
final shown = this.design;
|
||||
_preview = null;
|
||||
_design = design;
|
||||
if (design != shown) notifyListeners();
|
||||
if (design != shown) _shown(shown);
|
||||
final saved = await _store.save(design.id);
|
||||
if (revision != _revision || saved != _saveFailed) return;
|
||||
_saveFailed = !saved;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/painting.dart';
|
||||
|
||||
export 'design_density.dart';
|
||||
|
||||
/// How the chat transcript draws a conversation. Each design picks one; the
|
||||
/// transcript widgets branch on it, never on the design itself.
|
||||
enum TranscriptStyle {
|
||||
@@ -54,6 +56,7 @@ class ReadingType {
|
||||
this.measure,
|
||||
this.scale = 1,
|
||||
this.figureWidth = 0.5,
|
||||
this.paragraphGap = 0.9,
|
||||
});
|
||||
|
||||
/// The reading face; null keeps the theme's body face.
|
||||
@@ -73,6 +76,10 @@ class ReadingType {
|
||||
/// [measure] is worth (half an em for Source Serif's figures).
|
||||
final double figureWidth;
|
||||
|
||||
/// The gap between two paragraphs of an answer, in lines of reading text
|
||||
/// (before text scaling): about a line by default, less for a dense design.
|
||||
final double paragraphGap;
|
||||
|
||||
/// [base] in the reading face, size and line height.
|
||||
TextStyle? apply(TextStyle? base) {
|
||||
if (base == null) return null;
|
||||
@@ -98,8 +105,10 @@ class ReadingType {
|
||||
other.height == height &&
|
||||
other.measure == measure &&
|
||||
other.scale == scale &&
|
||||
other.figureWidth == figureWidth;
|
||||
other.figureWidth == figureWidth &&
|
||||
other.paragraphGap == paragraphGap;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(family, height, measure, scale, figureWidth);
|
||||
int get hashCode =>
|
||||
Object.hash(family, height, measure, scale, figureWidth, paragraphGap);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
this.selectedRow = SelectedRowStyle.tonal,
|
||||
this.reading = const ReadingType(),
|
||||
this.chatColorSaturation = 1,
|
||||
this.density = DesignDensity.comfortable,
|
||||
});
|
||||
|
||||
/// The Classic design: every widget keeps its own shapes.
|
||||
@@ -111,6 +112,10 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
/// palette as is, lower to quieten it towards ink.
|
||||
final double chatColorSaturation;
|
||||
|
||||
/// How tightly the interface is packed: spacing, icon and avatar sizes,
|
||||
/// the rail and the window title bar ([DesignDensity.compact] for Compact).
|
||||
final DesignDensity density;
|
||||
|
||||
/// Whether the transcript draws prompt and tool lines rather than bubbles.
|
||||
bool get terminal => transcript == TranscriptStyle.prompt;
|
||||
|
||||
@@ -132,6 +137,12 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
return r == null ? designed : BorderRadius.circular(r);
|
||||
}
|
||||
|
||||
/// [designed] corners, or [radius] corners under a dense design: for the
|
||||
/// surfaces whose own corners the comfortable designs keep (floating
|
||||
/// windows, search thumbnails), so only a dense design rounds them alike.
|
||||
BorderRadius denseCorners(BorderRadius designed) =>
|
||||
density.dense ? corners(designed) : designed;
|
||||
|
||||
/// [designed] (a widget's own fill) or, under a flat design, its [panel].
|
||||
Color panelFill(ColorScheme scheme, Color designed) =>
|
||||
flat ? panel ?? scheme.surfaceContainerLow : designed;
|
||||
@@ -156,6 +167,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
SelectedRowStyle? selectedRow,
|
||||
ReadingType? reading,
|
||||
double? chatColorSaturation,
|
||||
DesignDensity? density,
|
||||
}) => AppDesignTokens(
|
||||
design: design ?? this.design,
|
||||
radius: radius ?? this.radius,
|
||||
@@ -169,6 +181,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
selectedRow: selectedRow ?? this.selectedRow,
|
||||
reading: reading ?? this.reading,
|
||||
chatColorSaturation: chatColorSaturation ?? this.chatColorSaturation,
|
||||
density: density ?? this.density,
|
||||
);
|
||||
|
||||
// Value equality keeps a rebuilt theme equal to the one it replaces, so
|
||||
@@ -188,7 +201,8 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
other.composer == composer &&
|
||||
other.selectedRow == selectedRow &&
|
||||
other.reading == reading &&
|
||||
other.chatColorSaturation == chatColorSaturation;
|
||||
other.chatColorSaturation == chatColorSaturation &&
|
||||
other.density == density;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
@@ -204,6 +218,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
selectedRow,
|
||||
reading,
|
||||
chatColorSaturation,
|
||||
density,
|
||||
);
|
||||
|
||||
/// Designs switch whole: a theme animation snaps halfway rather than
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'compact_theme.dart';
|
||||
|
||||
const BorderRadius _corners = BorderRadius.all(Radius.circular(compactRadius));
|
||||
const RoundedRectangleBorder _rounded = RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
);
|
||||
|
||||
/// [base] with Compact's controls: Default's Material components at dense
|
||||
/// heights, in [compactRadius] corners, with 4px-grid paddings. Their text
|
||||
/// keeps each component's own Material role (already at Compact's sizes):
|
||||
/// a component theme that sets a text-theme style cannot be lerped against
|
||||
/// Default's unset one, which breaks a live design switch. Floating
|
||||
/// surfaces (menus, dialogs, sheets, tooltips, snack bars) keep Material's
|
||||
/// elevation and fills; only their corners and insets change.
|
||||
ThemeData compactControls(ThemeData base) {
|
||||
final scheme = base.colorScheme;
|
||||
const icon = 18.0;
|
||||
// Buttons: 32px tall under compact density, 12px side padding, 18px icons.
|
||||
ButtonStyle buttons() => const ButtonStyle(
|
||||
shape: WidgetStatePropertyAll(_rounded),
|
||||
padding: WidgetStatePropertyAll(EdgeInsets.symmetric(horizontal: 12)),
|
||||
iconSize: WidgetStatePropertyAll(icon),
|
||||
);
|
||||
final menu = MenuStyle(
|
||||
shape: const WidgetStatePropertyAll(_rounded),
|
||||
padding: const WidgetStatePropertyAll(EdgeInsets.symmetric(vertical: 4)),
|
||||
visualDensity: VisualDensity.compact,
|
||||
);
|
||||
return base.copyWith(
|
||||
filledButtonTheme: FilledButtonThemeData(style: buttons()),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(style: buttons()),
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(style: buttons()),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: buttons().copyWith(
|
||||
padding: const WidgetStatePropertyAll(
|
||||
EdgeInsets.symmetric(horizontal: 8),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Material 3's icon button ignores the theme's density unless its own
|
||||
// style sets one: 32px drawn, its target padded to 40px on touch.
|
||||
iconButtonTheme: const IconButtonThemeData(
|
||||
style: ButtonStyle(
|
||||
visualDensity: VisualDensity.compact,
|
||||
iconSize: WidgetStatePropertyAll(icon),
|
||||
// A square 32px button around its 18px icon.
|
||||
padding: WidgetStatePropertyAll(EdgeInsets.all(7)),
|
||||
shape: WidgetStatePropertyAll(_rounded),
|
||||
),
|
||||
),
|
||||
segmentedButtonTheme: SegmentedButtonThemeData(
|
||||
style: buttons().copyWith(visualDensity: VisualDensity.compact),
|
||||
),
|
||||
// A 40px action (Material's small FAB) and a 40px extended one.
|
||||
floatingActionButtonTheme: FloatingActionButtonThemeData(
|
||||
shape: _rounded,
|
||||
iconSize: icon,
|
||||
sizeConstraints: const BoxConstraints.tightFor(width: 40, height: 40),
|
||||
// Only a least height: a larger text scale still grows the label.
|
||||
extendedSizeConstraints: const BoxConstraints(
|
||||
minHeight: 40,
|
||||
minWidth: 64,
|
||||
),
|
||||
extendedPadding: const EdgeInsetsDirectional.only(start: 12, end: 16),
|
||||
extendedIconLabelSpacing: 8,
|
||||
),
|
||||
menuTheme: MenuThemeData(style: menu),
|
||||
dropdownMenuTheme: DropdownMenuThemeData(
|
||||
menuStyle: menu,
|
||||
inputDecorationTheme: const InputDecorationTheme(isDense: true),
|
||||
),
|
||||
menuButtonTheme: MenuButtonThemeData(
|
||||
style: MenuItemButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
minimumSize: const Size(0, 32),
|
||||
iconSize: icon,
|
||||
),
|
||||
),
|
||||
popupMenuTheme: PopupMenuThemeData(
|
||||
shape: _rounded,
|
||||
menuPadding: const EdgeInsets.symmetric(vertical: 4),
|
||||
),
|
||||
dialogTheme: DialogThemeData(
|
||||
shape: _rounded,
|
||||
insetPadding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
|
||||
actionsPadding: const EdgeInsets.fromLTRB(16, 0, 16, 12),
|
||||
),
|
||||
bottomSheetTheme: const BottomSheetThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(compactRadius),
|
||||
),
|
||||
),
|
||||
),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
shape: _rounded,
|
||||
insetPadding: const EdgeInsets.fromLTRB(12, 4, 12, 12),
|
||||
),
|
||||
tooltipTheme: TooltipThemeData(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.inverseSurface,
|
||||
borderRadius: _corners,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
waitDuration: const Duration(milliseconds: 400),
|
||||
),
|
||||
// A hairline on every card variant: the theme's shape replaces each
|
||||
// variant's own, so an outlined card (a graph node) keeps its outline.
|
||||
cardTheme: CardThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
side: BorderSide(color: scheme.outlineVariant),
|
||||
),
|
||||
margin: const EdgeInsets.all(4),
|
||||
),
|
||||
chipTheme: ChipThemeData(
|
||||
shape: _rounded,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
|
||||
labelPadding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
iconTheme: const IconThemeData(size: 16),
|
||||
),
|
||||
inputDecorationTheme: const InputDecorationTheme(
|
||||
isDense: true,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
),
|
||||
searchBarTheme: SearchBarThemeData(
|
||||
shape: const WidgetStatePropertyAll(_rounded),
|
||||
constraints: const BoxConstraints(minWidth: 240, minHeight: 36),
|
||||
padding: const WidgetStatePropertyAll(
|
||||
EdgeInsets.symmetric(horizontal: 12),
|
||||
),
|
||||
),
|
||||
listTileTheme: const ListTileThemeData(
|
||||
dense: true,
|
||||
visualDensity: VisualDensity.compact,
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 12),
|
||||
horizontalTitleGap: 12,
|
||||
minLeadingWidth: 20,
|
||||
minVerticalPadding: 6,
|
||||
shape: _rounded,
|
||||
),
|
||||
expansionTileTheme: const ExpansionTileThemeData(
|
||||
tilePadding: EdgeInsets.symmetric(horizontal: 12),
|
||||
childrenPadding: EdgeInsets.symmetric(horizontal: 12),
|
||||
shape: Border(),
|
||||
collapsedShape: Border(),
|
||||
),
|
||||
navigationRailTheme: NavigationRailThemeData(
|
||||
minWidth: 64,
|
||||
labelType: NavigationRailLabelType.none,
|
||||
indicatorShape: _rounded,
|
||||
indicatorColor: scheme.secondaryContainer,
|
||||
selectedIconTheme: IconThemeData(
|
||||
size: icon,
|
||||
color: scheme.onSecondaryContainer,
|
||||
),
|
||||
unselectedIconTheme: IconThemeData(
|
||||
size: icon,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
groupAlignment: -1,
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
height: 64,
|
||||
indicatorShape: _rounded,
|
||||
iconTheme: const WidgetStatePropertyAll(IconThemeData(size: icon)),
|
||||
),
|
||||
tabBarTheme: TabBarThemeData(
|
||||
labelPadding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
),
|
||||
dividerTheme: const DividerThemeData(space: 8, thickness: 1),
|
||||
badgeTheme: BadgeThemeData(
|
||||
smallSize: 6,
|
||||
largeSize: 14,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
),
|
||||
checkboxTheme: const CheckboxThemeData(
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
radioTheme: const RadioThemeData(visualDensity: VisualDensity.compact),
|
||||
scrollbarTheme: const ScrollbarThemeData(
|
||||
radius: Radius.circular(3),
|
||||
thickness: WidgetStatePropertyAll(6),
|
||||
),
|
||||
drawerTheme: const DrawerThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.horizontal(
|
||||
right: Radius.circular(compactRadius),
|
||||
),
|
||||
),
|
||||
),
|
||||
datePickerTheme: const DatePickerThemeData(shape: _rounded),
|
||||
timePickerTheme: const TimePickerThemeData(shape: _rounded),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design.dart';
|
||||
import 'app_design_tokens.dart';
|
||||
import 'app_theme.dart';
|
||||
import 'compact_controls.dart';
|
||||
import 'compact_typography.dart';
|
||||
|
||||
/// Compact's corner radius: every card, field, button, chip, menu, dialog,
|
||||
/// sheet, tooltip, snack bar, bubble and window takes it.
|
||||
const double compactRadius = 6;
|
||||
|
||||
/// The Compact design's theme: Default's Material 3 colours and surfaces,
|
||||
/// packed for a big monitor and long runs and chats. A smaller type scale
|
||||
/// ([compactTextTheme]), Material's compact visual density, 18px icons, and
|
||||
/// [compactRadius] corners on every surface. On a touch device controls keep
|
||||
/// a 40px tap target (Material's padded target under compact density); on a
|
||||
/// pointer device they shrink to their drawn size.
|
||||
ThemeData compactTheme(Brightness brightness, {String? fontFamily}) {
|
||||
final standard = brightness == Brightness.dark
|
||||
? appDarkTheme(fontFamily: fontFamily)
|
||||
: appLightTheme(fontFamily: fontFamily);
|
||||
final textTheme = compactTextTheme(standard.textTheme);
|
||||
final themed = standard.copyWith(
|
||||
visualDensity: VisualDensity.compact,
|
||||
materialTapTargetSize: DesignDensity.pointerPlatform
|
||||
? MaterialTapTargetSize.shrinkWrap
|
||||
: MaterialTapTargetSize.padded,
|
||||
textTheme: textTheme,
|
||||
primaryTextTheme: compactTextTheme(standard.primaryTextTheme),
|
||||
iconTheme: standard.iconTheme.copyWith(
|
||||
size: DesignDensity.compact.iconSize,
|
||||
),
|
||||
primaryIconTheme: standard.primaryIconTheme.copyWith(
|
||||
size: DesignDensity.compact.iconSize,
|
||||
),
|
||||
extensions: const [
|
||||
AppDesignTokens(
|
||||
design: AppDesign.compact,
|
||||
radius: compactRadius,
|
||||
reading: compactReading,
|
||||
density: DesignDensity.compact,
|
||||
),
|
||||
],
|
||||
);
|
||||
return compactControls(themed);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design_styles.dart';
|
||||
|
||||
/// Compact's reading type: the interface face at the dense body size
|
||||
/// (`bodyLarge`, 14px), a little more line height than the role's so long
|
||||
/// answers stay easy to follow, and about two thirds of a line between
|
||||
/// paragraphs.
|
||||
const ReadingType compactReading = ReadingType(height: 1.5, paragraphGap: 0.6);
|
||||
|
||||
/// [base] (Material 3's type scale, in the device's interface face) at
|
||||
/// Compact's sizes: body 13px, labels 11-12px, list and dialog titles 14 and
|
||||
/// 18px. Line heights sit on a 2px step so rows of mixed roles still line up
|
||||
/// on the 4px grid. Weights, colours, families and tracking stay Material's;
|
||||
/// text scaling still applies on top.
|
||||
TextTheme compactTextTheme(TextTheme base) {
|
||||
TextStyle? sized(TextStyle? style, double size, double line) =>
|
||||
style?.copyWith(fontSize: size, height: line / size);
|
||||
return base.copyWith(
|
||||
displayLarge: sized(base.displayLarge, 44, 52),
|
||||
displayMedium: sized(base.displayMedium, 36, 44),
|
||||
displaySmall: sized(base.displaySmall, 28, 36),
|
||||
headlineLarge: sized(base.headlineLarge, 26, 32),
|
||||
headlineMedium: sized(base.headlineMedium, 22, 28),
|
||||
headlineSmall: sized(base.headlineSmall, 20, 26),
|
||||
titleLarge: sized(base.titleLarge, 18, 24),
|
||||
titleMedium: sized(base.titleMedium, 14, 20),
|
||||
titleSmall: sized(base.titleSmall, 13, 18),
|
||||
bodyLarge: sized(base.bodyLarge, 14, 20),
|
||||
bodyMedium: sized(base.bodyMedium, 13, 18),
|
||||
bodySmall: sized(base.bodySmall, 11.5, 16),
|
||||
labelLarge: sized(base.labelLarge, 13, 18),
|
||||
labelMedium: sized(base.labelMedium, 12, 16),
|
||||
labelSmall: sized(base.labelSmall, 11, 14),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// How tightly a design packs the interface: the spacing inside and between
|
||||
/// components, icon and avatar sizes, the navigation rail's width and labels
|
||||
/// and the floating window title bar. [comfortable] is the Default look;
|
||||
/// every widget that reads a density keeps its own value under it, so the
|
||||
/// comfortable designs draw exactly as before.
|
||||
///
|
||||
/// A dense design sets [spacing] below 1: [space] then scales a widget's own
|
||||
/// spacing and snaps it to the 4px grid, so every component tightens by the
|
||||
/// same proportion instead of each picking its own number.
|
||||
@immutable
|
||||
class DesignDensity {
|
||||
const DesignDensity({
|
||||
this.spacing = 1,
|
||||
this.iconSize,
|
||||
this.avatarSize = 40,
|
||||
this.railWidth = 96,
|
||||
this.railLabels = true,
|
||||
this.titleBarHeight = 40,
|
||||
});
|
||||
|
||||
/// The Default density.
|
||||
static const DesignDensity comfortable = DesignDensity();
|
||||
|
||||
/// The Compact density: spacing at 60% on the 4px grid, 18px icons, 28px
|
||||
/// avatars, an icon-only 64px rail and a 32px window title bar.
|
||||
static const DesignDensity compact = DesignDensity(
|
||||
spacing: 0.6,
|
||||
iconSize: 18,
|
||||
avatarSize: 28,
|
||||
railWidth: 64,
|
||||
railLabels: false,
|
||||
titleBarHeight: 32,
|
||||
);
|
||||
|
||||
/// The proportion of a widget's own spacing this density keeps.
|
||||
final double spacing;
|
||||
|
||||
/// The interface's icon size; null keeps Material's 24.
|
||||
final double? iconSize;
|
||||
|
||||
/// A list row's leading avatar.
|
||||
final double avatarSize;
|
||||
|
||||
/// The destination rail's width on a wide window.
|
||||
final double railWidth;
|
||||
|
||||
/// Whether the rail labels its destinations under their icons; without
|
||||
/// them the rail shows icons with tooltips.
|
||||
final bool railLabels;
|
||||
|
||||
/// A floating window's title bar height, before text scaling.
|
||||
final double titleBarHeight;
|
||||
|
||||
/// Whether this density is tighter than [comfortable].
|
||||
bool get dense => spacing < 1;
|
||||
|
||||
/// [comfortable] spacing under this density: unchanged at [spacing] 1,
|
||||
/// otherwise scaled and snapped to the 4px grid (a gap under 4px keeps a
|
||||
/// 2px step, so a hairline gap never collapses to nothing).
|
||||
double space(double comfortable) {
|
||||
if (spacing == 1 || comfortable <= 0) return comfortable;
|
||||
final scaled = comfortable * spacing;
|
||||
if (scaled < 4) return scaled < 3 ? 2 : 4;
|
||||
return (scaled / 4).round() * 4.0;
|
||||
}
|
||||
|
||||
/// [comfortable] edge inset (a row's or a panel's side padding) under this
|
||||
/// density: halfway between [space] and the comfortable value, on the 4px
|
||||
/// grid, so a dense row's text still keeps clear of the pane's edge
|
||||
/// (16px becomes 12px at Compact).
|
||||
double inset(double comfortable) {
|
||||
if (spacing == 1 || comfortable <= 0) return comfortable;
|
||||
final scaled = comfortable * (1 + spacing) / 2;
|
||||
return scaled < 4 ? 4 : (scaled / 4).round() * 4.0;
|
||||
}
|
||||
|
||||
/// The least height a tappable row keeps under this density: nothing
|
||||
/// beyond its content when comfortable (its own padding already gives
|
||||
/// room) or on a pointer device, and 40px on a touch device, so a dense
|
||||
/// row stays easy to hit with a finger.
|
||||
double get minTouchRow {
|
||||
if (!dense) return 0;
|
||||
return pointerPlatform ? 0 : 40;
|
||||
}
|
||||
|
||||
/// Whether the device drives the app with a pointer (desktop, including a
|
||||
/// desktop browser). Reads the device's platform, not the theme's: web
|
||||
/// themes are pinned to Android.
|
||||
static bool get pointerPlatform => switch (defaultTargetPlatform) {
|
||||
TargetPlatform.macOS ||
|
||||
TargetPlatform.linux ||
|
||||
TargetPlatform.windows => true,
|
||||
TargetPlatform.android ||
|
||||
TargetPlatform.iOS ||
|
||||
TargetPlatform.fuchsia => false,
|
||||
};
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
other is DesignDensity &&
|
||||
other.spacing == spacing &&
|
||||
other.iconSize == iconSize &&
|
||||
other.avatarSize == avatarSize &&
|
||||
other.railWidth == railWidth &&
|
||||
other.railLabels == railLabels &&
|
||||
other.titleBarHeight == titleBarHeight;
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(
|
||||
spacing,
|
||||
iconSize,
|
||||
avatarSize,
|
||||
railWidth,
|
||||
railLabels,
|
||||
titleBarHeight,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
# Compact design
|
||||
|
||||
Classic's (formerly Default's) Material 3 look, packed tight for a big monitor and long runs and
|
||||
chats (Settings > Design > Compact). It has the same colours and glass bars
|
||||
as Default. Type is smaller: body 13px, labels 11-12px, chat reading 14px on a
|
||||
1.5 line. Spacing sits on a 4px grid. Rows are 36px with one line and about
|
||||
54px with two. Icons are 18px, avatars 28px, and every corner is 6px.
|
||||
|
||||
## Tokens
|
||||
|
||||
- `density` (`DesignDensity`, `design_density.dart`; `comfortable` for every
|
||||
other design). It holds `spacing` (0.6), `iconSize` (18), `avatarSize`
|
||||
(28), `railWidth` (64), `railLabels` (false) and `titleBarHeight` (32).
|
||||
- `space(v)` scales a widget's own spacing and snaps it to the 4px grid.
|
||||
- `inset(v)` does the same for side insets, halfway between: 16 becomes 12.
|
||||
- `minTouchRow` is 40 on touch devices and 0 on pointer devices.
|
||||
- `dense` and `pointerPlatform` are also available. All of them return the
|
||||
input unchanged when the density is comfortable, so other designs keep
|
||||
their numbers.
|
||||
- `ReadingType.paragraphGap` is the gap between paragraphs of an answer, in
|
||||
lines. Default is 0.9; Compact is 0.6.
|
||||
- `AppDesignTokens.denseCorners(r)` gives the design's radius only under a
|
||||
dense design. It is for surfaces whose own corners the comfortable designs
|
||||
keep: floating windows (12), search thumbnails, find bars, run detail
|
||||
boxes and the search field stadium.
|
||||
- `AppDesign.dense` and `AppDesign.swatchLines` (the picker preview draws 4
|
||||
thin lines for Compact).
|
||||
|
||||
## Themed surfaces
|
||||
|
||||
- `compact_theme.dart`, `compact_controls.dart`, `compact_typography.dart`:
|
||||
- visual density is `compact`;
|
||||
- the tap target is `shrinkWrap` on desktop and `padded` (40px) on touch;
|
||||
- Material 3 icon buttons need their own `visualDensity`, otherwise they
|
||||
ignore the theme's; they are 32px with a padding of 7;
|
||||
- buttons, chips, fields, the search bar, list tiles, menus, popups,
|
||||
dialogs, sheets, snack bars, tooltips, FABs (40px), the rail, the
|
||||
navigation bar, tabs, badges, the scrollbar, date and time pickers all
|
||||
take 6px corners and dense paddings;
|
||||
- cards get a hairline, so `Card.outlined` (graph nodes) keeps its outline.
|
||||
- `AppListRow` / `AppListAvatar`: dense insets, padding and avatar size, plus
|
||||
the touch minimum.
|
||||
- `ShellNavigationRail`: 64px wide, icons only with tooltips. Settings uses
|
||||
the same 56x32 indicator as the tabs.
|
||||
- The shell and window host read the rail width through
|
||||
`navigationRailSpaceOf`.
|
||||
- Chat:
|
||||
- the operator bubble has 6px corners and 12/8 padding;
|
||||
- turn gaps and the paragraph gap are tighter;
|
||||
- the activity line is 28px (40px on touch);
|
||||
- turn chips, follow-up and automatic-continue cards are tighter;
|
||||
- code blocks use 8px insets with monospace at 13/14;
|
||||
- the composer is a 40px pill, and its field padding is 10 because
|
||||
density takes 4px off each side.
|
||||
- Top bars: segmented pieces are 40px (`segmentedPieceHeight(context)`) and
|
||||
title pill padding is 12. Chat bar text buttons have a 32px minimum.
|
||||
- Floating windows: a 32px title bar with 16px icons and 6px corners on the
|
||||
frame, outline and page clip.
|
||||
- Graph: nodes use 12/8 insets with a 32px minimum height.
|
||||
`graphMetricsOf(context)` tightens the gaps, lanes and padding.
|
||||
- Settings: `settingsSectionGapOf` and `settingsRowInsetOf` give 16 and 12,
|
||||
and the group header, footer and item paddings are dense.
|
||||
|
||||
## Live switch
|
||||
|
||||
A switch into or out of a dense design does not blend
|
||||
(`AppDesignController.themeAnimationDuration` is zero). The reason:
|
||||
`ThemeData.lerp` takes a component theme's unset size as 0, so every icon
|
||||
(and any text style set in a component theme) passes through size 0. In
|
||||
skwasm, laying out glyphs at nearly zero size hung the page. This was
|
||||
bisected with `tool/perf/design_bench.mjs`, and the pause stack showed
|
||||
`paragraph_layout`.
|
||||
|
||||
For the same reason, Compact's component themes set no text styles. Each
|
||||
component keeps its Material role, which is already at Compact's size.
|
||||
`test/ui/theme/compact_switch_test.dart` checks every frame of a switch.
|
||||
|
||||
Default, Terminal and Paper keep their blend.
|
||||
|
||||
## Perf budget changes
|
||||
|
||||
- `test/perf/design_bench_test.dart` budgets `scrollRebuildsPerRow`, not
|
||||
per frame. A denser design shows more rows in each 120px step.
|
||||
- `design_bench.mjs` gives the chat-switch clicks per-design points
|
||||
(`compact: [x, y]`), checked with `tool/capture`.
|
||||
|
||||
## Still Default
|
||||
|
||||
- Sliders and switches keep their size.
|
||||
- Tab heights are not themeable.
|
||||
- The walkthrough's bullet dot sits off the baseline in every design.
|
||||
- The glass bar margins (`kFloatingBarMargin`) and `GlassBarMetrics` (artifact
|
||||
viewer, chevron pager) keep 48px.
|
||||
- Fields that set their own `OutlineInputBorder()` keep 4px corners.
|
||||
@@ -117,4 +117,40 @@ void main() {
|
||||
await next.restore();
|
||||
expect(next.design, AppDesign.paper);
|
||||
});
|
||||
|
||||
testWidgets('choosing Compact stores it, densifies the page live, draws '
|
||||
'a denser swatch and is restored on the next launch', (tester) async {
|
||||
final store = MemoryAppDesignStore();
|
||||
final designs = AppDesignController(store: store);
|
||||
await _pump(tester, designs);
|
||||
|
||||
final swatch = tester.widget<DesignSwatchPreview>(
|
||||
find.descendant(
|
||||
of: find.byKey(settingsDesignKey(AppDesign.compact)),
|
||||
matching: find.byType(DesignSwatchPreview),
|
||||
),
|
||||
);
|
||||
expect(swatch.lines, greaterThan(2));
|
||||
expect(find.text(AppDesign.compact.description), findsOneWidget);
|
||||
final before = tester.getSize(
|
||||
find.byKey(settingsDesignKey(AppDesign.paper)),
|
||||
);
|
||||
|
||||
await tester.tap(find.text(AppDesign.compact.label));
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.id, 'compact');
|
||||
expect(designs.design, AppDesign.compact);
|
||||
final tokens = _tokens(tester);
|
||||
expect(tokens.density.dense, isTrue);
|
||||
expect(tokens.transcript, TranscriptStyle.bubbles);
|
||||
// The rows themselves tighten at once.
|
||||
final after = tester.getSize(
|
||||
find.byKey(settingsDesignKey(AppDesign.paper)),
|
||||
);
|
||||
expect(after.height, lessThan(before.height));
|
||||
|
||||
final next = AppDesignController(store: MemoryAppDesignStore(store.id));
|
||||
await next.restore();
|
||||
expect(next.design, AppDesign.compact);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -257,6 +257,13 @@ void main() {
|
||||
row['scrollFrameUs'] = watch.elapsedMicroseconds ~/ frames;
|
||||
rebuilds.uninstall();
|
||||
row['scrollRebuildsPerFrame'] = rebuilds.count / frames;
|
||||
// A denser design shows more rows in the same 120px, so it builds
|
||||
// more per frame for the same per-row cost: the budget is per row
|
||||
// scrolled past (rows over the transcript's whole extent).
|
||||
final position = controller.position;
|
||||
final extent = position.maxScrollExtent + position.viewportDimension;
|
||||
final rowsScrolled = frames * 120 * _rows.length / extent;
|
||||
row['scrollRebuildsPerRow'] = rebuilds.count / rowsScrolled;
|
||||
row['scrollLayersPerFrame'] = _sum(layers) / frames;
|
||||
row['scrollSaveLayersPerFrame'] =
|
||||
_sum(layers, (k) => !k.startsWith('clip')) / frames;
|
||||
@@ -277,7 +284,7 @@ void main() {
|
||||
// Counts are deterministic: a design may not exceed Default's by more
|
||||
// than a quarter (its own rows are allowed to differ a little).
|
||||
for (final key in [
|
||||
'scrollRebuildsPerFrame',
|
||||
'scrollRebuildsPerRow',
|
||||
'scrollLayersPerFrame',
|
||||
'scrollSaveLayersPerFrame',
|
||||
'switchFramesPerSwitch',
|
||||
|
||||
@@ -265,6 +265,7 @@ void main() {
|
||||
(AppDesign.standard, false, true),
|
||||
(AppDesign.terminal, true, false),
|
||||
(AppDesign.paper, false, false),
|
||||
(AppDesign.compact, false, true),
|
||||
]) {
|
||||
testWidgets('${design.label}: the open row is clearly marked', (
|
||||
tester,
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design_controller.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
ThemeData _theme(AppDesign design, Brightness brightness, {String? font}) =>
|
||||
brightness == Brightness.dark
|
||||
? design.dark(fontFamily: font)
|
||||
: design.light(fontFamily: font);
|
||||
|
||||
BorderRadius? _radiusOf(ShapeBorder? shape) =>
|
||||
(shape as RoundedRectangleBorder?)?.borderRadius as BorderRadius?;
|
||||
|
||||
void main() {
|
||||
const six = BorderRadius.all(Radius.circular(6));
|
||||
|
||||
test('Compact is listed with a stable id, a label and one line', () {
|
||||
expect(AppDesign.fromId('compact'), AppDesign.compact);
|
||||
expect(AppDesign.compact.label, 'Compact');
|
||||
expect(AppDesign.compact.description, isNot(contains('\n')));
|
||||
expect(AppDesign.compact.usesInterfaceFont, isTrue);
|
||||
expect(AppDesign.compact.swatchLines, greaterThan(2));
|
||||
for (final design in AppDesign.values) {
|
||||
if (design != AppDesign.compact) expect(design.swatchLines, 2);
|
||||
}
|
||||
});
|
||||
|
||||
test('Compact tokens: Default chat and composer, tonal rows, 6px corners, '
|
||||
'the compact density and tighter paragraphs', () {
|
||||
for (final brightness in Brightness.values) {
|
||||
final tokens = _theme(
|
||||
AppDesign.compact,
|
||||
brightness,
|
||||
).extension<AppDesignTokens>()!;
|
||||
expect(tokens.design, AppDesign.compact);
|
||||
expect(tokens.radius, 6);
|
||||
expect(tokens.flat, isFalse);
|
||||
expect(tokens.frame, isNull);
|
||||
expect(tokens.transcript, TranscriptStyle.bubbles);
|
||||
expect(tokens.composer, ComposerStyle.pill);
|
||||
expect(tokens.selectedRow, SelectedRowStyle.tonal);
|
||||
expect(tokens.density, DesignDensity.compact);
|
||||
expect(tokens.density.dense, isTrue);
|
||||
expect(tokens.density.iconSize, 18);
|
||||
expect(tokens.density.railLabels, isFalse);
|
||||
expect(tokens.density.railWidth, lessThan(96));
|
||||
expect(tokens.reading.family, isNull);
|
||||
expect(tokens.reading.paragraphGap, lessThan(0.9));
|
||||
expect(tokens.denseCorners(BorderRadius.circular(12)), six);
|
||||
}
|
||||
});
|
||||
|
||||
test('the comfortable designs keep the comfortable density', () {
|
||||
for (final design in [AppDesign.terminal, AppDesign.paper]) {
|
||||
final tokens = design.light().extension<AppDesignTokens>()!;
|
||||
expect(tokens.density, DesignDensity.comfortable);
|
||||
expect(tokens.reading.paragraphGap, 0.9);
|
||||
final twelve = BorderRadius.circular(12);
|
||||
expect(tokens.denseCorners(twelve), twelve);
|
||||
}
|
||||
expect(AppDesignTokens.standard.density, DesignDensity.comfortable);
|
||||
// Default still builds its exact themes, with no tokens at all.
|
||||
expect(AppDesign.standard.light(), appLightTheme());
|
||||
expect(AppDesign.standard.dark(), appDarkTheme());
|
||||
});
|
||||
|
||||
test('density spacing: unchanged when comfortable, 4px grid when dense', () {
|
||||
const comfortable = DesignDensity.comfortable;
|
||||
for (final value in [2.0, 4.0, 6.0, 10.0, 13.0, 16.0, 24.0]) {
|
||||
expect(comfortable.space(value), value);
|
||||
expect(comfortable.inset(value), value);
|
||||
}
|
||||
expect(comfortable.minTouchRow, 0);
|
||||
const compact = DesignDensity.compact;
|
||||
expect(compact.space(16), 8);
|
||||
expect(compact.space(13), 8);
|
||||
expect(compact.space(12), 8);
|
||||
expect(compact.space(8), 4);
|
||||
expect(compact.space(6), 4);
|
||||
expect(compact.space(4), 2);
|
||||
expect(compact.space(24), 16);
|
||||
expect(compact.inset(16), 12);
|
||||
expect(compact.inset(12), 8);
|
||||
for (final value in [8.0, 12.0, 16.0, 24.0, 32.0]) {
|
||||
expect(compact.space(value) % 4, 0, reason: 'on the 4px grid');
|
||||
expect(compact.space(value), lessThan(value));
|
||||
}
|
||||
});
|
||||
|
||||
test('Compact keeps Default colours and packs type, icons and density', () {
|
||||
for (final brightness in Brightness.values) {
|
||||
final theme = _theme(AppDesign.compact, brightness, font: 'Inter');
|
||||
final standard = _theme(AppDesign.standard, brightness, font: 'Inter');
|
||||
expect(theme.colorScheme, standard.colorScheme);
|
||||
expect(theme.scaffoldBackgroundColor, standard.scaffoldBackgroundColor);
|
||||
final text = theme.textTheme;
|
||||
expect(text.bodyMedium?.fontSize, 13);
|
||||
expect(text.bodyLarge?.fontSize, 14);
|
||||
expect(text.labelMedium?.fontSize, 12);
|
||||
expect(text.labelSmall?.fontSize, 11);
|
||||
expect(text.titleMedium?.fontSize, 14);
|
||||
for (final style in [text.bodyMedium, text.titleLarge, text.labelLarge]) {
|
||||
// The device's interface font still applies.
|
||||
expect(style?.fontFamily, 'Inter');
|
||||
expect(style?.fontSize, lessThan(20));
|
||||
// Line heights on a 2px step.
|
||||
expect((style!.fontSize! * style.height!) % 2, closeTo(0, 0.01));
|
||||
}
|
||||
expect(theme.visualDensity, VisualDensity.compact);
|
||||
expect(theme.iconTheme.size, 18);
|
||||
expect(
|
||||
theme.iconButtonTheme.style?.visualDensity,
|
||||
VisualDensity.compact,
|
||||
reason: 'Material 3 icon buttons ignore the theme density otherwise',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('every floating and framed surface takes the same 6px corners', () {
|
||||
final theme = AppDesign.compact.light();
|
||||
expect(_radiusOf(theme.dialogTheme.shape), six);
|
||||
expect(_radiusOf(theme.popupMenuTheme.shape), six);
|
||||
expect(_radiusOf(theme.snackBarTheme.shape), six);
|
||||
expect(_radiusOf(theme.cardTheme.shape), six);
|
||||
expect(_radiusOf(theme.chipTheme.shape), six);
|
||||
expect(_radiusOf(theme.floatingActionButtonTheme.shape), six);
|
||||
expect(_radiusOf(theme.listTileTheme.shape), six);
|
||||
expect(_radiusOf(theme.navigationRailTheme.indicatorShape), six);
|
||||
expect(_radiusOf(theme.menuTheme.style?.shape?.resolve(const {})), six);
|
||||
expect(
|
||||
_radiusOf(theme.filledButtonTheme.style?.shape?.resolve(const {})),
|
||||
six,
|
||||
);
|
||||
expect(
|
||||
_radiusOf(theme.iconButtonTheme.style?.shape?.resolve(const {})),
|
||||
six,
|
||||
);
|
||||
expect(
|
||||
(theme.tooltipTheme.decoration as BoxDecoration?)?.borderRadius,
|
||||
six,
|
||||
);
|
||||
final sheet = _radiusOf(theme.bottomSheetTheme.shape)!;
|
||||
expect(sheet.topLeft, const Radius.circular(6));
|
||||
expect(sheet.bottomLeft, Radius.zero);
|
||||
// A card keeps its outline under the theme's shape (outlined graph
|
||||
// nodes would otherwise lose it).
|
||||
final card = theme.cardTheme.shape! as RoundedRectangleBorder;
|
||||
expect(card.side.color, theme.colorScheme.outlineVariant);
|
||||
});
|
||||
|
||||
test('pointer devices shrink targets; touch devices keep 40px', () {
|
||||
for (final (platform, pointer) in [
|
||||
(TargetPlatform.linux, true),
|
||||
(TargetPlatform.macOS, true),
|
||||
(TargetPlatform.windows, true),
|
||||
(TargetPlatform.android, false),
|
||||
(TargetPlatform.iOS, false),
|
||||
]) {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
// Built afresh: the cached theme is the device's, built once.
|
||||
final theme = AppDesign.compact.build(Brightness.light);
|
||||
expect(
|
||||
theme.materialTapTargetSize,
|
||||
pointer
|
||||
? MaterialTapTargetSize.shrinkWrap
|
||||
: MaterialTapTargetSize.padded,
|
||||
);
|
||||
expect(DesignDensity.compact.minTouchRow, pointer ? 0 : 40);
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
test(
|
||||
'a switch into or out of Compact snaps; others keep the blend',
|
||||
() async {
|
||||
final designs = AppDesignController(store: MemoryAppDesignStore());
|
||||
expect(AppDesign.compact.dense, isTrue);
|
||||
for (final design in [
|
||||
AppDesign.standard,
|
||||
AppDesign.terminal,
|
||||
AppDesign.paper,
|
||||
]) {
|
||||
expect(design.dense, isFalse);
|
||||
}
|
||||
expect(designs.themeAnimationDuration, kThemeAnimationDuration);
|
||||
await designs.select(AppDesign.terminal);
|
||||
expect(designs.themeAnimationDuration, kThemeAnimationDuration);
|
||||
await designs.select(AppDesign.compact);
|
||||
expect(designs.themeAnimationDuration, Duration.zero);
|
||||
await designs.select(AppDesign.paper);
|
||||
expect(designs.themeAnimationDuration, Duration.zero);
|
||||
await designs.select(AppDesign.standard);
|
||||
expect(designs.themeAnimationDuration, kThemeAnimationDuration);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_bubble.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/navigation_rail.dart';
|
||||
import 'package:pipelines_app/shell/windows/window_frame.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_avatar.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design_tokens.dart';
|
||||
|
||||
/// Compact as drawn: thin rows, a narrow icon-only rail, 32px icon buttons
|
||||
/// (40px targets on touch), tight bubbles, a slim window title bar, and no
|
||||
/// clipping at a large text scale.
|
||||
void main() {
|
||||
tearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
|
||||
Future<void> pump(
|
||||
WidgetTester tester,
|
||||
Widget child, {
|
||||
AppDesign design = AppDesign.compact,
|
||||
double textScale = 1,
|
||||
double width = 560,
|
||||
}) async {
|
||||
tester.view.physicalSize = Size(width, 900);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
// Built afresh, so the platform this test sets is the theme's.
|
||||
theme: design.build(Brightness.light),
|
||||
home: MediaQuery(
|
||||
data: MediaQueryData(
|
||||
size: Size(width, 900),
|
||||
textScaler: TextScaler.linear(textScale),
|
||||
),
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Widget rows() => ListView(
|
||||
children: [
|
||||
AppListRow(
|
||||
key: const Key('one'),
|
||||
title: const Text('Release train'),
|
||||
time: '09:12',
|
||||
onTap: () {},
|
||||
),
|
||||
AppListRow(
|
||||
key: const Key('two'),
|
||||
leading: AppListAvatar.initial('Release', color: Colors.teal),
|
||||
title: const Text('Release notes'),
|
||||
subtitle: const Text('claude-opus · /workspace/demo'),
|
||||
time: '10m',
|
||||
selected: true,
|
||||
onTap: () {},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
testWidgets('pointer: a 36px single-line row and a ~52px two-line row', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
|
||||
await pump(tester, rows());
|
||||
// Each row includes its 1px divider.
|
||||
expect(tester.getSize(find.byKey(const Key('one'))).height, 37);
|
||||
final two = tester.getSize(find.byKey(const Key('two'))).height;
|
||||
expect(two, inInclusiveRange(50, 56));
|
||||
expect(
|
||||
tester.getSize(find.byType(AppListAvatar)).height,
|
||||
DesignDensity.compact.avatarSize,
|
||||
);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('touch: rows keep a 40px target', (tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
await pump(tester, rows());
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('one'))).height,
|
||||
greaterThanOrEqualTo(41),
|
||||
);
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('Default rows keep their comfortable size', (tester) async {
|
||||
await pump(tester, rows(), design: AppDesign.standard);
|
||||
expect(
|
||||
tester.getSize(find.byKey(const Key('one'))).height,
|
||||
greaterThan(48),
|
||||
);
|
||||
expect(
|
||||
tester.getSize(find.byType(AppListAvatar)).height,
|
||||
kAppListAvatarSize,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('rows and bubbles do not clip at 2x text', (tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
|
||||
await pump(
|
||||
tester,
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(height: 300, child: rows()),
|
||||
const ChatUserBubble(child: Text('Summarise the release notes.')),
|
||||
],
|
||||
),
|
||||
textScale: 2,
|
||||
width: 360,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
final one = tester.getSize(find.byKey(const Key('one'))).height;
|
||||
expect(one, greaterThan(37), reason: 'the row grows with its text');
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('icon buttons: 32px on a pointer device, 40px target on touch', (
|
||||
tester,
|
||||
) async {
|
||||
Widget button() => IconButton(
|
||||
key: const Key('b'),
|
||||
onPressed: () {},
|
||||
icon: const Icon(Icons.add),
|
||||
);
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
|
||||
await pump(tester, Center(child: button()));
|
||||
expect(tester.getSize(find.byKey(const Key('b'))), const Size(32, 32));
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.android;
|
||||
await pump(tester, Center(child: button()));
|
||||
expect(tester.getSize(find.byKey(const Key('b'))), const Size(40, 40));
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
|
||||
testWidgets('the rail is narrow and icon-only, each icon with a tooltip', (
|
||||
tester,
|
||||
) async {
|
||||
await pump(
|
||||
tester,
|
||||
Row(
|
||||
children: [
|
||||
ShellNavigationRail(
|
||||
selected: AppDestination.runs,
|
||||
icon: (d) => Icon(destinationDetails(d).icon),
|
||||
onSelected: (_) {},
|
||||
),
|
||||
const Expanded(child: SizedBox()),
|
||||
],
|
||||
),
|
||||
width: 1200,
|
||||
);
|
||||
final rail = find.byKey(const ValueKey('shell.navigation-rail.surface'));
|
||||
expect(tester.getSize(rail).width, DesignDensity.compact.railWidth);
|
||||
expect(
|
||||
tester.widget<NavigationRail>(find.byType(NavigationRail)).labelType,
|
||||
NavigationRailLabelType.none,
|
||||
);
|
||||
for (final destination in shellTabDestinations) {
|
||||
expect(
|
||||
find.byTooltip(destinationDetails(destination).label),
|
||||
findsOneWidget,
|
||||
);
|
||||
}
|
||||
expect(find.byTooltip('Settings'), findsOneWidget);
|
||||
// Settings' indicator matches the tabs' 56x32 rather than the rail.
|
||||
final indicator = find.descendant(
|
||||
of: find.byKey(const ValueKey('shell.destination.settings')),
|
||||
matching: find.byType(Container),
|
||||
);
|
||||
expect(tester.getSize(indicator.first), const Size(56, 32));
|
||||
});
|
||||
|
||||
testWidgets('the operator bubble is tight, in the design corners', (
|
||||
tester,
|
||||
) async {
|
||||
await pump(tester, const ChatUserBubble(child: Text('Ship it')));
|
||||
final material = tester.widget<Material>(
|
||||
find.descendant(
|
||||
of: find.byType(ChatUserBubble),
|
||||
matching: find.byType(Material),
|
||||
),
|
||||
);
|
||||
final shape = material.shape! as RoundedRectangleBorder;
|
||||
expect(shape.borderRadius, BorderRadius.circular(6));
|
||||
final padding = tester.widget<Padding>(
|
||||
find.descendant(
|
||||
of: find.byType(ChatUserBubble),
|
||||
matching: find.byType(Padding),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
padding.padding,
|
||||
const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
);
|
||||
final gap = chatParagraphGap(tester.element(find.text('Ship it')), 14);
|
||||
expect(gap, closeTo(14 * 0.6, 0.01));
|
||||
});
|
||||
|
||||
testWidgets('a floating window has a 32px title bar and 6px corners', (
|
||||
tester,
|
||||
) async {
|
||||
late BuildContext context;
|
||||
await pump(
|
||||
tester,
|
||||
Builder(
|
||||
builder: (c) {
|
||||
context = c;
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
);
|
||||
expect(windowTitleBarHeight(context), 32);
|
||||
expect(windowCorners(context), BorderRadius.circular(6));
|
||||
await pump(
|
||||
tester,
|
||||
Builder(
|
||||
builder: (c) {
|
||||
context = c;
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
design: AppDesign.paper,
|
||||
);
|
||||
expect(windowTitleBarHeight(context), 40);
|
||||
expect(windowCorners(context), BorderRadius.circular(windowCornerRadius));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/chat/domain/chat_transcript.dart';
|
||||
import 'package:pipelines_app/features/chat/ui/transcript/chat_message_view.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_design.dart';
|
||||
|
||||
final _rows = transcriptRows([
|
||||
for (var i = 0; i < 6; i++) ...[
|
||||
{
|
||||
'id': 'u$i',
|
||||
'role': 'user',
|
||||
'parts': [
|
||||
{'type': 'text', 'text': 'Step $i'},
|
||||
],
|
||||
},
|
||||
{
|
||||
'id': 'a$i',
|
||||
'role': 'assistant',
|
||||
'parts': [
|
||||
{
|
||||
'type': 'tool',
|
||||
'id': 't$i',
|
||||
'name': 'Bash',
|
||||
'state': {
|
||||
'status': 'completed',
|
||||
'input': {'command': 'go test'},
|
||||
},
|
||||
},
|
||||
{'type': 'text', 'text': 'Fixed `x`.\n\n- one\n\n```go\nreturn 1\n```'},
|
||||
],
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
/// A live design switch to and from Compact animates the theme without an
|
||||
/// error in any frame. A component theme that set a text-theme style failed
|
||||
/// to lerp against Default's unset one, and in the browser the broken
|
||||
/// frames stopped the app drawing.
|
||||
void main() {
|
||||
testWidgets('switching to and from Compact lerps every frame cleanly', (
|
||||
tester,
|
||||
) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.linux;
|
||||
final design = ValueNotifier(AppDesign.compact);
|
||||
await tester.pumpWidget(
|
||||
ValueListenableBuilder<AppDesign>(
|
||||
valueListenable: design,
|
||||
builder: (_, d, _) => MaterialApp(
|
||||
theme: d.dark(),
|
||||
darkTheme: d.dark(),
|
||||
home: Scaffold(
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: () {},
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('New run'),
|
||||
),
|
||||
body: Row(
|
||||
children: [
|
||||
NavigationRail(
|
||||
destinations: const [
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.add),
|
||||
label: Text('a'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.add),
|
||||
label: Text('b'),
|
||||
),
|
||||
],
|
||||
selectedIndex: 0,
|
||||
),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
IconButton(onPressed: () {}, icon: const Icon(Icons.add)),
|
||||
IconButton.filled(
|
||||
onPressed: () {},
|
||||
icon: const Icon(Icons.add),
|
||||
),
|
||||
Checkbox(value: true, onChanged: (_) {}),
|
||||
Switch(value: true, onChanged: (_) {}),
|
||||
const ListTile(title: Text('t'), subtitle: Text('s')),
|
||||
const TextField(),
|
||||
Chip(label: const Text('c'), onDeleted: () {}),
|
||||
SegmentedButton<int>(
|
||||
segments: const [
|
||||
ButtonSegment(value: 1, label: Text('one')),
|
||||
ButtonSegment(value: 2, label: Text('two')),
|
||||
],
|
||||
selected: const {1},
|
||||
),
|
||||
for (final row in _rows) ChatMessageView(row: row),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
for (var round = 0; round < 3; round++) {
|
||||
for (final other in [
|
||||
AppDesign.standard,
|
||||
AppDesign.terminal,
|
||||
AppDesign.paper,
|
||||
AppDesign.compact,
|
||||
]) {
|
||||
design.value = other;
|
||||
for (var f = 0; f < 20; f++) {
|
||||
await tester.pump(const Duration(milliseconds: 16));
|
||||
final e = tester.takeException();
|
||||
if (e != null) fail('to ${other.id} frame $f: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
}
|
||||
@@ -29,7 +29,7 @@ Per design it checks and prints (`BENCH <design> {...}` in the log):
|
||||
animation (one frame each).
|
||||
- `switchFramesPerSwitch`: frames to settle a live design switch; after the
|
||||
switches, no listener is left on the design controller.
|
||||
- Scrolling a 120-row CLI transcript: `scrollRebuildsPerFrame`,
|
||||
- Scrolling a 120-row CLI transcript: `scrollRebuildsPerRow`,
|
||||
`scrollLayersPerFrame` and `scrollSaveLayersPerFrame` (opacity, backdrop,
|
||||
image/colour filter and shader-mask layers), plus the layer kinds.
|
||||
- `themeBuildUs` (one uncached build) and `scrollFrameUs` are informational
|
||||
@@ -70,7 +70,13 @@ designs with each other, not with a device.
|
||||
|
||||
Click points assume the chat list's row positions at 1280x800 (chats at
|
||||
y=170/260/335); a design that changes list density a lot should check
|
||||
with `tool/capture` that those points still open the chats.
|
||||
with `tool/capture` that those points still open the chats, and give the
|
||||
step its own point keyed by design id (Compact: y=150/210/266).
|
||||
|
||||
The widget test budgets transcript rebuilds per row scrolled past
|
||||
(`scrollRebuildsPerRow`), not per frame: a denser design shows more rows in
|
||||
each 120px step for the same per-row cost. `scrollRebuildsPerFrame` stays
|
||||
informational.
|
||||
|
||||
## Rules the budget enforces
|
||||
|
||||
|
||||
@@ -43,7 +43,13 @@ const SCENARIOS = [
|
||||
{ name: 'scroll', label: 'scroll a 200-message transcript', ...CHAT,
|
||||
act: [{ wheel: [860, 400, -240, 40] }, { wheel: [860, 400, 240, 20] }] },
|
||||
{ name: 'switch', label: 'switch chats', ...CHAT,
|
||||
act: [{ click: [300, 260] }, { click: [300, 335] }, { click: [300, 170] }] },
|
||||
// Chat 2, chat 3, chat 1. Compact's thinner rows sit higher (verified
|
||||
// with tool/capture at 1280x800), so it names its own points.
|
||||
act: [
|
||||
{ click: [300, 260], compact: [300, 210] },
|
||||
{ click: [300, 335], compact: [300, 266] },
|
||||
{ click: [300, 170], compact: [300, 150] },
|
||||
] },
|
||||
{ name: 'runs', label: 'scroll 400 runs', size: '560x900', route: '/runs', q: { runs: '400' },
|
||||
act: [{ wheel: [280, 450, 240, 40] }] },
|
||||
{ name: 'graph', label: 'open and pan the run graph', size: '560x900', route: '/runs/7', q: { graph: '1' },
|
||||
@@ -88,9 +94,11 @@ async function drag([x, y, dx, dy]) {
|
||||
}
|
||||
await send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: x + dx, y: y + dy, button: 'left', clickCount: 1 });
|
||||
}
|
||||
async function run(steps) {
|
||||
// A step's point under [design]: its own (`step[design]`) when the design
|
||||
// moves the target, else the shared one.
|
||||
async function run(steps, design) {
|
||||
for (const step of steps ?? []) {
|
||||
if (step.click) { await tap(step.click); await delay(1000); }
|
||||
if (step.click) { await tap(step[design] ?? step.click); await delay(1000); }
|
||||
if (step.drag) { await drag(step.drag); await delay(400); }
|
||||
if (step.wheel) {
|
||||
const [x, y, deltaY, count] = step.wheel;
|
||||
@@ -146,7 +154,7 @@ async function measure(s, design, others) {
|
||||
out.switches = Number(opts.switches) * others.length * 2;
|
||||
out.heapGrowthMB = (await heapMB()) - before;
|
||||
} else {
|
||||
await run(s.act);
|
||||
await run(s.act, design);
|
||||
await settle();
|
||||
}
|
||||
fetchesBy[design] ??= new Set();
|
||||
|
||||
Reference in New Issue
Block a user