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.
88 lines
2.7 KiB
Dart
88 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../shell/shell_bar.dart';
|
|
import '../../../ui/adaptive/segmented_bar.dart';
|
|
import '../../../ui/navigation/bar_icon_button.dart';
|
|
|
|
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
|
const templatesBackKey = ValueKey<String>('templates-back');
|
|
const templatesTitle = 'Templates';
|
|
|
|
/// The screen's native chrome.
|
|
///
|
|
/// Standalone use draws the segmented bar: the round Back (back to the
|
|
/// gallery from a template, otherwise the route's own) and Refresh in the
|
|
/// actions pill. A page that already owns a bar passes [embedded]; the
|
|
/// screen then publishes its Back and Refresh to that bar through
|
|
/// [ShellBar]. Only with no bar above at all does Refresh sit atop the body.
|
|
class TemplatesFrame extends StatelessWidget {
|
|
const TemplatesFrame({
|
|
super.key,
|
|
required this.body,
|
|
required this.embedded,
|
|
required this.canGoBack,
|
|
required this.refreshing,
|
|
required this.onBack,
|
|
required this.onRefresh,
|
|
this.title = templatesTitle,
|
|
this.subtitle,
|
|
});
|
|
|
|
/// The bar's title pill: `Templates` on the gallery, the open template's
|
|
/// name (with its description as [subtitle]) on a detail.
|
|
final String title;
|
|
final String? subtitle;
|
|
final Widget body;
|
|
final bool embedded;
|
|
final bool canGoBack;
|
|
final bool refreshing;
|
|
final VoidCallback onBack;
|
|
final VoidCallback onRefresh;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (embedded) {
|
|
if (ShellBar.available(context)) {
|
|
return ShellBar(
|
|
title: title,
|
|
subtitle: subtitle,
|
|
onBack: canGoBack ? onBack : null,
|
|
actions: [_refreshButton()],
|
|
child: body,
|
|
);
|
|
}
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Align(
|
|
alignment: AlignmentDirectional.centerEnd,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
child: _refreshButton(),
|
|
),
|
|
),
|
|
Expanded(child: body),
|
|
],
|
|
);
|
|
}
|
|
final bar = SegmentedBar(
|
|
leading: canGoBack
|
|
? SegmentedBackButton(key: templatesBackKey, onPressed: onBack)
|
|
: null,
|
|
title: title,
|
|
subtitle: subtitle,
|
|
actions: [_refreshButton()],
|
|
);
|
|
// The body reaches the top edge and scrolls behind the bar.
|
|
final page = SafeArea(top: false, bottom: false, child: body);
|
|
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: page);
|
|
}
|
|
|
|
Widget _refreshButton() => BarIconButton(
|
|
key: templatesRefreshKey,
|
|
icon: Icons.refresh,
|
|
label: 'Refresh',
|
|
onPressed: refreshing ? null : onRefresh,
|
|
);
|
|
}
|