9551eceaed
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.
80 lines
2.5 KiB
Dart
80 lines
2.5 KiB
Dart
import 'package:flutter/material.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.
|
|
///
|
|
/// 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 {
|
|
const AppSheetHeader({
|
|
super.key,
|
|
required this.title,
|
|
this.actions = const [],
|
|
this.onDone,
|
|
this.doneKey,
|
|
});
|
|
|
|
final String title;
|
|
|
|
/// 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;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final done = onDone ?? () => Navigator.of(context).maybePop();
|
|
final titleStyle = Theme.of(context).textTheme.titleLarge;
|
|
final Widget doneButton = TextButton(
|
|
key: doneKey,
|
|
onPressed: done,
|
|
child: const Text(appSheetDoneLabel),
|
|
);
|
|
return Padding(
|
|
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 8, 4),
|
|
child: LayoutBuilder(
|
|
builder: (context, constraints) {
|
|
final heading = Expanded(
|
|
child: Semantics(
|
|
header: true,
|
|
namesRoute: true,
|
|
child: Text(title, style: titleStyle),
|
|
),
|
|
);
|
|
// A narrow sheet at large text moves the extra actions to a line
|
|
// of their own under the title, so nothing is squeezed off.
|
|
final narrow =
|
|
constraints.maxWidth <
|
|
MediaQuery.textScalerOf(context).scale(_wideHeaderWidth);
|
|
if (actions.isEmpty || !narrow) {
|
|
return Row(children: [heading, ...actions, doneButton]);
|
|
}
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Row(children: [heading, doneButton]),
|
|
Align(
|
|
alignment: AlignmentDirectional.centerStart,
|
|
child: Wrap(children: actions),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Below this width (scaled with the text) the extra actions wrap under the
|
|
/// title.
|
|
const double _wideHeaderWidth = 360;
|