Merge commit '84684463204d32bc51ea50ddb5789b0cc17b280a' into pipelines/run-20261111-0240-perf-whole-pixel-window-frames-stop-per-89f6

This commit is contained in:
2026-11-11 03:37:34 +00:00
62 changed files with 1394 additions and 3044 deletions
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import 'graph_viewport.dart';
import 'graph_viewport_controller.dart';
@@ -100,23 +98,6 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
Expanded(child: viewport),
],
);
if (usesCupertinoHost(context)) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
automaticallyImplyLeading: false,
leading: SegmentedBackButton(cupertino: true, onPressed: _close),
title: widget.title,
actions: [
_GraphFitButton(
cupertino: true,
onPressed: _controller.fitToViewport,
),
],
),
child: BelowTopBar(child: body),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
@@ -124,12 +105,7 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
title: widget.title,
automaticallyImplyLeading: false,
leading: SegmentedBackButton(cupertino: false, onPressed: _close),
actions: [
_GraphFitButton(
cupertino: false,
onPressed: _controller.fitToViewport,
),
],
actions: [_GraphFitButton(onPressed: _controller.fitToViewport)],
),
body: BelowTopBar(child: body),
);
@@ -137,9 +113,8 @@ class _GraphExpandedViewState extends State<GraphExpandedView> {
}
class _GraphFitButton extends StatelessWidget {
const _GraphFitButton({required this.cupertino, required this.onPressed});
const _GraphFitButton({required this.onPressed});
final bool cupertino;
final VoidCallback onPressed;
@override
@@ -147,22 +122,15 @@ class _GraphFitButton extends StatelessWidget {
child: Semantics(
button: true,
label: graphFitLabel,
child: cupertino
? CupertinoButton(
key: const Key('graph-fit'),
padding: const EdgeInsets.all(8),
onPressed: onPressed,
child: const ExcludeSemantics(child: Icon(CupertinoIcons.resize)),
)
: Tooltip(
message: graphFitLabel,
excludeFromSemantics: true,
child: IconButton(
key: const Key('graph-fit'),
onPressed: onPressed,
icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)),
),
),
child: Tooltip(
message: graphFitLabel,
excludeFromSemantics: true,
child: IconButton(
key: const Key('graph-fit'),
onPressed: onPressed,
icon: const ExcludeSemantics(child: Icon(Icons.fit_screen)),
),
),
),
);
}
@@ -190,8 +158,9 @@ Future<void> openGraphExpanded(
selectedStage: selectedStage,
header: header,
);
final route = usesCupertinoHost(context)
? CupertinoPageRoute<void>(fullscreenDialog: true, builder: (_) => page)
: MaterialPageRoute<void>(fullscreenDialog: true, builder: (_) => page);
final route = MaterialPageRoute<void>(
fullscreenDialog: true,
builder: (_) => page,
);
return Navigator.of(context).push(route);
}
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/adaptive/glass_pill.dart';
import 'graph_viewport_controller.dart';
@@ -121,20 +119,20 @@ class _GraphViewportState extends State<GraphViewport> {
top: 8,
end: 8,
child: GlassPill(
cupertino: usesCupertinoHost(context),
cupertino: false,
child: Wrap(
spacing: 2,
children: [
_ViewportButton(
buttonKey: const Key('graph-fit'),
icon: _fitIcon(context),
icon: Icons.fit_screen,
label: graphFitLabel,
onPressed: widget.controller.fitToViewport,
),
if (widget.onExpand != null)
_ViewportButton(
buttonKey: const Key('graph-expand'),
icon: _expandIcon(context),
icon: Icons.fullscreen,
label: graphExpandLabel,
onPressed: widget.onExpand,
),
@@ -147,12 +145,6 @@ class _GraphViewportState extends State<GraphViewport> {
},
);
}
IconData _fitIcon(BuildContext context) =>
usesCupertinoHost(context) ? CupertinoIcons.resize : Icons.fit_screen;
IconData _expandIcon(BuildContext context) =>
usesCupertinoHost(context) ? CupertinoIcons.fullscreen : Icons.fullscreen;
}
/// One native graph control inside the shared floating glass pill.
@@ -160,7 +152,7 @@ class _GraphViewportState extends State<GraphViewport> {
/// The label and the button's own tap action must reach the same semantics
/// node: the icon is the only excluded child, and [MergeSemantics] folds the
/// host button's action into the labelled node, so a screen reader can activate
/// Fit and Expand on either host. A hand-written `Semantics` sibling around an
/// Fit and Expand. A hand-written `Semantics` sibling around an
/// excluded button would announce the control with no action at all.
class _ViewportButton extends StatelessWidget {
const _ViewportButton({
@@ -181,24 +173,17 @@ class _ViewportButton extends StatelessWidget {
child: Semantics(
button: true,
label: label,
child: usesCupertinoHost(context)
? CupertinoButton(
key: buttonKey,
padding: const EdgeInsets.all(8),
onPressed: onPressed,
child: ExcludeSemantics(child: Icon(icon)),
)
: Tooltip(
message: label,
// The merged node already carries the label; the tooltip is
// only the pointer affordance.
excludeFromSemantics: true,
child: IconButton(
key: buttonKey,
onPressed: onPressed,
icon: ExcludeSemantics(child: Icon(icon)),
),
),
child: Tooltip(
message: label,
// The merged node already carries the label; the tooltip is
// only the pointer affordance.
excludeFromSemantics: true,
child: IconButton(
key: buttonKey,
onPressed: onPressed,
icon: ExcludeSemantics(child: Icon(icon)),
),
),
),
);
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../layout/layout_models.dart';
import '../routing/route_models.dart';
@@ -32,9 +30,9 @@ RoutingConfig graphCanvasRoutingConfig() => RoutingConfig(
/// The native theme roles one definition graph canvas needs.
///
/// No palette, font family or size is defined here: every value comes from the
/// ambient Material or Cupertino theme, so light/dark and text scaling follow
/// the host exactly. Edge labels and diagnostics are metadata, so they use the
/// host's secondary-label role rather than the node's own label style.
/// ambient Material theme, so light/dark and text scaling follow the host
/// exactly. Edge labels and diagnostics are metadata, so they use the host's
/// secondary-label role rather than the node's own label style.
class GraphCanvasStyle {
const GraphCanvasStyle({
required this.labelStyle,
@@ -44,20 +42,6 @@ class GraphCanvasStyle {
});
factory GraphCanvasStyle.of(BuildContext context) {
if (usesCupertinoHost(context)) {
final theme = CupertinoTheme.of(context);
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
return GraphCanvasStyle(
labelStyle: theme.textTheme.tabLabelTextStyle.copyWith(
color: secondary,
),
messageStyle: theme.textTheme.textStyle.copyWith(color: secondary),
edgeColor: CupertinoColors.separator.resolveFrom(context),
// Cupertino has no divider-thickness token; its separators are one
// logical pixel hairlines, so the stroke keeps that native default.
edgeWidth: 1,
);
}
final theme = Theme.of(context);
final secondary = theme.colorScheme.onSurfaceVariant;
return GraphCanvasStyle(
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/status/run_status_icon.dart';
import '../domain/graph_definition.dart';
@@ -37,7 +35,7 @@ class GraphStageNode extends StatelessWidget {
/// Reports [node.key] exactly as the definition recorded it.
final ValueChanged<String> onSelected;
/// Content inset shared by both hosts. It is spacing, not a size: the control
/// Content inset for a graph node. It is spacing, not a size: the control
/// still takes its size from its label, and the inset keeps wrapped glyphs
/// clear of a rounded surface's corners.
static const EdgeInsets _contentPadding = EdgeInsets.all(16);
@@ -61,9 +59,7 @@ class GraphStageNode extends StatelessWidget {
button: true,
selected: selected,
label: _label,
child: usesCupertinoHost(context)
? _cupertinoButton(onPressed, content)
: _materialCard(onPressed, content),
child: _materialCard(onPressed, content),
),
);
return active ? StageActivityHalo(child: control) : control;
@@ -106,12 +102,6 @@ class GraphStageNode extends StatelessWidget {
);
}
/// Tinted is Cupertino's stock low-emphasis surface, so an unselected node is
/// still a visible node body; filled raises the selected one.
Widget _cupertinoButton(VoidCallback onPressed, Widget content) => selected
? CupertinoButton.filled(onPressed: onPressed, child: content)
: CupertinoButton.tinted(onPressed: onPressed, child: content);
Widget _content(BuildContext context) {
final status = _status;
// The recorded status reads apart from the name: a coloured dot and
@@ -215,10 +205,7 @@ class _StageActivityHaloState extends State<StageActivityHalo>
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final color = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final color = Theme.of(context).colorScheme.primary;
return AnimatedBuilder(
animation: _controller,
builder: (context, child) => CustomPaint(
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show listEquals;
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/graph_definition.dart';
import '../domain/run_graph_state.dart';
import '../layout/layout_models.dart';
@@ -200,10 +198,7 @@ class RunGraphCanvas extends StatelessWidget {
final executedIds = {for (final route in executed) route.id};
final size = Size(routing.width, routing.height);
final activeStage = state.activeStage;
final cupertino = usesCupertinoHost(context);
final executedColor = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final executedColor = Theme.of(context).colorScheme.primary;
return Stack(
clipBehavior: Clip.none,
children: [
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/run_graph_state.dart';
import 'graph_canvas_style.dart';
@@ -31,10 +29,7 @@ class RunGraphHeader extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final executedColor = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final executedColor = Theme.of(context).colorScheme.primary;
final mutedColor = style.edgeColor;
final active = state.activeStage;
return Padding(
@@ -53,14 +48,12 @@ class RunGraphHeader extends StatelessWidget {
crossAxisAlignment: WrapCrossAlignment.center,
children: [
_LegendEntry(
icon: cupertino
? CupertinoIcons.arrow_right
: Icons.arrow_forward,
icon: Icons.arrow_forward,
label: runGraphExecuted,
color: executedColor,
),
_LegendEntry(
icon: cupertino ? CupertinoIcons.minus : Icons.remove,
icon: Icons.remove,
label: runGraphNotExecuted,
color: mutedColor,
),
@@ -1,14 +1,12 @@
import '../../../ui/adaptive/segmented_bar.dart';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/text/markdown_source_view.dart';
import '../../chat/ui/transcript/chat_markdown_view.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/graph_protocol.dart';
import '../domain/stage_definition.dart';
@@ -159,30 +157,14 @@ Future<void> openStageDefinition(
// A terminal is a definition target, not its protocol key: the web pane
// titles it with `nodeDisplayLabel` (`Failure`/`Success`).
final title = '${nodeDisplayLabel(stageKey)} definition';
final route = usesCupertinoHost(context)
? CupertinoPageRoute<void>(
settings: settings,
builder: (_) => CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
title: title,
subtitle: identity,
),
child: SafeArea(top: false, bottom: false, child: view),
),
)
: MaterialPageRoute<void>(
settings: settings,
builder: (_) => Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
cupertino: false,
title: title,
subtitle: identity,
),
body: SafeArea(top: false, bottom: false, child: view),
),
);
final route = MaterialPageRoute<void>(
settings: settings,
builder: (_) => Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(cupertino: false, title: title, subtitle: identity),
body: SafeArea(top: false, bottom: false, child: view),
),
);
return Navigator.of(context).push(route);
}
@@ -263,22 +245,6 @@ class _StageDefinitionStyle {
});
factory _StageDefinitionStyle.of(BuildContext context) {
if (usesCupertinoHost(context)) {
final theme = CupertinoTheme.of(context);
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
return _StageDefinitionStyle(
label: theme.textTheme.tabLabelTextStyle.copyWith(color: secondary),
// SelectableText needs a style it can merge into the default text
// style; Cupertino's textStyle is a complete style with `inherit: false`
// and no baseline.
value: theme.textTheme.textStyle.copyWith(inherit: true),
muted: theme.textTheme.textStyle.copyWith(
inherit: true,
color: secondary,
),
heading: theme.textTheme.navTitleTextStyle,
);
}
final theme = Theme.of(context);
return _StageDefinitionStyle(
label: (theme.textTheme.labelMedium ?? const TextStyle()).copyWith(
+1 -2
View File
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
import '../../shell/shell_bar.dart';
import '../../ui/adaptive/host.dart';
import '../../ui/adaptive/top_bar_notices.dart';
import 'data/template_repository.dart';
import 'domain/template_entry.dart';
@@ -170,7 +169,7 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
context: context,
template: template,
repository: _repository,
cupertino: usesCupertinoHost(context),
cupertino: false,
onCreated: (detail) => widget.onCreated?.call(detail),
),
);
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'template_create_wording.dart';
@@ -13,6 +12,8 @@ class TemplateCreateNameField extends StatelessWidget {
required this.onSubmit,
});
/// Retained for callers that still pass it; the field is always the
/// Material one whether this is set or not.
final bool cupertino;
final TextEditingController controller;
final bool enabled;
@@ -26,24 +27,14 @@ class TemplateCreateNameField extends StatelessWidget {
children: [
const Text(templateCreateNameLabel),
const SizedBox(height: 8),
if (cupertino)
CupertinoTextField(
key: templateCreateNameKey,
controller: controller,
enabled: enabled,
autofocus: true,
textInputAction: TextInputAction.done,
onSubmitted: (_) => onSubmit(),
)
else
TextField(
key: templateCreateNameKey,
controller: controller,
enabled: enabled,
autofocus: true,
textInputAction: TextInputAction.done,
onSubmitted: (_) => onSubmit(),
),
TextField(
key: templateCreateNameKey,
controller: controller,
enabled: enabled,
autofocus: true,
textInputAction: TextInputAction.done,
onSubmitted: (_) => onSubmit(),
),
],
),
);
@@ -56,14 +47,6 @@ Widget templateCreateDialogAction({
required Widget child,
bool primary = false,
}) {
if (cupertino) {
return CupertinoDialogAction(
key: key,
isDefaultAction: primary,
onPressed: onPressed,
child: child,
);
}
if (primary) {
return FilledButton(key: key, onPressed: onPressed, child: child);
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
@@ -12,6 +11,9 @@ import 'template_create_controls.dart';
/// Cancel send nothing; Create validates the source first and only a passing
/// validate submits it create-only. A refusal keeps the typed name; an accepted
/// `detail` is delivered through [onCreated] once.
///
/// [cupertino] is retained for callers that still pass it; the prompt is
/// always the Material dialog.
Future<void> showTemplateCreateDialog({
required BuildContext context,
required TemplateEntry template,
@@ -22,33 +24,24 @@ Future<void> showTemplateCreateDialog({
final dialog = _TemplateCreateDialog(
template: template,
repository: repository,
cupertino: cupertino,
onCreated: onCreated,
);
return cupertino
? showCupertinoDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => dialog,
)
: showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => dialog,
);
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => dialog,
);
}
class _TemplateCreateDialog extends StatefulWidget {
const _TemplateCreateDialog({
required this.template,
required this.repository,
required this.cupertino,
required this.onCreated,
});
final TemplateEntry template;
final TemplateRepository repository;
final bool cupertino;
final ValueChanged<JsonMap> onCreated;
@override
@@ -150,15 +143,13 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
@override
Widget build(BuildContext context) {
final color = widget.cupertino
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error;
final color = Theme.of(context).colorScheme.error;
final content = Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TemplateCreateNameField(
cupertino: widget.cupertino,
cupertino: false,
controller: _name,
enabled: _fieldEnabled,
onSubmit: _create,
@@ -196,7 +187,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
);
final actions = [
templateCreateDialogAction(
cupertino: widget.cupertino,
cupertino: false,
key: templateCreateCancelKey,
onPressed: _sending ? null : _cancel,
child: Text(
@@ -206,7 +197,7 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
),
),
templateCreateDialogAction(
cupertino: widget.cupertino,
cupertino: false,
key: templateCreateConfirmKey,
primary: true,
onPressed: _canSubmit ? _create : null,
@@ -216,20 +207,10 @@ class _TemplateCreateDialogState extends State<_TemplateCreateDialog> {
),
];
final title = Text(templateCreateTitle(widget.template));
if (!widget.cupertino) {
return PopScope(
canPop: !_sending,
child: AlertDialog(
scrollable: true,
title: title,
content: content,
actions: actions,
),
);
}
return PopScope(
canPop: !_sending,
child: CupertinoAlertDialog(
child: AlertDialog(
scrollable: true,
title: title,
content: content,
actions: actions,
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../domain/template_entry.dart';
import 'template_gallery.dart' show templatesColumn;
@@ -63,14 +61,13 @@ class TemplateDetail extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final muted = templateMutedStyle(context);
final description = entry.description.trim();
return ListView(
key: templateDetailKey,
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
children: [
if (showBack) _backRow(context, cupertino),
if (showBack) _backRow(context),
templatesColumn(
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
@@ -91,7 +88,7 @@ class TemplateDetail extends StatelessWidget {
),
const SizedBox(height: 12),
],
_createButton(cupertino),
_createButton(),
const SizedBox(height: 16),
// The key and the schedule on one quiet line, not a
// label/value document.
@@ -136,15 +133,7 @@ class TemplateDetail extends StatelessWidget {
/// A compact button at its own width: the page's one action, never a bar
/// spanning a wide window.
Widget _createButton(bool cupertino) {
if (cupertino) {
return CupertinoButton.filled(
key: templateCreateActionKey,
sizeStyle: CupertinoButtonSize.medium,
onPressed: onCreate,
child: const Text(templateCreateActionLabel),
);
}
Widget _createButton() {
return FilledButton.icon(
key: templateCreateActionKey,
onPressed: onCreate,
@@ -153,13 +142,13 @@ class TemplateDetail extends StatelessWidget {
);
}
Widget _backRow(BuildContext context, bool cupertino) {
Widget _backRow(BuildContext context) {
// Only without a bar above: the same round Back the bar would show.
final back = SegmentedPill(
cupertino: cupertino,
cupertino: false,
child: SegmentedBackButton(
key: templateDetailBackKey,
cupertino: cupertino,
cupertino: false,
onPressed: onBack,
),
);
@@ -179,35 +168,15 @@ class TemplateDetail extends StatelessWidget {
}
TextStyle? templateTitleStyle(BuildContext context) =>
usesCupertinoHost(context)
? CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle
: Theme.of(context).textTheme.headlineSmall;
Theme.of(context).textTheme.headlineSmall;
TextStyle? templateSectionStyle(BuildContext context) =>
usesCupertinoHost(context)
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleMedium;
Theme.of(context).textTheme.titleMedium;
TextStyle? templateBodyStyle(BuildContext context) {
if (usesCupertinoHost(context)) {
// SelectableText needs an explicit baseline when it inherits no style.
return CupertinoTheme.of(
context,
).textTheme.textStyle.copyWith(inherit: true);
}
return Theme.of(context).textTheme.bodyMedium;
}
TextStyle? templateBodyStyle(BuildContext context) =>
Theme.of(context).textTheme.bodyMedium;
TextStyle? templateMutedStyle(BuildContext context) {
if (usesCupertinoHost(context)) {
// The list rows' secondary size, not the tab bar's 10pt caption.
// SelectableText needs an explicit baseline when it inherits no style.
return CupertinoTheme.of(context).textTheme.textStyle.copyWith(
inherit: true,
fontSize: 15,
color: CupertinoColors.secondaryLabel.resolveFrom(context),
);
}
final theme = Theme.of(context);
return theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/layout/app_list_avatar.dart';
import '../../../ui/layout/app_list_row.dart';
import '../domain/template_entry.dart';
@@ -70,13 +68,13 @@ class TemplateGallery extends StatelessWidget {
onRetry: onRetry,
);
}
return _loadingState(context);
return _loadingState();
}
if (templates.isEmpty) return _emptyState(context);
return _list(context);
}
Widget _loadingState(BuildContext context) {
Widget _loadingState() {
return Center(
key: templatesLoadingKey,
child: Semantics(
@@ -85,9 +83,7 @@ class TemplateGallery extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
usesCupertinoHost(context)
? const CupertinoActivityIndicator()
: const CircularProgressIndicator(),
const CircularProgressIndicator(),
const SizedBox(height: 12),
const Text(_loadingMessage),
],
@@ -107,7 +103,6 @@ class TemplateGallery extends StatelessWidget {
}
Widget _list(BuildContext context) {
final cupertino = usesCupertinoHost(context);
// The rows scroll behind the bar and the floating tab bar.
return ListView.builder(
key: templatesGalleryKey,
@@ -118,14 +113,14 @@ class TemplateGallery extends StatelessWidget {
return templatesColumn(
AppListRow(
key: templateRowKey(entry.key),
cupertino: cupertino,
cupertino: false,
divider: index < templates.length - 1,
onTap: () => onOpen(entry.key),
leading: ExcludeSemantics(
child: AppListAvatar.initial(
templateDetailName(entry),
key: templateAvatarKey(entry.key),
color: _avatarColor(context, entry.key, cupertino),
color: _avatarColor(context, entry.key),
),
),
title: Text(templateGalleryName(entry)),
@@ -138,18 +133,9 @@ class TemplateGallery extends StatelessWidget {
/// One of the theme's accents, picked by the template key so a row keeps
/// its colour across reloads (the Pipelines list's palette).
Color _avatarColor(BuildContext context, String key, bool cupertino) {
final List<Color> colors;
if (cupertino) {
colors = [
CupertinoTheme.of(context).primaryColor,
CupertinoColors.systemIndigo.resolveFrom(context),
CupertinoColors.systemTeal.resolveFrom(context),
];
} else {
final scheme = Theme.of(context).colorScheme;
colors = [scheme.primary, scheme.secondary, scheme.tertiary];
}
Color _avatarColor(BuildContext context, String key) {
final scheme = Theme.of(context).colorScheme;
final colors = [scheme.primary, scheme.secondary, scheme.tertiary];
final hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
return colors[hash % colors.length];
}
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
const templatesErrorKey = ValueKey<String>('templates-error');
const templatesRetryKey = ValueKey<String>('templates-retry');
const templatesErrorBannerKey = ValueKey<String>('templates-error-banner');
@@ -36,7 +33,6 @@ class TemplatesFailureState extends StatelessWidget {
),
const SizedBox(height: 8),
_retryButton(
context,
buttonKey: templatesRetryKey,
retrying: retrying,
onRetry: onRetry,
@@ -76,15 +72,10 @@ class TemplatesFailureBanner extends StatelessWidget {
liveRegion: true,
child: Text(
message,
style: TextStyle(
color: usesCupertinoHost(context)
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error,
),
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
),
_retryButton(
context,
buttonKey: templatesBannerRetryKey,
retrying: retrying,
onRetry: onRetry,
@@ -95,21 +86,12 @@ class TemplatesFailureBanner extends StatelessWidget {
}
}
Widget _retryButton(
BuildContext context, {
Widget _retryButton({
required Key buttonKey,
required bool retrying,
required VoidCallback onRetry,
}) {
final onPressed = retrying ? null : onRetry;
if (usesCupertinoHost(context)) {
return CupertinoButton(
key: buttonKey,
padding: EdgeInsets.zero,
onPressed: onPressed,
child: const Text('Retry'),
);
}
return TextButton(
key: buttonKey,
onPressed: onPressed,
@@ -2,10 +2,8 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../shell/shell_bar.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/navigation/bar_icon_button.dart';
import '../../../ui/theme/app_theme.dart';
const templatesRefreshKey = ValueKey<String>('templates-refresh');
const templatesBackKey = ValueKey<String>('templates-back');
@@ -44,7 +42,6 @@ class TemplatesFrame extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
if (embedded) {
if (ShellBar.available(context)) {
return ShellBar(
@@ -70,11 +67,11 @@ class TemplatesFrame extends StatelessWidget {
);
}
final bar = SegmentedBar(
cupertino: cupertino,
cupertino: false,
leading: canGoBack
? SegmentedBackButton(
key: templatesBackKey,
cupertino: cupertino,
cupertino: false,
onPressed: onBack,
)
: null,
@@ -84,19 +81,12 @@ class TemplatesFrame extends StatelessWidget {
);
// The body reaches the top edge and scrolls behind the bar.
final page = SafeArea(top: false, bottom: false, child: body);
if (cupertino) {
return CupertinoPageScaffold(
// Plain list rows on the page background, like the other lists.
backgroundColor: AppColors.background,
navigationBar: bar,
child: page,
);
}
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: page);
}
Widget _refreshButton() => BarIconButton(
key: templatesRefreshKey,
cupertino: false,
icon: Icons.refresh,
cupertinoIcon: CupertinoIcons.refresh,
label: 'Refresh',
+5 -37
View File
@@ -1,17 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import 'cupertino_web_search_field.dart';
/// The app's one search field per platform.
/// The app's one search field.
///
/// Cupertino uses the stock [CupertinoSearchTextField]. Material uses a
/// [TextField] shaped like it: a stadium with a leading search icon, a clear
/// button once there is text, no underline and no elevation. On a page it is
/// filled with the host's raised surface; [inBar] drops the fill (and the
/// Cupertino grey) because a bar's glass pill is already its background.
/// A [TextField] shaped like the stock iOS field: a stadium with a leading
/// search icon, a clear button once there is text, no underline and no
/// elevation. On a page it is filled with the host's raised surface; [inBar]
/// drops the fill because a bar's glass pill is already its background.
class AppSearchField extends StatelessWidget {
const AppSearchField({
super.key,
@@ -58,32 +52,6 @@ class AppSearchField extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (cupertino ?? usesCupertinoHost(context)) {
if (kIsWeb) {
return CupertinoWebSearchField(
controller: controller,
placeholder: placeholder,
fieldKey: fieldKey,
focusNode: focusNode,
autofocus: autofocus,
inBar: inBar,
onChanged: onChanged,
onSubmitted: onSubmitted,
onCleared: _clear,
);
}
return CupertinoSearchTextField(
key: fieldKey,
controller: controller,
focusNode: focusNode,
autofocus: autofocus,
placeholder: placeholder,
backgroundColor: inBar ? const Color(0x00000000) : null,
onChanged: onChanged,
onSubmitted: onSubmitted,
onSuffixTap: _clear,
);
}
final scheme = Theme.of(context).colorScheme;
const radius = BorderRadius.all(Radius.circular(28));
const stadium = OutlineInputBorder(
@@ -1,115 +0,0 @@
import 'package:flutter/cupertino.dart';
/// Keeps the web input's semantics stable when its clear action appears.
/// Nesting the clear button in CupertinoSearchTextField changes its merged
/// editable node into a disabled child node on web. Native sibling controls
/// retain both an enabled input and an independently accessible clear action.
class CupertinoWebSearchField extends StatefulWidget {
const CupertinoWebSearchField({
super.key,
required this.controller,
required this.placeholder,
required this.onCleared,
this.fieldKey,
this.focusNode,
this.autofocus = false,
this.inBar = false,
this.onChanged,
this.onSubmitted,
});
final TextEditingController controller;
final String placeholder;
final VoidCallback onCleared;
final Key? fieldKey;
final FocusNode? focusNode;
final bool autofocus;
final bool inBar;
final ValueChanged<String>? onChanged;
final ValueChanged<String>? onSubmitted;
@override
State<CupertinoWebSearchField> createState() =>
_CupertinoWebSearchFieldState();
}
class _CupertinoWebSearchFieldState extends State<CupertinoWebSearchField> {
FocusNode? _localFocus;
FocusNode get _focus => widget.focusNode ?? (_localFocus ??= FocusNode());
void _clear() {
final focus = _focus;
// The browser can keep the old editing session focused on the semantic
// clear button after it is removed. This explicit action ends that edit,
// then hands focus back after layout; ordinary query changes never refocus.
focus.unfocus();
widget.onCleared();
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted || !identical(focus, _focus)) return;
final current = FocusManager.instance.primaryFocus;
if (current == null || current == focus || current is FocusScopeNode) {
focus.requestFocus();
}
});
WidgetsBinding.instance.ensureVisualUpdate();
}
@override
void dispose() {
_localFocus?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => DecoratedBox(
decoration: BoxDecoration(
color: widget.inBar
? const Color(0x00000000)
: CupertinoColors.tertiarySystemFill.resolveFrom(context),
borderRadius: BorderRadius.circular(9),
),
child: ConstrainedBox(
constraints: const BoxConstraints(
minHeight: kMinInteractiveDimensionCupertino,
),
child: TextFieldTapRegion(
child: Row(
children: [
Expanded(
child: CupertinoSearchTextField(
key: widget.fieldKey,
controller: widget.controller,
focusNode: _focus,
autofocus: widget.autofocus,
placeholder: widget.placeholder,
backgroundColor: const Color(0x00000000),
suffixMode: OverlayVisibilityMode.never,
onChanged: widget.onChanged,
onSubmitted: widget.onSubmitted,
),
),
ValueListenableBuilder<TextEditingValue>(
valueListenable: widget.controller,
builder: (context, value, _) => value.text.isEmpty
? const SizedBox.shrink()
: CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 8),
onPressed: _clear,
child: Icon(
CupertinoIcons.clear_thick_circled,
color: CupertinoColors.secondaryLabel.resolveFrom(
context,
),
size: 20,
semanticLabel: CupertinoLocalizations.of(
context,
).clearButtonLabel,
),
),
),
],
),
),
),
);
}
@@ -1,6 +1,3 @@
import 'dart:math' as math;
import 'package:flutter/gestures.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
@@ -21,10 +18,9 @@ abstract interface class ContainerTransformGestureRoute
void endSwipeBack(double velocity);
}
/// The back gestures of a page that shrinks into its item: on a Cupertino
/// host the native swipe from the start edge; on Android the system's
/// predictive back. Either one drives the page's own animation, so the
/// shrink follows the finger, and releasing commits or cancels it.
/// The back gestures of a page that shrinks into its item: the system's
/// predictive back drives the page's own animation, so the shrink follows
/// the finger, and releasing commits or cancels it.
class ContainerTransformBackGestures extends StatelessWidget {
const ContainerTransformBackGestures({
super.key,
@@ -38,96 +34,8 @@ class ContainerTransformBackGestures extends StatelessWidget {
final Widget child;
@override
Widget build(BuildContext context) => cupertino
? _EdgeSwipeBack(route: route, child: child)
: _PredictiveBack(route: route, child: child);
}
/// The width of the start edge that takes a swipe back, as in iOS.
const double _edgeWidth = 20;
class _EdgeSwipeBack extends StatefulWidget {
const _EdgeSwipeBack({required this.route, required this.child});
final ContainerTransformGestureRoute route;
final Widget child;
@override
State<_EdgeSwipeBack> createState() => _EdgeSwipeBackState();
}
class _EdgeSwipeBackState extends State<_EdgeSwipeBack> {
late final HorizontalDragGestureRecognizer _recognizer =
HorizontalDragGestureRecognizer(debugOwner: this)
..onStart = _start
..onUpdate = _update
..onEnd = _end
..onCancel = _cancel;
bool _dragging = false;
@override
void dispose() {
_recognizer.dispose();
if (_dragging) widget.route.endSwipeBack(0);
super.dispose();
}
double _logical(double value) =>
Directionality.of(context) == TextDirection.rtl ? -value : value;
void _start(DragStartDetails details) {
_dragging = true;
widget.route.startSwipeBack();
}
void _update(DragUpdateDetails details) {
if (!_dragging) return;
widget.route.updateSwipeBack(
_logical(details.primaryDelta! / context.size!.width),
);
}
void _end(DragEndDetails details) {
if (!_dragging) return;
_dragging = false;
widget.route.endSwipeBack(
_logical(details.velocity.pixelsPerSecond.dx / context.size!.width),
);
}
void _cancel() {
if (!_dragging) return;
_dragging = false;
widget.route.endSwipeBack(0);
}
@override
Widget build(BuildContext context) {
final padding = MediaQuery.paddingOf(context);
final notch = Directionality.of(context) == TextDirection.rtl
? padding.right
: padding.left;
return Stack(
fit: StackFit.passthrough,
children: [
widget.child,
PositionedDirectional(
start: 0,
top: 0,
bottom: 0,
width: math.max(notch, _edgeWidth),
child: Listener(
behavior: HitTestBehavior.translucent,
onPointerDown: (event) {
if (widget.route.backGestureEnabled) {
_recognizer.addPointer(event);
}
},
),
),
],
);
}
Widget build(BuildContext context) =>
_PredictiveBack(route: route, child: child);
}
/// Forwards Android's predictive back to the page, as the stock Material
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'container_transform_flight.dart';
@@ -15,10 +14,9 @@ const Duration _droppedSwipeDuration = Duration(milliseconds: 350);
/// [link] resolves the item each time the page animates, so closing after
/// another item took the page shrinks into that one. When the item is not on
/// screen, or the system asks for reduced motion, the page fades instead.
/// The list behind stays put. A Cupertino host keeps the native swipe back
/// from the start edge and Android its predictive back; both drive the
/// shrink with the finger. The animation-speed setting scales every
/// duration through the scheduler clock.
/// The list behind stays put. Android's predictive back drives the shrink
/// with the finger. The animation-speed setting scales every duration
/// through the scheduler clock.
class ContainerTransformPageRoute<T> extends PageRoute<T>
implements ContainerTransformGestureRoute {
ContainerTransformPageRoute({
@@ -81,33 +79,16 @@ class ContainerTransformPageRoute<T> extends PageRoute<T>
Widget child,
) {
final reduced = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
final pageColor = cupertino
? CupertinoDynamicColor.resolve(
CupertinoTheme.of(context).scaffoldBackgroundColor,
context,
)
: Theme.of(context).scaffoldBackgroundColor;
Widget page = ContainerTransformFlight(
final page = ContainerTransformFlight(
animation: animation,
origin: reduced ? null : link.resolve,
closing: () =>
animation.status == AnimationStatus.reverse || popGestureInProgress,
tracking: () => popGestureInProgress,
pageColor: pageColor,
scrimColor: cupertino
? CupertinoColors.black
: Theme.of(context).colorScheme.scrim,
pageColor: Theme.of(context).scaffoldBackgroundColor,
scrimColor: Theme.of(context).colorScheme.scrim,
child: child,
);
if (cupertino) {
// A page pushed over this one keeps the native parallax.
page = CupertinoPageTransition(
primaryRouteAnimation: kAlwaysCompleteAnimation,
secondaryRouteAnimation: secondaryAnimation,
linearTransition: popGestureInProgress,
child: page,
);
}
return ContainerTransformBackGestures(
route: this,
cupertino: cupertino,
+7 -30
View File
@@ -1,14 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// One icon action of a segmented bar's actions pill (or any toolbar row).
///
/// Every action gets the platform's whole touch target and no extra padding,
/// so a row of them is evenly spaced and the last one never touches the
/// pill's edge: Material's [IconButton] (48dp, with its tooltip), Cupertino's
/// [CupertinoButton] at [kMinInteractiveDimensionCupertino] (44pt) square.
/// pill's edge: Material's [IconButton] (48dp, with its tooltip).
/// While [busy] the action shows the platform's activity indicator in the
/// same box and takes no taps.
class BarIconButton extends StatelessWidget {
@@ -43,40 +39,21 @@ class BarIconButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final native = cupertino ?? usesCupertinoHost(context);
if (busy) {
final side = native
? kMinInteractiveDimensionCupertino
: kMinInteractiveDimension;
return Semantics(
label: busyLabel ?? label,
liveRegion: true,
child: SizedBox.square(
dimension: side,
child: const SizedBox.square(
dimension: kMinInteractiveDimension,
child: Center(
child: native
? const CupertinoActivityIndicator()
: const SizedBox.square(
dimension: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
child: SizedBox.square(
dimension: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
),
),
);
}
if (native) {
return Semantics(
button: true,
label: label,
excludeSemantics: true,
child: CupertinoButton(
padding: EdgeInsets.zero,
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: onPressed,
child: Icon(cupertinoIcon),
),
);
}
return IconButton(
tooltip: label,
isSelected: selected,
+1 -24
View File
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/glass_bar.dart';
import '../adaptive/host.dart';
/// Previous and next as chevrons in one row at the bottom right, with the
/// position before them (`2 of 5`). Each chevron is named for assistive
@@ -34,33 +32,12 @@ class ChevronPager extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
Widget chevron({
required Key? key,
required bool previous,
required String label,
required VoidCallback? onPressed,
}) {
if (cupertino) {
return Semantics(
button: true,
enabled: onPressed != null,
label: label,
excludeSemantics: true,
child: CupertinoButton(
key: key,
padding: EdgeInsets.zero,
minimumSize: GlassBarMetrics.cupertinoMinimumSize(),
onPressed: onPressed,
child: Icon(
previous
? CupertinoIcons.chevron_left
: CupertinoIcons.chevron_right,
size: GlassBarMetrics.iconSize(true),
),
),
);
}
return IconButton(
key: key,
tooltip: label,
@@ -77,7 +54,7 @@ class ChevronPager extends StatelessWidget {
// The surrounding glass bar supplies the edge gap ([GlassBarMetrics]).
// The position keeps an icon's inset on each side, so it sits as far from
// the bar's edge and from the chevrons as an icon would.
final inset = GlassBarMetrics.iconInset(cupertino);
final inset = GlassBarMetrics.iconInset(false);
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
-16
View File
@@ -37,7 +37,6 @@ ThemeData appLightTheme({String? fontFamily}) {
colorScheme: scheme,
pageTransitionsTheme: appPageTransitions,
fontFamily: fontFamily,
cupertinoOverrideTheme: _cupertinoOverride(fontFamily, scheme),
);
}
@@ -110,7 +109,6 @@ ThemeData appDarkTheme({String? fontFamily}) {
scaffoldBackgroundColor: scheme.surface,
pageTransitionsTheme: appPageTransitions,
fontFamily: fontFamily,
cupertinoOverrideTheme: _cupertinoOverride(fontFamily, scheme),
);
}
@@ -146,17 +144,3 @@ CupertinoTextThemeData appCupertinoTextTheme(
dateTimePickerTextStyle: face(base.dateTimePickerTextStyle),
);
}
/// Cupertino widgets on a Material host derive their theme from Material's;
/// only the family is overridden, with Material's primary for actions.
NoDefaultCupertinoThemeData? _cupertinoOverride(
String? fontFamily,
ColorScheme scheme,
) => fontFamily == null
? null
: CupertinoThemeData(
textTheme: appCupertinoTextTheme(
fontFamily,
primaryColor: scheme.primary,
),
);