WIP compact
This commit is contained in:
@@ -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,7 @@ 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).
|
||||
|
||||
@@ -1329,7 +1329,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 in a 40px pill, as tall
|
||||
// as its 32px controls (its compact density takes 4px off each of
|
||||
// these 10).
|
||||
contentPadding: EdgeInsets.symmetric(
|
||||
vertical: AppDesignTokens.of(context).density.dense ? 10 : 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,7 @@ 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,7 @@ 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,7 @@ 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 {
|
||||
@@ -147,7 +148,7 @@ 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,
|
||||
|
||||
@@ -18,6 +18,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.
|
||||
@@ -90,7 +91,7 @@ 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,7 @@ 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,7 @@ 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,7 @@ 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,11 @@ 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)
|
||||
|
||||
@@ -347,7 +347,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,12 +101,19 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _rail(int index, Color surface, {required bool pinSettings}) =>
|
||||
NavigationRail(
|
||||
Widget _rail(
|
||||
int index,
|
||||
Color surface,
|
||||
DesignDensity density, {
|
||||
required bool pinSettings,
|
||||
}) => NavigationRail(
|
||||
key: const ValueKey('shell.navigation-rail'),
|
||||
backgroundColor: surface,
|
||||
minWidth: kNavigationRailWidth,
|
||||
labelType: NavigationRailLabelType.all,
|
||||
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]),
|
||||
@@ -119,6 +137,7 @@ class ShellNavigationRail extends StatelessWidget {
|
||||
scrollable: true,
|
||||
trailingAtBottom: pinSettings,
|
||||
trailing: _SettingsRailItem(
|
||||
density: density,
|
||||
selected: selected == AppDestination.settings,
|
||||
onTap: () => onSelected(AppDestination.settings),
|
||||
),
|
||||
@@ -130,8 +149,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 +170,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 +206,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,
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'window_frame.dart'
|
||||
show
|
||||
WindowOutline,
|
||||
WindowResizeGrip,
|
||||
windowCornerRadius,
|
||||
windowCorners,
|
||||
windowTitleBarHeight;
|
||||
import 'window_scope.dart';
|
||||
|
||||
@@ -122,15 +122,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,7 @@ 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';
|
||||
|
||||
@@ -40,6 +41,14 @@ enum AppDesign {
|
||||
'paper',
|
||||
'Paper',
|
||||
'Warm paper, serif reading text and ink colours; calm for long reads.',
|
||||
),
|
||||
|
||||
/// The Default look packed tight for a big monitor: smaller type, thin
|
||||
/// rows, 18px icons, an icon-only rail and modest corners.
|
||||
compact(
|
||||
'compact',
|
||||
'Compact',
|
||||
'Default’s Material look, dense: small type, thin rows, more on screen.',
|
||||
);
|
||||
|
||||
const AppDesign(this.id, this.label, this.description);
|
||||
@@ -67,6 +76,7 @@ enum AppDesign {
|
||||
standard => appLightTheme(fontFamily: fontFamily),
|
||||
terminal => terminalTheme(Brightness.light),
|
||||
paper => paperTheme(Brightness.light, fontFamily: fontFamily),
|
||||
compact => compactTheme(Brightness.light, fontFamily: fontFamily),
|
||||
};
|
||||
|
||||
/// The design's dark theme; see [light].
|
||||
@@ -74,6 +84,7 @@ enum AppDesign {
|
||||
standard => appDarkTheme(fontFamily: fontFamily),
|
||||
terminal => terminalTheme(Brightness.dark),
|
||||
paper => paperTheme(Brightness.dark, fontFamily: fontFamily),
|
||||
compact => compactTheme(Brightness.dark, fontFamily: fontFamily),
|
||||
};
|
||||
|
||||
/// Whether the device's interface font applies under this design (Paper
|
||||
@@ -85,7 +96,7 @@ enum AppDesign {
|
||||
DesignSwatch swatch(Brightness brightness) {
|
||||
final dark = brightness == Brightness.dark;
|
||||
return switch (this) {
|
||||
standard =>
|
||||
standard || compact =>
|
||||
dark
|
||||
? const DesignSwatch(
|
||||
Color(0xFF141416),
|
||||
@@ -123,6 +134,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,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;
|
||||
|
||||
@@ -52,6 +52,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
this.selectedRow = SelectedRowStyle.tonal,
|
||||
this.reading = const ReadingType(),
|
||||
this.chatColorSaturation = 1,
|
||||
this.density = DesignDensity.comfortable,
|
||||
});
|
||||
|
||||
/// The Default design: every widget keeps its own shapes.
|
||||
@@ -98,6 +99,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;
|
||||
|
||||
@@ -119,6 +124,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;
|
||||
@@ -143,6 +154,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
SelectedRowStyle? selectedRow,
|
||||
ReadingType? reading,
|
||||
double? chatColorSaturation,
|
||||
DesignDensity? density,
|
||||
}) => AppDesignTokens(
|
||||
design: design ?? this.design,
|
||||
radius: radius ?? this.radius,
|
||||
@@ -156,6 +168,7 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
selectedRow: selectedRow ?? this.selectedRow,
|
||||
reading: reading ?? this.reading,
|
||||
chatColorSaturation: chatColorSaturation ?? this.chatColorSaturation,
|
||||
density: density ?? this.density,
|
||||
);
|
||||
|
||||
/// Designs switch whole: a theme animation snaps halfway rather than
|
||||
|
||||
@@ -0,0 +1,220 @@
|
||||
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. 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;
|
||||
final text = base.textTheme;
|
||||
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,
|
||||
textStyle: WidgetStatePropertyAll(text.labelLarge),
|
||||
),
|
||||
),
|
||||
// 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,
|
||||
extendedTextStyle: text.labelLarge,
|
||||
),
|
||||
menuTheme: MenuThemeData(style: menu),
|
||||
dropdownMenuTheme: DropdownMenuThemeData(
|
||||
menuStyle: menu,
|
||||
textStyle: text.bodyMedium,
|
||||
inputDecorationTheme: const InputDecorationTheme(isDense: true),
|
||||
),
|
||||
menuButtonTheme: MenuButtonThemeData(
|
||||
style: MenuItemButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
minimumSize: const Size(0, 32),
|
||||
textStyle: text.bodyMedium,
|
||||
iconSize: icon,
|
||||
),
|
||||
),
|
||||
popupMenuTheme: PopupMenuThemeData(
|
||||
shape: _rounded,
|
||||
menuPadding: const EdgeInsets.symmetric(vertical: 4),
|
||||
labelTextStyle: WidgetStatePropertyAll(text.bodyMedium),
|
||||
textStyle: text.bodyMedium,
|
||||
),
|
||||
dialogTheme: DialogThemeData(
|
||||
shape: _rounded,
|
||||
titleTextStyle: text.titleLarge?.copyWith(color: scheme.onSurface),
|
||||
contentTextStyle: text.bodyMedium?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
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,
|
||||
contentTextStyle: text.bodyMedium?.copyWith(
|
||||
color: scheme.onInverseSurface,
|
||||
),
|
||||
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),
|
||||
textStyle: text.bodySmall?.copyWith(color: scheme.onInverseSurface),
|
||||
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),
|
||||
labelStyle: text.labelLarge,
|
||||
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),
|
||||
),
|
||||
textStyle: WidgetStatePropertyAll(text.bodyMedium),
|
||||
hintStyle: WidgetStatePropertyAll(
|
||||
text.bodyMedium?.copyWith(color: scheme.onSurfaceVariant),
|
||||
),
|
||||
),
|
||||
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,
|
||||
labelTextStyle: WidgetStatePropertyAll(text.labelMedium),
|
||||
iconTheme: const WidgetStatePropertyAll(IconThemeData(size: icon)),
|
||||
),
|
||||
tabBarTheme: TabBarThemeData(
|
||||
labelStyle: text.labelLarge,
|
||||
unselectedLabelStyle: text.labelLarge,
|
||||
labelPadding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
),
|
||||
dividerTheme: const DividerThemeData(space: 8, thickness: 1),
|
||||
badgeTheme: BadgeThemeData(
|
||||
smallSize: 6,
|
||||
largeSize: 14,
|
||||
textStyle: text.labelSmall?.copyWith(fontSize: 10),
|
||||
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,
|
||||
);
|
||||
}
|
||||
@@ -114,4 +114,36 @@ 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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,174 @@
|
||||
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_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;
|
||||
final theme = AppDesign.compact.light();
|
||||
expect(
|
||||
theme.materialTapTargetSize,
|
||||
pointer ? MaterialTapTargetSize.shrinkWrap : MaterialTapTargetSize.padded,
|
||||
);
|
||||
expect(DesignDensity.compact.minTouchRow, pointer ? 0 : 40);
|
||||
}
|
||||
debugDefaultTargetPlatformOverride = null;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
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';
|
||||
|
||||
/// 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() {
|
||||
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(
|
||||
theme: design.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));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user