Remove Cupertino branches from layout widgets

Keep the public cupertino parameters for existing callers while making the layout widgets and focused tests Material-only. Remove unreachable Cupertino imports, helpers, widgets, and test variants without changing the Material path.
This commit is contained in:
2026-11-11 16:35:38 +00:00
parent edc503b228
commit a5912d9a1e
11 changed files with 262 additions and 547 deletions
+8 -21
View File
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// The leading circle every list row uses, as large as a native contact
/// avatar ([CircleAvatar]'s default).
const double kAppListAvatarSize = 40;
@@ -48,29 +45,19 @@ class AppListAvatar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final mark =
foreground ??
(cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant);
final mark = foreground ?? Theme.of(context).colorScheme.onSurfaceVariant;
final fill =
background ??
(foreground == null
? (cupertino
? CupertinoColors.systemGrey5.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainerHighest)
? Theme.of(context).colorScheme.surfaceContainerHighest
: mark.withValues(alpha: 0.14));
final initialStyle =
(cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.titleMedium ?? const TextStyle())
.copyWith(
color: mark,
fontSize: 18,
fontWeight: FontWeight.w700,
height: 1,
);
(Theme.of(context).textTheme.titleMedium ?? const TextStyle()).copyWith(
color: mark,
fontSize: 18,
fontWeight: FontWeight.w700,
height: 1,
);
final circle = SizedBox.square(
dimension: kAppListAvatarSize,
child: DecoratedBox(
+25 -121
View File
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import 'app_list_avatar.dart';
/// Below this row width (a list pane squeezed beside its detail) a row is
@@ -31,12 +29,8 @@ const appListRowSurfaceKey = ValueKey<String>('app-list-row-surface');
const appListRowDividerKey = ValueKey<String>('app-list-row-divider');
const appListRowAccentKey = ValueKey<String>('app-list-row-accent');
bool _darkSurface(BuildContext context, bool cupertino) => cupertino
? CupertinoTheme.brightnessOf(context) == Brightness.dark
: Theme.of(context).brightness == Brightness.dark;
/// The app's one list row (runs, pipelines, chats, search results,
/// schedules), on both hosts.
/// schedules).
///
/// Layout: [leading] (an [AppListAvatar]), then a bold one-line [title] with
/// the [time] at its trailing edge, then one muted [subtitle] line (with an
@@ -48,10 +42,8 @@ bool _darkSurface(BuildContext context, bool cupertino) => cupertino
/// under the text column separates rows. Nothing has a fixed height: the row
/// grows with text scaling and every line ellipsises.
///
/// [selected] paints the open row (Material `secondaryContainer`, Cupertino
/// `tertiarySystemFill`); [emphasized] marks unread/attention (a heavier
/// title and an accent time). Material rows ripple; Cupertino rows highlight
/// while pressed, like a native table cell.
/// [selected] paints the open row (Material `secondaryContainer`); [emphasized]
/// marks unread/attention (a heavier title and an accent time). Rows ripple.
class AppListRow extends StatelessWidget {
const AppListRow({
super.key,
@@ -115,29 +107,28 @@ class AppListRow extends StatelessWidget {
final bool divider;
final double compactWidth;
/// Overrides the host detection (some features pick a style per platform).
/// Ignored: rows are always Material. Kept so existing callers compile.
final bool? cupertino;
/// The faint tint an unselected row with [accent] wears over the list.
/// The [cupertino] argument is ignored; the tint is always Material.
static Color? tintFor(
BuildContext context,
Color? accent, {
required bool cupertino,
}) =>
accent?.withValues(alpha: _darkSurface(context, cupertino) ? 0.12 : 0.07);
}) => accent?.withValues(
alpha: Theme.of(context).brightness == Brightness.dark ? 0.12 : 0.07,
);
/// The open row's fill on each host.
/// The open row's fill. The [cupertino] argument is ignored; the fill is
/// always Material `secondaryContainer`.
static Color selectedColor(BuildContext context, {required bool cupertino}) =>
cupertino
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
: Theme.of(context).colorScheme.secondaryContainer;
Theme.of(context).colorScheme.secondaryContainer;
@override
Widget build(BuildContext context) {
final cupertino = this.cupertino ?? usesCupertinoHost(context);
final styles = _RowStyles.of(
context,
cupertino: cupertino,
selected: selected,
emphasized: emphasized,
);
@@ -181,29 +172,19 @@ class AppListRow extends StatelessWidget {
],
),
);
final tint = tintFor(context, accent, cupertino: cupertino);
final surface = cupertino
? _CupertinoRowSurface(
tapKey: tapKey,
onTap: onTap,
onLongPress: onLongPress,
selected: selected,
tint: tint,
selectedFill: selectedFill,
child: content,
)
: Material(
key: appListRowSurfaceKey,
color: selected
? selectedFill ?? selectedColor(context, cupertino: false)
: tint ?? Colors.transparent,
child: InkWell(
key: tapKey,
onTap: onTap,
onLongPress: onLongPress,
child: content,
),
);
final tint = tintFor(context, accent, cupertino: false);
final surface = Material(
key: appListRowSurfaceKey,
color: selected
? selectedFill ?? selectedColor(context, cupertino: false)
: tint ?? Colors.transparent,
child: InkWell(
key: tapKey,
onTap: onTap,
onLongPress: onLongPress,
child: content,
),
);
// The colour bar runs the row's whole height, divider included, and
// the tint fills the divider's inset too, so coloured rows read as
// one band each.
@@ -229,9 +210,7 @@ class AppListRow extends StatelessWidget {
padding: EdgeInsetsDirectional.only(start: textStart),
child: SizedBox(
key: appListRowDividerKey,
height: cupertino
? 1 / MediaQuery.devicePixelRatioOf(context)
: 1,
height: 1,
child: ColoredBox(color: styles.divider),
),
);
@@ -353,26 +332,10 @@ class _RowStyles {
factory _RowStyles.of(
BuildContext context, {
required bool cupertino,
required bool selected,
required bool emphasized,
}) {
final weight = emphasized ? FontWeight.w700 : FontWeight.w600;
if (cupertino) {
final theme = CupertinoTheme.of(context);
final base = theme.textTheme.textStyle;
final muted = CupertinoColors.secondaryLabel.resolveFrom(context);
final small = base.copyWith(fontSize: 15, color: muted);
return _RowStyles(
base.copyWith(fontWeight: weight, letterSpacing: 0),
small,
small.copyWith(
color: emphasized ? theme.primaryColor : muted,
fontWeight: emphasized ? FontWeight.w600 : null,
),
CupertinoColors.separator.resolveFrom(context),
);
}
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final text = theme.textTheme;
@@ -397,62 +360,3 @@ class _RowStyles {
final TextStyle time;
final Color divider;
}
/// A Cupertino table cell: highlights while pressed, tinted while selected.
class _CupertinoRowSurface extends StatefulWidget {
const _CupertinoRowSurface({
required this.tapKey,
required this.onTap,
required this.selected,
this.onLongPress,
this.tint,
this.selectedFill,
required this.child,
});
/// The unselected row's tint, transparent when null.
final Color? tint;
final Color? selectedFill;
final Key? tapKey;
final VoidCallback? onTap;
final VoidCallback? onLongPress;
final bool selected;
final Widget child;
@override
State<_CupertinoRowSurface> createState() => _CupertinoRowSurfaceState();
}
class _CupertinoRowSurfaceState extends State<_CupertinoRowSurface> {
bool _pressed = false;
void _press(bool value) {
if (_pressed != value) setState(() => _pressed = value);
}
@override
Widget build(BuildContext context) {
final color = _pressed
? CupertinoColors.systemGrey4.resolveFrom(context)
: widget.selected
? widget.selectedFill ??
AppListRow.selectedColor(context, cupertino: true)
: widget.tint ?? const Color(0x00000000);
final enabled = widget.onTap != null;
return GestureDetector(
key: widget.tapKey,
behavior: HitTestBehavior.opaque,
onTap: widget.onTap,
onLongPress: widget.onLongPress,
onTapDown: enabled ? (_) => _press(true) : null,
onTapUp: enabled ? (_) => _press(false) : null,
onTapCancel: enabled ? () => _press(false) : null,
child: ColoredBox(
key: appListRowSurfaceKey,
color: color,
child: widget.child,
),
);
}
}
+13 -36
View File
@@ -1,19 +1,15 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// The label of every sheet's close action.
const appSheetDoneLabel = 'Done';
/// The app's one sheet header: the sheet's [title] at the start, then any
/// extra [actions] (Clear all), then Done, which closes the sheet.
///
/// Material shows the title in `titleLarge` and a [TextButton]; Cupertino
/// shows the navigation title style and a bold [CupertinoButton], like a
/// modal's navigation bar. The title is a header that names the route, so a
/// screen reader announces the sheet by it. Nothing has a fixed height and the
/// title wraps at large text. Used by the Runs filter and sort sheets and the
/// The title is shown in `titleLarge` with a [TextButton] for Done. The title
/// is a header that names the route, so a screen reader announces the sheet by
/// it. Nothing has a fixed height and the title wraps at large text. Used by the
/// Runs filter and sort sheets and the
/// Needs you sheet, so every sheet closes the same way, not only by its drag
/// handle.
class AppSheetHeader extends StatelessWidget {
@@ -28,46 +24,27 @@ class AppSheetHeader extends StatelessWidget {
final String title;
/// Controls before Done, in the host's style.
/// Controls before Done.
final List<Widget> actions;
/// Closes the sheet; the default pops the route the header is in.
final VoidCallback? onDone;
final Key? doneKey;
/// Overrides the host detection.
/// Ignored: the header is always Material. Kept so existing callers compile.
final bool? cupertino;
@override
Widget build(BuildContext context) {
final cupertino = this.cupertino ?? usesCupertinoHost(context);
final done = onDone ?? () => Navigator.of(context).maybePop();
final titleStyle = cupertino
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleLarge;
final Widget doneButton = cupertino
? CupertinoButton(
key: doneKey,
padding: const EdgeInsets.symmetric(horizontal: 8),
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: done,
child: const Text(
appSheetDoneLabel,
style: TextStyle(fontWeight: FontWeight.w600),
),
)
: TextButton(
key: doneKey,
onPressed: done,
child: const Text(appSheetDoneLabel),
);
final titleStyle = Theme.of(context).textTheme.titleLarge;
final Widget doneButton = TextButton(
key: doneKey,
onPressed: done,
child: const Text(appSheetDoneLabel),
);
return Padding(
padding: EdgeInsetsDirectional.fromSTEB(
cupertino ? 20 : 24,
cupertino ? 8 : 0,
8,
4,
),
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 8, 4),
child: LayoutBuilder(
builder: (context, constraints) {
final heading = Expanded(
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import '../motion/motion.dart';
import 'section_heading.dart';
import 'sliver_animated_extent.dart';
@@ -90,10 +88,7 @@ class _SliverCollapsibleListSectionState
}
Widget _heading(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
return Semantics(
container: true,
header: true,
@@ -123,10 +118,7 @@ class _SliverCollapsibleListSectionState
turns: _open ? 0.5 : 0,
duration: Motion.of(context, Motion.standard),
curve: Motion.curve,
child: Icon(
cupertino ? CupertinoIcons.chevron_down : Icons.expand_more,
color: muted,
),
child: Icon(Icons.expand_more, color: muted),
),
],
),
+11 -22
View File
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import '../text/monospace.dart';
/// One recorded fact of a detail Summary: a small muted label over its value.
@@ -31,8 +29,8 @@ const int kFactsGridLongValue = 28;
/// The pane width from which the grid shows three facts per line.
const double kFactsGridThreeColumnWidth = 600;
/// A detail Summary's facts as one compact grid on the page, the same on
/// both hosts and in every detail (run, pipeline): two facts per line on a
/// A detail Summary's facts as one compact grid on the page, the same in every
/// detail (run, pipeline): two facts per line on a
/// phone, three from [kFactsGridThreeColumnWidth]; a long, wide or monospace
/// value (a path, a hash) takes a whole line.
///
@@ -51,28 +49,19 @@ class FactsGrid extends StatelessWidget {
final List<FactsGridItem> items;
final EdgeInsetsGeometry padding;
/// Material values are selectable text; Cupertino values stay plain text.
/// Values are selectable text unless this is false.
final bool selectable;
/// Overrides the host detection (a feature that picks its style per
/// platform).
/// Ignored: the grid is always Material. Kept so existing callers compile.
final bool? cupertino;
@override
Widget build(BuildContext context) {
final cupertino = this.cupertino ?? usesCupertinoHost(context);
final labelStyle = cupertino
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
)
: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
final labelStyle = Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
final TextStyle valueStyle =
(cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodyMedium) ??
const TextStyle();
Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
return Padding(
padding: padding,
child: LayoutBuilder(
@@ -101,7 +90,7 @@ class FactsGrid extends StatelessWidget {
children: [
Text(item.label, style: labelStyle),
const SizedBox(height: 2),
_value(item, valueStyle, cupertino),
_value(item, valueStyle),
],
),
),
@@ -113,11 +102,11 @@ class FactsGrid extends StatelessWidget {
);
}
Widget _value(FactsGridItem item, TextStyle base, bool cupertino) {
Widget _value(FactsGridItem item, TextStyle base) {
final style = item.monospace
? base.copyWith(fontFamily: appMonospaceFamily)
: base;
if (cupertino || !selectable) return Text(item.value, style: style);
if (!selectable) return Text(item.value, style: style);
return SelectableText(item.value, style: style);
}
}
-23
View File
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// The look every section title shares: a quiet, grouped-list label rather than
/// another filled row.
class SectionHeadingStyle {
@@ -23,26 +20,6 @@ class SectionHeadingStyle {
final Color line;
static SectionHeadingStyle of(BuildContext context) {
if (usesCupertinoHost(context)) {
final theme = CupertinoTheme.of(context);
final base = theme.textTheme.textStyle;
// The detail pages (run, stage, pipeline) are flat on the page colour,
// as on Material, so a pinned heading's scrim is the page itself rather
// than a grey grouped band (black in dark mode).
final page = theme.scaffoldBackgroundColor;
return SectionHeadingStyle(
background: page,
body: page,
accent: CupertinoTheme.of(context).primaryColor,
title: base.copyWith(
fontSize: 13,
fontWeight: FontWeight.w600,
letterSpacing: 0.4,
color: CupertinoColors.secondaryLabel.resolveFrom(context),
),
line: CupertinoColors.separator.resolveFrom(context),
);
}
final scheme = Theme.of(context).colorScheme;
return SectionHeadingStyle(
background: scheme.surface,
+7 -33
View File
@@ -1,11 +1,8 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import '../adaptive/window_margins.dart';
import '../theme/app_theme.dart';
import '../motion/motion.dart';
import 'section_heading.dart';
import 'sliver_reveal.dart';
@@ -179,13 +176,10 @@ class StickySectionTitle extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
// The shared section-title look is deliberately quiet, like a grouped-list
// label rather than a separate, filled row.
final heading = SectionHeadingStyle.of(context);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final muted = Theme.of(context).colorScheme.onSurfaceVariant;
final style = color == null
? heading.title
: heading.title.copyWith(color: color);
@@ -193,10 +187,7 @@ class StickySectionTitle extends StatelessWidget {
turns: open ? 0.5 : 0,
duration: Motion.of(context, Motion.standard),
curve: Motion.curve,
child: Icon(
cupertino ? CupertinoIcons.chevron_down : Icons.expand_more,
color: muted,
),
child: Icon(Icons.expand_more, color: muted),
);
// On a wide window the chevron keeps the title's 16 px from the edge, in
// line with the top bar's trailing piece; a phone keeps it closer.
@@ -238,21 +229,10 @@ class StickySectionTitle extends StatelessWidget {
final scrim = pinned
? heading.background
: heading.background.withValues(alpha: 0.94);
final Widget strip = cupertino
? GestureDetector(
behavior: HitTestBehavior.opaque,
excludeFromSemantics: true,
onTap: onToggle,
child: ColoredBox(color: scrim, child: row),
)
: Material(
color: scrim,
child: InkWell(
onTap: onToggle,
excludeFromSemantics: true,
child: row,
),
);
final Widget strip = Material(
color: scrim,
child: InkWell(onTap: onToggle, excludeFromSemantics: true, child: row),
);
return Stack(
clipBehavior: Clip.none,
fit: StackFit.expand,
@@ -283,9 +263,6 @@ class _SectionBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
final content = Padding(padding: padding, child: child);
if (usesCupertinoHost(context)) {
return content;
}
// Rows inside retain a Material ancestor for their ink reactions.
return Material(type: MaterialType.transparency, child: content);
}
@@ -300,12 +277,9 @@ class StickyBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
return PinnedHeaderSliver(
child: ColoredBox(
color: cupertino
? AppColors.groupedBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surface,
color: Theme.of(context).colorScheme.surface,
child: child,
),
);
+1 -39
View File
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import 'section_heading.dart';
/// Protocol warning arrays contain human-readable strings. Ignore malformed
@@ -37,43 +34,8 @@ class WarningsSection extends StatelessWidget {
for (final message in messages)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 8),
child: usesCupertinoHost(context)
? _CupertinoWarningText(message)
: SelectableText(message),
child: SelectableText(message),
),
],
);
}
class _CupertinoWarningText extends StatefulWidget {
const _CupertinoWarningText(this.message);
final String message;
@override
State<_CupertinoWarningText> createState() => _CupertinoWarningTextState();
}
class _CupertinoWarningTextState extends State<_CupertinoWarningText> {
late final _controller = TextEditingController(text: widget.message);
@override
void didUpdateWidget(covariant _CupertinoWarningText oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.message != oldWidget.message) _controller.text = widget.message;
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => CupertinoTextField(
controller: _controller,
readOnly: true,
maxLines: null,
padding: EdgeInsets.zero,
decoration: const BoxDecoration(),
);
}