Complete Material-only APIs and fixtures

Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
This commit is contained in:
2026-11-11 21:55:39 +00:00
parent 63b2fd12cd
commit 9551eceaed
222 changed files with 540 additions and 1351 deletions
@@ -29,12 +29,10 @@ import 'floating_destination_labels.dart';
/// visible, scalable captions. Each tab's label stays its accessible name
/// (and the Material tooltip), announced as a selectable tab with "tab n of
/// m" the way the platform navigation controls announce theirs (see
/// [FloatingTabButton]); the icons must be distinct within a bar. The
/// Cupertino path builds no Material widget.
/// [FloatingTabButton]); the icons must be distinct within a bar.
class FloatingDestinationBar extends StatefulWidget {
const FloatingDestinationBar({
super.key,
required this.cupertino,
required this.currentIndex,
required this.onTap,
required this.items,
@@ -43,8 +41,6 @@ class FloatingDestinationBar extends StatefulWidget {
this.showLabels = false,
});
final bool cupertino;
/// Main app navigation keeps names visible; dense page tabs can stay icons.
final bool showLabels;
@@ -63,15 +59,12 @@ class FloatingDestinationBar extends StatefulWidget {
/// The icon size inside each button, as in the host navigation controls.
static const double materialIconSize = 28;
static const double cupertinoIconSize = 30;
/// The diameter of each tab button, which is also the bar's height.
static const double materialButtonSize = 52;
static const double cupertinoButtonSize = 50;
/// The gap between neighbouring buttons.
static const double materialButtonGap = 12;
static const double cupertinoButtonGap = 10;
/// The side margin at [FloatingBarEdge.top], matching the top bar's own.
static const double topMargin = 12;
@@ -79,28 +72,23 @@ class FloatingDestinationBar extends StatefulWidget {
/// The row of buttons inside each bar, for tests and measurement.
static const Key rowKey = ValueKey('floating-destination-bar.row');
static double buttonSize({required bool cupertino}) =>
cupertino ? cupertinoButtonSize : materialButtonSize;
static double buttonSize() => materialButtonSize;
static double buttonGap({required bool cupertino}) =>
cupertino ? cupertinoButtonGap : materialButtonGap;
static double buttonGap() => materialButtonGap;
/// The selected button's size, about [Motion.tabSelectedScale] times the
/// others (whole pixels, so layout stays exact).
static const double materialSelectedButtonSize = 62;
static const double cupertinoSelectedButtonSize = 60;
static double selectedButtonSize({required bool cupertino}) =>
cupertino ? cupertinoSelectedButtonSize : materialSelectedButtonSize;
static double selectedButtonSize() => materialSelectedButtonSize;
/// The width of a row of [tabs] buttons (one of them selected), when the
/// space allows it.
static double rowWidth({required bool cupertino, required int tabs}) =>
tabs == 0
static double rowWidth({required int tabs}) => tabs == 0
? 0
: buttonSize(cupertino: cupertino) * (tabs - 1) +
selectedButtonSize(cupertino: cupertino) +
buttonGap(cupertino: cupertino) * math.max(0, tabs - 1);
: buttonSize() * (tabs - 1) +
selectedButtonSize() +
buttonGap() * math.max(0, tabs - 1);
@override
State<FloatingDestinationBar> createState() => _FloatingDestinationBarState();
@@ -112,7 +100,6 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
final _backdrop = BackdropKey();
bool _entered = false;
bool get cupertino => widget.cupertino;
List<FloatingDestinationItem> get items => widget.items;
int get currentIndex => widget.currentIndex;
@@ -144,9 +131,8 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
static String _tabSetIdentity(List<FloatingDestinationItem> items) =>
items.map((item) => '${item.key ?? item.label}:${item.label}').join('|');
double get _size => FloatingDestinationBar.buttonSize(cupertino: cupertino);
double get _selectedSize =>
FloatingDestinationBar.selectedButtonSize(cupertino: cupertino);
double get _size => FloatingDestinationBar.buttonSize();
double get _selectedSize => FloatingDestinationBar.selectedButtonSize();
/// The buttons' natural width side by side, the selected one larger.
double get _buttonsWidth =>
@@ -194,7 +180,7 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
/// The gap between neighbouring buttons in [width]: the named one, or less
/// in a row squeezed below its natural width.
double _gap(double width) {
final gap = FloatingDestinationBar.buttonGap(cupertino: cupertino);
final gap = FloatingDestinationBar.buttonGap();
final count = items.length;
if (count < 2 || !width.isFinite) return gap;
return (width - _buttonsWidth).clamp(0.0, gap * (count - 1)) / (count - 1);
@@ -204,7 +190,6 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
if (widget.showLabels) {
return FloatingDestinationLabels(
key: FloatingDestinationBar.rowKey,
cupertino: cupertino,
labels: [for (final item in items) item.label],
selected: currentIndex,
buttonBuilder: (index) => _button(context, index),
@@ -243,15 +228,13 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
);
// The bar does not scale with text (its icons do not either); a badge
// count keeps its size.
return cupertino ? MediaQuery.withNoTextScaling(child: row) : row;
return row;
}
Widget _button(BuildContext context, int index) {
final item = items[index];
final selected = index == currentIndex;
final iconSize = cupertino
? FloatingDestinationBar.cupertinoIconSize
: FloatingDestinationBar.materialIconSize;
final iconSize = FloatingDestinationBar.materialIconSize;
// The selected button grows (and a deselected one shrinks back) in the
// layout, so its neighbours move over and keep their gaps.
return FloatingTabEntrance(
@@ -263,7 +246,6 @@ class _FloatingDestinationBarState extends State<FloatingDestinationBar>
curve: Motion.curve,
builder: (context, size, _) => FloatingTabButton(
key: item.key,
cupertino: cupertino,
motion: _motion,
index: index,
count: items.length,
@@ -6,13 +6,11 @@ import 'package:flutter/material.dart';
class FloatingDestinationLabels extends StatelessWidget {
const FloatingDestinationLabels({
super.key,
required this.cupertino,
required this.labels,
required this.selected,
required this.buttonBuilder,
required this.onTap,
});
final bool cupertino;
final List<String> labels;
final int selected;
final Widget Function(int) buttonBuilder;
+5 -17
View File
@@ -11,21 +11,19 @@ import 'segmented_bar_motion.dart';
/// One tab of a floating tab bar: a round [GlassPill] of [size] with the
/// tab's icon in the middle.
///
/// The selected tab fills its circle with the host's selection tint
/// (Material `secondaryContainer`, Cupertino active colour at
/// [cupertinoTintOpacity]) and draws its icon in the selected colour; the
/// The selected tab fills its circle with Material `secondaryContainer`
/// and draws its icon in the selected colour; the
/// tint and colour cross-fade when the selection moves. A press sinks the
/// button ([SegmentedPress]), the Material one with its circular ink.
///
/// It is announced like the host navigation controls' tabs: a tab (and a
/// button) named by [label], with its selected state and "tab n of m"
/// (in the Material label, or the Cupertino hint). Material shows [label]
/// in its accessible label. Material shows [label]
/// as a tooltip. The icon is painted above the glass, unclipped, so a badge
/// on its corner can reach past the circle.
class FloatingTabButton extends StatelessWidget {
const FloatingTabButton({
super.key,
required this.cupertino,
required this.motion,
required this.index,
required this.count,
@@ -37,7 +35,6 @@ class FloatingTabButton extends StatelessWidget {
required this.onTap,
});
final bool cupertino;
final FloatingTabMotion motion;
final int index;
final int count;
@@ -50,11 +47,7 @@ class FloatingTabButton extends StatelessWidget {
final Widget icon;
final VoidCallback onTap;
/// The Cupertino selection fill: the active colour at this opacity.
static const double cupertinoTintOpacity = 0.18;
/// The selection fill inside each button (an [Ink] on Material, a
/// [DecoratedBox] on Cupertino), for tests.
/// The selection [Ink] inside each button, for tests.
static const Key fillKey = ValueKey('floating-tab-button.fill');
@override
@@ -135,7 +128,6 @@ class FloatingTabButton extends StatelessWidget {
);
}
return SegmentedPress(
cupertino: cupertino,
child: SizedBox.square(
dimension: size,
child: Stack(
@@ -143,11 +135,7 @@ class FloatingTabButton extends StatelessWidget {
alignment: Alignment.center,
children: [
Positioned.fill(
child: GlassPill(
cupertino: cupertino,
shape: const CircleBorder(),
child: fill,
),
child: GlassPill(shape: const CircleBorder(), child: fill),
),
IgnorePointer(child: glyph),
],
+9 -22
View File
@@ -19,48 +19,35 @@ abstract final class GlassBarMetrics {
static const double fieldEdgeGap = 4;
/// The square target of one control: the platform's minimum touch target.
static double controlExtent(bool cupertino) => kMinInteractiveDimension;
static double controlExtent() => kMinInteractiveDimension;
/// The icon drawn inside a control's target.
static double iconSize(bool cupertino) => 28;
static double iconSize() => 28;
/// The space between a control's icon and the edge of its target.
static double iconInset(bool cupertino) =>
(controlExtent(cupertino) - iconSize(cupertino)) / 2;
static double iconInset() => (controlExtent() - iconSize()) / 2;
/// The visible circle of a filled control (Send) inside its target: the
/// Material filled icon button's 40 in 48, and the same inset on Cupertino.
static double filledExtent(bool cupertino) => controlExtent(cupertino) - 8;
/// Material filled icon button's 40 in 48.
static double filledExtent() => controlExtent() - 8;
/// The pill's height around one row of controls.
static double height(bool cupertino) =>
controlExtent(cupertino) + 2 * edgeGap;
static double height() => controlExtent() + 2 * edgeGap;
/// The Material target constraints of one control.
static BoxConstraints materialConstraints() => BoxConstraints(
minWidth: controlExtent(false),
minHeight: controlExtent(false),
);
/// Compatibility helper for callers still passing the old control family.
static Size cupertinoMinimumSize() => Size.square(controlExtent(false));
static BoxConstraints materialConstraints() =>
BoxConstraints(minWidth: controlExtent(), minHeight: controlExtent());
}
/// A [GlassPill] padded by [GlassBarMetrics.edgeGap] on every side around
/// [child], a row of controls each [GlassBarMetrics.controlExtent] tall.
class GlassControlBar extends StatelessWidget {
const GlassControlBar({
super.key,
required this.cupertino,
required this.child,
});
const GlassControlBar({super.key, required this.child});
final bool cupertino;
final Widget child;
@override
Widget build(BuildContext context) => GlassPill(
cupertino: cupertino,
child: Padding(
padding: const EdgeInsets.all(GlassBarMetrics.edgeGap),
child: child,
+3 -6
View File
@@ -4,14 +4,13 @@ import 'glass_surface.dart';
/// A frosted-glass piece floating over content: the content behind is
/// blurred and its colour lifted inside the piece's [shape], under a
/// translucent fill in the host's raised surface role (Material
/// `surfaceContainerHigh`, Cupertino `systemGrey5`), a soft highlight along
/// translucent fill in Material `surfaceContainerHigh`, a soft highlight along
/// its top, a faint rim over a hairline border, and a soft shadow
/// outside it ([GlassLook], tuned for light and dark fills).
///
/// Under the system's high-contrast setting the fill is solid, nothing is
/// blurred and only the hairline border is drawn. The Cupertino piece uses
/// no Material widget; the Material piece is a transparent [Material] so ink
/// blurred and only the hairline border is drawn. A transparent [Material]
/// lets ink
/// responses inside it show.
///
/// Shared by the segmented top bar and any floating bar (a tab bar) that
@@ -19,13 +18,11 @@ import 'glass_surface.dart';
class GlassPill extends StatelessWidget {
const GlassPill({
super.key,
required this.cupertino,
required this.child,
this.shape = const StadiumBorder(),
this.fill,
});
final bool cupertino;
final Widget child;
final OutlinedBorder shape;
-10
View File
@@ -1,10 +0,0 @@
import 'package:flutter/material.dart';
/// Whether the nearest app host is a Cupertino one.
///
/// A `CupertinoApp` supplies Cupertino localizations only, while `MaterialApp`
/// supplies [MaterialLocalizations]. Checking the host avoids guessing from a
/// desktop browser's target platform and keeps one answer for every control.
bool usesCupertinoHost(BuildContext context) =>
Localizations.of<MaterialLocalizations>(context, MaterialLocalizations) ==
null;
-9
View File
@@ -1,15 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
/// The app renders the same Material layout and design on every platform:
/// web, Android, iOS and macOS. The Cupertino host and controls remain
/// available only when a caller asks for them explicitly (`cupertino: true`);
/// they are never chosen from the target platform.
///
/// Flutter's automatic platform behaviours (scroll physics, text selection,
/// page transitions and back-swipe) still follow the target platform.
bool prefersCupertino() => false;
/// Whether this runs on a desktop platform (macOS, Linux, Windows),
/// including a desktop browser. Hover and click targets there hug their
/// content; phones and tablets keep full-width touch rows. Uses the device's
+11 -62
View File
@@ -1,6 +1,5 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@@ -40,18 +39,15 @@ export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill;
/// the leading piece (up to the widget's own width cap), with no title.
///
/// Only the pieces take taps: a tap between them reaches the content behind.
/// It works as a [Scaffold.appBar] (with `extendBodyBehindAppBar`) and a
/// [CupertinoPageScaffold.navigationBar], which inset the content by the
/// It works as a [Scaffold.appBar] (with `extendBodyBehindAppBar`), which insets content by the
/// bar's height through [MediaQuery.paddingOf], so a page keeps its
/// scaffold's structure; [SegmentedBarOverlay] does the same anywhere else.
/// It handles the top safe area itself, keeps its pieces clear of the
/// system's window controls ([WindowControlsClearance]), and on a wide window
/// keeps the wider [WindowMargins] from the top and the sides.
class SegmentedBar extends StatefulWidget
implements ObstructingPreferredSizeWidget {
class SegmentedBar extends StatefulWidget implements PreferredSizeWidget {
const SegmentedBar({
super.key,
required this.cupertino,
required this.title,
this.titleWidget,
this.titleWidgetMaxWidth = double.infinity,
@@ -75,11 +71,6 @@ class SegmentedBar extends StatefulWidget
this.backdrop,
});
/// Which control family to draw. Required because the bar's reserved
/// height differs: a Cupertino navigation bar never scales its text, so it
/// reserves exactly its height, while a Material app bar grows with text.
final bool cupertino;
/// The title; empty shows no title pill unless there is a [subtitle].
final String title;
@@ -160,35 +151,16 @@ class SegmentedBar extends StatefulWidget
@override
Size get preferredSize {
final piece = segmentedPieceHeight(cupertino);
if (cupertino) {
// CupertinoPageScaffold disables text scaling for its navigation bar
// and reserves exactly this height for it.
return Size.fromHeight(_topPadding + piece + bottomPadding);
}
final piece = segmentedPieceHeight();
// A Material scaffold only caps its app bar at this height and lets it
// size to its content: room for a title and subtitle at the largest
// text scale.
return Size.fromHeight(_topPadding + piece * maxTextScale + bottomPadding);
}
@override
// Content scrolls behind the bar; the scaffold insets it by the bar's
// height through the media padding instead.
bool shouldFullyObstruct(BuildContext context) => false;
Color _background(BuildContext context) {
if (backgroundColor case final color?) {
// A dynamic system colour (the grouped background) follows the theme.
return CupertinoDynamicColor.maybeResolve(color, context) ?? color;
}
if (cupertino) {
return context
.dependOnInheritedWidgetOfExactType<
CupertinoPageScaffoldBackgroundColor
>()
?.color ??
CupertinoTheme.of(context).scaffoldBackgroundColor;
return color;
}
return Scaffold.maybeOf(context)?.widget.backgroundColor ??
Theme.of(context).scaffoldBackgroundColor;
@@ -252,7 +224,6 @@ class _SegmentedBarState extends State<SegmentedBar> {
return ConstrainedBox(
constraints: BoxConstraints(maxWidth: widget.titleWidgetMaxWidth),
child: SegmentedPill(
cupertino: widget.cupertino,
fill: widget.pillColor,
child: SizedBox(width: double.infinity, child: titleWidget),
),
@@ -312,7 +283,6 @@ class _SegmentedBarState extends State<SegmentedBar> {
List<Widget> actions,
List<Object> ids,
List<SegmentedActionEntrance> entrances, {
required bool cupertino,
required double overflowWidth,
}) {
final entries = [
@@ -329,9 +299,8 @@ class _SegmentedBarState extends State<SegmentedBar> {
more: ExcludeFocus(
excluding: entries.isEmpty,
child: SegmentedPress(
cupertino: cupertino,
tint: widget.foregroundColor,
child: SegmentedMoreButton(cupertino: cupertino, entries: entries),
child: SegmentedMoreButton(entries: entries),
),
),
actions: [
@@ -344,7 +313,6 @@ class _SegmentedBarState extends State<SegmentedBar> {
delay: entrances[index].delay,
glass: false,
child: SegmentedPress(
cupertino: cupertino,
tint: widget.foregroundColor,
enabled: actions.length > 1,
child: widget.separateActionIslands
@@ -353,7 +321,6 @@ class _SegmentedBarState extends State<SegmentedBar> {
start: index == 0 ? 0 : 8,
),
child: SegmentedPill(
cupertino: cupertino,
fill: widget.pillColor,
child: action,
),
@@ -366,17 +333,13 @@ class _SegmentedBarState extends State<SegmentedBar> {
);
}
Widget _actionsIsland({
required bool cupertino,
Color? fill,
required Widget child,
}) => widget.separateActionIslands
Widget _actionsIsland({Color? fill, required Widget child}) =>
widget.separateActionIslands
? child
: SegmentedPill(cupertino: cupertino, fill: fill, child: child);
: SegmentedPill(fill: fill, child: child);
@override
Widget build(BuildContext context) {
final cupertino = widget.cupertino;
final title = widget.title;
final titleWidget = widget.titleWidget;
final leadingWidget = widget.leading;
@@ -392,12 +355,9 @@ class _SegmentedBarState extends State<SegmentedBar> {
final bottomPadding = widget.bottomPadding;
final leading =
leadingWidget ??
(automaticallyImplyLeading
? impliedSegmentedLeading(context, cupertino)
: null);
(automaticallyImplyLeading ? impliedSegmentedLeading(context) : null);
final showTitle = title.isNotEmpty || (subtitle ?? '').isNotEmpty;
Widget titlePill(bool expanded) => SegmentedTitlePill(
cupertino: cupertino,
title: title,
subtitle: subtitle,
subtitleIcon: subtitleIcon,
@@ -437,7 +397,6 @@ class _SegmentedBarState extends State<SegmentedBar> {
math.min(
segmentedTitleWidth(
context,
cupertino: cupertino,
title: title,
subtitle: subtitle,
subtitleIcon: subtitleIcon,
@@ -450,9 +409,7 @@ class _SegmentedBarState extends State<SegmentedBar> {
? .10
: SegmentedBar.minTitleShare;
final besideTitle =
width -
(leading == null ? 0 : segmentedPieceHeight(cupertino) + 8) -
8;
width - (leading == null ? 0 : segmentedPieceHeight() + 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.
@@ -468,13 +425,8 @@ class _SegmentedBarState extends State<SegmentedBar> {
key: const ValueKey('segmented.leading'),
delay: entrances.leading,
child: SegmentedPress(
cupertino: cupertino,
tint: foregroundColor,
child: SegmentedPill(
cupertino: cupertino,
fill: pillColor,
child: leading,
),
child: SegmentedPill(fill: pillColor, child: leading),
),
),
const SizedBox(width: 8),
@@ -508,17 +460,14 @@ class _SegmentedBarState extends State<SegmentedBar> {
// A lone action is the whole pill, so the pill sinks when it
// is pressed; beside others, each action sinks on its own.
child: SegmentedPress(
cupertino: cupertino,
tint: foregroundColor,
enabled: actions.length == 1,
child: _actionsIsland(
cupertino: cupertino,
fill: pillColor,
child: _actionRow(
actions,
actionIds,
entrances.actions,
cupertino: cupertino,
overflowWidth: overflowWidth,
),
),
@@ -9,7 +9,7 @@ import '../motion/motion.dart';
/// back.
///
/// It only listens: the control below still takes the tap, and its own
/// feedback (an ink ripple, a Cupertino button's dimming) still shows. A
/// feedback (an ink ripple) still shows. A
/// quick tap plays the whole press before springing back, so it is seen.
/// Under reduced motion only the tint shows. When [enabled] is false it does
/// nothing, so a bar can switch a piece's feedback on and off without
@@ -17,13 +17,11 @@ import '../motion/motion.dart';
class SegmentedPress extends StatefulWidget {
const SegmentedPress({
super.key,
required this.cupertino,
required this.child,
this.enabled = true,
this.tint,
});
final bool cupertino;
final Widget child;
final bool enabled;
@@ -5,8 +5,7 @@ import 'package:flutter/material.dart';
/// all fit.
const segmentedMoreKey = ValueKey<String>('segmented.more');
/// One choice under a [SegmentedOverflowEntry] (a sort order): a submenu on
/// Material, a second action sheet on Cupertino.
/// One choice under a [SegmentedOverflowEntry] (a sort order): a Material submenu.
class SegmentedMenuChoice {
const SegmentedMenuChoice({
required this.label,
@@ -69,15 +68,10 @@ class SegmentedOverflowAction extends StatelessWidget
}
/// The bar's More button: the host's overflow icon at the platform's touch
/// target, opening a Material menu or a Cupertino action sheet of [entries].
/// target, opening a Material menu of [entries].
class SegmentedMoreButton extends StatelessWidget {
const SegmentedMoreButton({
super.key,
required this.cupertino,
required this.entries,
});
const SegmentedMoreButton({super.key, required this.entries});
final bool cupertino;
final List<SegmentedOverflowEntry> entries;
static const String label = 'More actions';
+8 -35
View File
@@ -5,19 +5,13 @@ 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(bool cupertino) => kMinInteractiveDimension;
double segmentedPieceHeight() => kMinInteractiveDimension;
/// One rounded piece of a segmented bar: a [GlassPill] at least the
/// platform's touch-target size.
class SegmentedPill extends StatelessWidget {
const SegmentedPill({
super.key,
required this.cupertino,
required this.child,
this.fill,
});
const SegmentedPill({super.key, required this.child, this.fill});
final bool cupertino;
final Widget child;
/// Overrides the fill (a dark viewer's pieces).
@@ -25,10 +19,9 @@ class SegmentedPill extends StatelessWidget {
@override
Widget build(BuildContext context) {
final height = segmentedPieceHeight(cupertino);
final height = segmentedPieceHeight();
// A stadium whose content is as wide as it is tall is a circle.
return GlassPill(
cupertino: cupertino,
fill: fill,
child: ConstrainedBox(
// The minimum reaches the content, so a pressable piece is pressable
@@ -43,13 +36,8 @@ class SegmentedPill extends StatelessWidget {
/// The app's Material Back button for a segmented bar. A null [onPressed] keeps the
/// stock action (pop the route).
class SegmentedBackButton extends StatelessWidget {
const SegmentedBackButton({
super.key,
required this.cupertino,
this.onPressed,
});
const SegmentedBackButton({super.key, this.onPressed});
final bool cupertino;
final VoidCallback? onPressed;
@override
@@ -59,7 +47,7 @@ class SegmentedBackButton extends StatelessWidget {
/// What a bar implies on the leading edge when the page gave none, matching
/// the stock bars: Back on a route that can go back, the platform's close
/// control on a full-screen dialog, nothing on a root page.
Widget? impliedSegmentedLeading(BuildContext context, bool cupertino) {
Widget? impliedSegmentedLeading(BuildContext context) {
final route = ModalRoute.of(context);
if (route == null) return null;
final dialog = route is PageRoute && route.fullscreenDialog;
@@ -70,7 +58,6 @@ Widget? impliedSegmentedLeading(BuildContext context, bool cupertino) {
/// The title pill's title and subtitle styles, from the host's type scale.
(TextStyle, TextStyle) segmentedTitleStyles(
BuildContext context, {
required bool cupertino,
Color? foreground,
}) {
final theme = Theme.of(context);
@@ -92,7 +79,6 @@ const double segmentedTitlePadding = 16;
/// the text scale at [context]).
double segmentedTitleWidth(
BuildContext context, {
required bool cupertino,
required String title,
String? subtitle,
IconData? subtitleIcon,
@@ -100,7 +86,6 @@ double segmentedTitleWidth(
}) {
final (titleStyle, subtitleStyle) = segmentedTitleStyles(
context,
cupertino: cupertino,
foreground: foreground,
);
final scaler = MediaQuery.textScalerOf(context);
@@ -136,7 +121,6 @@ double segmentedTitleWidth(
class SegmentedTitlePill extends StatelessWidget {
const SegmentedTitlePill({
super.key,
required this.cupertino,
required this.title,
this.subtitle,
this.subtitleIcon,
@@ -150,7 +134,6 @@ class SegmentedTitlePill extends StatelessWidget {
this.fill,
});
final bool cupertino;
final String title;
final String? subtitle;
final IconData? subtitleIcon;
@@ -169,7 +152,6 @@ class SegmentedTitlePill extends StatelessWidget {
Widget build(BuildContext context) {
final (titleStyle, subtitleStyle) = segmentedTitleStyles(
context,
cupertino: cupertino,
foreground: foreground,
);
final subtitle = this.subtitle ?? '';
@@ -258,7 +240,6 @@ class SegmentedTitlePill extends StatelessWidget {
// title and the action each give their own feedback.
final split = titleAction != null;
final pill = SegmentedPill(
cupertino: cupertino,
fill: fill,
child: Row(
mainAxisSize: MainAxisSize.min,
@@ -267,24 +248,16 @@ class SegmentedTitlePill extends StatelessWidget {
fit: FlexFit.loose,
child: IntrinsicWidth(
child: split && onPressed != null
? SegmentedPress(
cupertino: cupertino,
tint: foreground,
child: body,
)
? SegmentedPress(tint: foreground, child: body)
: body,
),
),
if (titleAction != null)
SegmentedPress(
cupertino: cupertino,
tint: foreground,
child: titleAction,
),
SegmentedPress(tint: foreground, child: titleAction),
],
),
);
if (split || onPressed == null) return pill;
return SegmentedPress(cupertino: cupertino, tint: foreground, child: pill);
return SegmentedPress(tint: foreground, child: pill);
}
}
-3
View File
@@ -18,13 +18,11 @@ const double kTopGlassStripRadius = 22;
class TopGlassStrip extends StatelessWidget {
const TopGlassStrip({
super.key,
required this.cupertino,
required this.child,
this.maxWidth = double.infinity,
this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
});
final bool cupertino;
final Widget child;
/// The widest the strip grows on a wide window.
@@ -50,7 +48,6 @@ class TopGlassStrip extends StatelessWidget {
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: maxWidth),
child: GlassPill(
cupertino: cupertino,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(kTopGlassStripRadius),
),
-2
View File
@@ -19,7 +19,6 @@ class AppSearchField extends StatelessWidget {
this.autofocus = false,
this.focusNode,
this.inBar = false,
this.cupertino,
});
final TextEditingController controller;
@@ -39,7 +38,6 @@ class AppSearchField extends StatelessWidget {
final bool autofocus;
final FocusNode? focusNode;
final bool inBar;
final bool? cupertino;
void _clear() {
controller.clear();
+8 -17
View File
@@ -65,7 +65,6 @@ class AppListRow extends StatelessWidget {
this.emphasized = false,
this.divider = true,
this.compactWidth = kAppListRowCompactWidth,
this.cupertino,
this.accent,
this.showAccentBorder = true,
});
@@ -107,22 +106,14 @@ class AppListRow extends StatelessWidget {
final bool divider;
final double compactWidth;
/// 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: Theme.of(context).brightness == Brightness.dark ? 0.12 : 0.07,
);
static Color? tintFor(BuildContext context, Color? accent) =>
accent?.withValues(
alpha: Theme.of(context).brightness == Brightness.dark ? 0.12 : 0.07,
);
/// The open row's fill. The [cupertino] argument is ignored; the fill is
/// always Material `secondaryContainer`.
static Color selectedColor(BuildContext context, {required bool cupertino}) =>
/// The open row's fill is Material `secondaryContainer`.
static Color selectedColor(BuildContext context) =>
Theme.of(context).colorScheme.secondaryContainer;
@override
@@ -172,11 +163,11 @@ class AppListRow extends StatelessWidget {
],
),
);
final tint = tintFor(context, accent, cupertino: false);
final tint = tintFor(context, accent);
final surface = Material(
key: appListRowSurfaceKey,
color: selected
? selectedFill ?? selectedColor(context, cupertino: false)
? selectedFill ?? selectedColor(context)
: tint ?? Colors.transparent,
child: InkWell(
key: tapKey,
-4
View File
@@ -19,7 +19,6 @@ class AppSheetHeader extends StatelessWidget {
this.actions = const [],
this.onDone,
this.doneKey,
this.cupertino,
});
final String title;
@@ -31,9 +30,6 @@ class AppSheetHeader extends StatelessWidget {
final VoidCallback? onDone;
final Key? doneKey;
/// Ignored: the header is always Material. Kept so existing callers compile.
final bool? cupertino;
@override
Widget build(BuildContext context) {
final done = onDone ?? () => Navigator.of(context).maybePop();
-4
View File
@@ -43,7 +43,6 @@ class FactsGrid extends StatelessWidget {
required this.items,
this.padding = const EdgeInsets.fromLTRB(16, 12, 16, 12),
this.selectable = true,
this.cupertino,
});
final List<FactsGridItem> items;
@@ -52,9 +51,6 @@ class FactsGrid extends StatelessWidget {
/// Values are selectable text unless this is false.
final bool selectable;
/// Ignored: the grid is always Material. Kept so existing callers compile.
final bool? cupertino;
@override
Widget build(BuildContext context) {
final labelStyle = Theme.of(context).textTheme.bodySmall?.copyWith(
@@ -25,12 +25,10 @@ class ContainerTransformBackGestures extends StatelessWidget {
const ContainerTransformBackGestures({
super.key,
required this.route,
required this.cupertino,
required this.child,
});
final ContainerTransformGestureRoute route;
final bool cupertino;
final Widget child;
@override
@@ -22,13 +22,11 @@ class ContainerTransformPageRoute<T> extends PageRoute<T>
ContainerTransformPageRoute({
required this.builder,
required this.link,
required this.cupertino,
super.settings,
});
final WidgetBuilder builder;
final ContainerTransformLink link;
final bool cupertino;
bool get _reducedMotion {
final context = navigator?.context;
@@ -89,11 +87,7 @@ class ContainerTransformPageRoute<T> extends PageRoute<T>
scrimColor: Theme.of(context).colorScheme.scrim,
child: child,
);
return ContainerTransformBackGestures(
route: this,
cupertino: cupertino,
child: page,
);
return ContainerTransformBackGestures(route: this, child: page);
}
@override
@@ -11,20 +11,15 @@ class BarIconButton extends StatelessWidget {
const BarIconButton({
super.key,
required this.icon,
this.cupertinoIcon,
required this.label,
required this.onPressed,
this.selected = false,
this.busy = false,
this.busyLabel,
this.cupertino,
});
final IconData icon;
/// Retained for source compatibility; Material rendering always uses [icon].
final IconData? cupertinoIcon;
/// The tooltip and accessible name.
final String label;
final VoidCallback? onPressed;
@@ -36,9 +31,6 @@ class BarIconButton extends StatelessWidget {
/// The accessible name while [busy]; defaults to [label].
final String? busyLabel;
/// The control family; defaults to the host's.
final bool? cupertino;
@override
Widget build(BuildContext context) {
if (busy) {
+2 -2
View File
@@ -46,7 +46,7 @@ class ChevronPager extends StatelessWidget {
onPressed: onPressed,
icon: Icon(
previous ? Icons.chevron_left : Icons.chevron_right,
size: GlassBarMetrics.iconSize(false),
size: GlassBarMetrics.iconSize(),
),
);
}
@@ -54,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(false);
final inset = GlassBarMetrics.iconInset();
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
+4 -59
View File
@@ -1,34 +1,12 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/cupertino.dart';
// Framework transition for Material routes: keeps Apple's interactive Back.
import 'package:flutter/cupertino.dart' show CupertinoPageTransitionsBuilder;
import 'package:flutter/material.dart';
/// The app's backgrounds. Dark mode uses a near-black gray rather than pure
/// black, so cards, sections and bars read as layers above the page.
abstract final class AppColors {
/// A page.
static const background = CupertinoDynamicColor.withBrightness(
color: Color(0xFFFFFFFF),
darkColor: Color(0xFF141416),
);
/// Behind grouped sections (Settings-style lists).
static const groupedBackground = CupertinoDynamicColor.withBrightness(
color: Color(0xFFF2F2F7),
darkColor: Color(0xFF141416),
);
/// Bars over the page.
static const bar = CupertinoDynamicColor.withBrightness(
color: Color(0xF0F9F9F9),
darkColor: Color(0xF01C1C1F),
);
}
const _seed = Color(0xFF6750A4);
/// [fontFamily] replaces the platform family throughout the text themes
/// (Material's, and Cupertino's for Cupertino widgets on a Material host),
/// keeping every size, weight and the text scaling; null keeps the system
/// [fontFamily] replaces the platform family throughout the Material text
/// themes, keeping every size, weight and text scaling. Null keeps the system
/// typography.
ThemeData appLightTheme({String? fontFamily}) {
final scheme = ColorScheme.fromSeed(seedColor: _seed);
@@ -111,36 +89,3 @@ ThemeData appDarkTheme({String? fontFamily}) {
fontFamily: fontFamily,
);
}
const appCupertinoTheme = CupertinoThemeData(
scaffoldBackgroundColor: AppColors.background,
barBackgroundColor: AppColors.bar,
);
/// [appCupertinoTheme] with every Cupertino text role in [fontFamily]; null
/// keeps the system typography.
CupertinoThemeData appCupertinoThemeWith({String? fontFamily}) =>
fontFamily == null
? appCupertinoTheme
: appCupertinoTheme.copyWith(textTheme: appCupertinoTextTheme(fontFamily));
/// The stock Cupertino text roles (sizes, weights, colours) in [fontFamily].
/// Action roles take [primaryColor], as the stock roles do.
CupertinoTextThemeData appCupertinoTextTheme(
String fontFamily, {
Color primaryColor = CupertinoColors.systemBlue,
}) {
final base = CupertinoTextThemeData(primaryColor: primaryColor);
TextStyle face(TextStyle style) => style.copyWith(fontFamily: fontFamily);
return CupertinoTextThemeData(
textStyle: face(base.textStyle),
actionTextStyle: face(base.actionTextStyle),
actionSmallTextStyle: face(base.actionSmallTextStyle),
tabLabelTextStyle: face(base.tabLabelTextStyle),
navTitleTextStyle: face(base.navTitleTextStyle),
navLargeTitleTextStyle: face(base.navLargeTitleTextStyle),
navActionTextStyle: face(base.navActionTextStyle),
pickerTextStyle: face(base.pickerTextStyle),
dateTimePickerTextStyle: face(base.dateTimePickerTextStyle),
);
}