Merge branch 'main' into run-chat-info-header
This commit is contained in:
@@ -479,6 +479,7 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
onViewPipelineRuns: (id) =>
|
||||
_delegate.goTo(AppRoute.runsForPipeline(id)),
|
||||
onOpenSchedules: _delegate.openSchedules,
|
||||
onOpenSettings: () => _delegate.goTo(AppRoute.settings),
|
||||
// The open pipeline is part of the route, so Back steps out of it.
|
||||
onSelectionChanged: (id) {
|
||||
final current = _delegate.route;
|
||||
@@ -529,13 +530,15 @@ class _PipelinesAppState extends State<PipelinesApp>
|
||||
onSessionSelected: (id) => _delegate.goTo(AppRoute.chatSession(id)),
|
||||
onBack: () => _delegate.goTo(AppRoute.chat),
|
||||
),
|
||||
// Search is the fifth tab; a result opens its destination.
|
||||
// Search is the fourth tab; a result opens its destination.
|
||||
AppDestination.search: (_) => SearchDestination(
|
||||
session: _session,
|
||||
server: widget.server,
|
||||
onOpen: _openSearchResult,
|
||||
embedded: true,
|
||||
),
|
||||
// Settings is a page of the Pipelines tab (its bar's gear), not a
|
||||
// tab; the shell shows it with Back to Pipelines.
|
||||
AppDestination.settings: (_) => SettingsScreen(
|
||||
client: _session.client,
|
||||
// A phone signs in at the web login; a browser has its own.
|
||||
|
||||
@@ -23,6 +23,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
this.onRunStarted,
|
||||
this.onViewPipelineRuns,
|
||||
this.onOpenSchedules,
|
||||
this.onOpenSettings,
|
||||
this.onSelectionChanged,
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
@@ -42,6 +43,9 @@ class PipelinesDestination extends StatelessWidget {
|
||||
final ValueChanged<int>? onRunStarted;
|
||||
final ValueChanged<int>? onViewPipelineRuns;
|
||||
final VoidCallback? onOpenSchedules;
|
||||
|
||||
/// Opens Settings as a page from the Pipelines bar's gear.
|
||||
final VoidCallback? onOpenSettings;
|
||||
final ValueChanged<int?>? onSelectionChanged;
|
||||
|
||||
/// The pipeline and pinned version a deep link names.
|
||||
@@ -95,6 +99,7 @@ class PipelinesDestination extends StatelessWidget {
|
||||
onRunStarted: onRunStarted,
|
||||
onViewPipelineRuns: onViewPipelineRuns,
|
||||
onOpenSchedules: onOpenSchedules,
|
||||
onOpenSettings: onOpenSettings,
|
||||
onSelectionChanged: onSelectionChanged,
|
||||
initialPipelineId: initialPipelineId,
|
||||
initialVersion: initialVersion,
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'pipeline_models.dart';
|
||||
import 'pipeline_repository.dart';
|
||||
import 'pipelines_controller.dart';
|
||||
import 'pending_run_store.dart';
|
||||
import 'widgets/pipeline_bar_buttons.dart';
|
||||
import 'widgets/pipeline_controls.dart';
|
||||
import 'widgets/pipeline_detail_panel.dart';
|
||||
import 'widgets/pipeline_list_panel.dart';
|
||||
@@ -36,6 +37,7 @@ class PipelinesScreen extends StatefulWidget {
|
||||
this.onViewPipelineRuns,
|
||||
this.onSelectionChanged,
|
||||
this.onOpenSchedules,
|
||||
this.onOpenSettings,
|
||||
this.initialPipelineId,
|
||||
this.initialVersion = 0,
|
||||
this.initialStageKey,
|
||||
@@ -66,6 +68,9 @@ class PipelinesScreen extends StatefulWidget {
|
||||
/// Opens every schedule; shown in the bar while the list is visible.
|
||||
final VoidCallback? onOpenSchedules;
|
||||
|
||||
/// Opens Settings as a page; a gear in the bar while the list is visible.
|
||||
final VoidCallback? onOpenSettings;
|
||||
|
||||
/// The pipeline a deep link names, opened after the list read starts.
|
||||
final int? initialPipelineId;
|
||||
|
||||
@@ -281,6 +286,8 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
if (listShown && widget.onOpenSchedules != null)
|
||||
_schedulesButton(context),
|
||||
_refreshButton(context),
|
||||
if (listShown && widget.onOpenSettings != null)
|
||||
_settingsButton(context),
|
||||
],
|
||||
child: body,
|
||||
);
|
||||
@@ -298,6 +305,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
...pipelineListActions(context, _controller),
|
||||
if (widget.onOpenSchedules != null) _schedulesButton(context),
|
||||
_refreshButton(context),
|
||||
if (widget.onOpenSettings != null) _settingsButton(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -307,26 +315,11 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _schedulesButton(BuildContext context) {
|
||||
if (useCupertinoControls(context)) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: 'Schedules',
|
||||
child: CupertinoButton(
|
||||
key: const Key('pipelines-open-schedules'),
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: widget.onOpenSchedules,
|
||||
child: const Icon(CupertinoIcons.calendar),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
key: const Key('pipelines-open-schedules'),
|
||||
tooltip: 'Schedules',
|
||||
onPressed: widget.onOpenSchedules,
|
||||
icon: const Icon(Icons.schedule),
|
||||
);
|
||||
}
|
||||
Widget _schedulesButton(BuildContext context) =>
|
||||
pipelineSchedulesButton(context, widget.onOpenSchedules);
|
||||
|
||||
Widget _settingsButton(BuildContext context) =>
|
||||
pipelineSettingsButton(context, widget.onOpenSettings);
|
||||
|
||||
Widget _refreshButton(BuildContext context) {
|
||||
if (useCupertinoControls(context)) {
|
||||
@@ -357,6 +350,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
...pipelineListActions(context, _controller),
|
||||
if (widget.onOpenSchedules != null) _schedulesButton(context),
|
||||
_refreshButton(context),
|
||||
if (widget.onOpenSettings != null) _settingsButton(context),
|
||||
],
|
||||
),
|
||||
body: SafeArea(top: false, child: body),
|
||||
@@ -372,6 +366,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
|
||||
...pipelineListActions(context, _controller),
|
||||
if (widget.onOpenSchedules != null) _schedulesButton(context),
|
||||
_refreshButton(context),
|
||||
if (widget.onOpenSettings != null) _settingsButton(context),
|
||||
],
|
||||
),
|
||||
child: SafeArea(top: false, child: body),
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'pipeline_controls.dart';
|
||||
|
||||
/// One icon action in the Pipelines bar's actions pill: a Material
|
||||
/// [IconButton] with its tooltip, or a Cupertino button named for
|
||||
/// accessibility.
|
||||
Widget pipelineBarIconButton(
|
||||
BuildContext context, {
|
||||
required Key key,
|
||||
required String label,
|
||||
required IconData icon,
|
||||
required IconData cupertinoIcon,
|
||||
required VoidCallback? onPressed,
|
||||
}) {
|
||||
if (useCupertinoControls(context)) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
child: CupertinoButton(
|
||||
key: key,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: Icon(cupertinoIcon),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
key: key,
|
||||
tooltip: label,
|
||||
onPressed: onPressed,
|
||||
icon: Icon(icon),
|
||||
);
|
||||
}
|
||||
|
||||
/// Opens every schedule.
|
||||
Widget pipelineSchedulesButton(BuildContext context, VoidCallback? onPressed) =>
|
||||
pipelineBarIconButton(
|
||||
context,
|
||||
key: const Key('pipelines-open-schedules'),
|
||||
label: 'Schedules',
|
||||
icon: Icons.schedule,
|
||||
cupertinoIcon: CupertinoIcons.calendar,
|
||||
onPressed: onPressed,
|
||||
);
|
||||
|
||||
/// Opens Settings as a page (it is not a tab of the shell).
|
||||
Widget pipelineSettingsButton(BuildContext context, VoidCallback? onPressed) =>
|
||||
pipelineBarIconButton(
|
||||
context,
|
||||
key: const Key('pipelines-open-settings'),
|
||||
label: 'Settings',
|
||||
icon: Icons.settings_outlined,
|
||||
cupertinoIcon: CupertinoIcons.gear,
|
||||
onPressed: onPressed,
|
||||
);
|
||||
@@ -4,14 +4,15 @@ import 'package:flutter/material.dart';
|
||||
/// The detail sections: Summary, the pinned definition Graph and Source.
|
||||
enum PipelineDetailTab {
|
||||
summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text),
|
||||
graph('Graph', Icons.account_tree_outlined, CupertinoIcons.arrow_branch),
|
||||
graph('Graph', Icons.hub_outlined, CupertinoIcons.flowchart),
|
||||
source('Source', Icons.code, CupertinoIcons.chevron_left_slash_chevron_right);
|
||||
|
||||
const PipelineDetailTab(this.label, this.icon, this.cupertinoIcon);
|
||||
|
||||
final String label;
|
||||
|
||||
/// The tab's glyph, shown above its name in the bottom bar.
|
||||
/// The tab's glyph, the only thing the bottom bar draws (the label is its
|
||||
/// accessible name); distinct from the shell's Pipelines tab beneath it.
|
||||
final IconData icon;
|
||||
final IconData cupertinoIcon;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ enum RunVisitSection {
|
||||
Icons.difference_outlined,
|
||||
CupertinoIcons.arrow_right_arrow_left,
|
||||
),
|
||||
session('Session', Icons.forum_outlined, CupertinoIcons.chat_bubble_2),
|
||||
session('Session', Icons.forum_outlined, CupertinoIcons.text_bubble),
|
||||
definition(
|
||||
'Definition',
|
||||
Icons.description_outlined,
|
||||
|
||||
@@ -117,7 +117,10 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
// Full-screen detail routes cover the shell themselves. Keep the root tabs
|
||||
// mounted/layout-ready underneath, so Back does not resize or reveal them
|
||||
// only after the outgoing page has finished its native animation.
|
||||
final index = AppDestination.values.indexOf(_selected);
|
||||
// Settings is shown as a page of the Pipelines tab: the tab bar keeps
|
||||
// Pipelines selected and the bar offers Back to it.
|
||||
final index = shellTabDestinations.indexOf(shellTabFor(_selected));
|
||||
final page = !shellTabDestinations.contains(_selected);
|
||||
final details = destinationDetails(_selected);
|
||||
final contents = AppDestination.values.map((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
@@ -144,62 +147,75 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
// scaffold's structure depends on the width, so resizing never
|
||||
// remounts a destination.
|
||||
//
|
||||
// While the tab shows its list beside an open item, the bar floats
|
||||
// over the list pane only (judging its placement on that width), so
|
||||
// it never covers the item or stacks on the item's own composer.
|
||||
// While the tab shows its list beside an open item the bar keeps
|
||||
// the same place, bottom right near the thumb: the item pane learns
|
||||
// the bar's height (see ListDetailPanes) and floats its own tabs or
|
||||
// composer above it, so the two never overlap.
|
||||
final split = _bar.split(_selected);
|
||||
final bar = ListPaneWidth(
|
||||
split: split,
|
||||
alignment: AlignmentDirectional.bottomStart,
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: widget.cupertino,
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(AppDestination.values[value]),
|
||||
items: _destinationItems(),
|
||||
),
|
||||
final bar = FloatingDestinationBar(
|
||||
cupertino: widget.cupertino,
|
||||
currentIndex: index,
|
||||
onTap: (value) => _select(shellTabDestinations[value]),
|
||||
items: _destinationItems(),
|
||||
);
|
||||
// Destinations reach the top edge and scroll behind the floating top
|
||||
// bar too: each learns the bar's height as its top media padding and
|
||||
// pads its own lists by it (see withTopBarClearance).
|
||||
final topBar = _ListPaneBar(
|
||||
split: split,
|
||||
bar: _segmentedBar(spec, details.label),
|
||||
bar: _segmentedBar(spec, details.label, page: page),
|
||||
);
|
||||
// The scaffolds below swap the system insets for their bars'
|
||||
// heights; panes beside a list read the real ones from here.
|
||||
final system = MediaQuery.paddingOf(context);
|
||||
// A page (Settings) closes to Pipelines on the system Back too. The
|
||||
// scope is always there, so opening the page never remounts the shell.
|
||||
Widget backable(Widget child) => PopScope(
|
||||
canPop: !page,
|
||||
onPopInvokedWithResult: (didPop, _) {
|
||||
if (!didPop) _closePage();
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
if (widget.cupertino) {
|
||||
return ShellSystemInsets(
|
||||
padding: system,
|
||||
child: CupertinoPageScaffold(
|
||||
navigationBar: topBar,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: FloatingBarOverlay(
|
||||
bar: bar,
|
||||
child: _destinationStack(contents, index),
|
||||
return backable(
|
||||
ShellSystemInsets(
|
||||
padding: system,
|
||||
child: CupertinoPageScaffold(
|
||||
navigationBar: topBar,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: FloatingBarOverlay(
|
||||
bar: bar,
|
||||
child: _destinationStack(contents),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return ShellSystemInsets(
|
||||
padding: system,
|
||||
child: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: topBar,
|
||||
body: _destinationStack(contents, index),
|
||||
extendBody: true,
|
||||
bottomNavigationBar: bar,
|
||||
return backable(
|
||||
ShellSystemInsets(
|
||||
padding: system,
|
||||
child: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: topBar,
|
||||
body: _destinationStack(contents),
|
||||
extendBody: true,
|
||||
bottomNavigationBar: bar,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Leaves a page destination (Settings) for the tab it belongs to.
|
||||
void _closePage() => _select(shellTabFor(_selected));
|
||||
|
||||
List<FloatingDestinationItem> _destinationItems() =>
|
||||
AppDestination.values.map((destination) {
|
||||
shellTabDestinations.map((destination) {
|
||||
final item = destinationDetails(destination);
|
||||
return FloatingDestinationItem(
|
||||
key: ValueKey('shell.destination.${destination.name}'),
|
||||
@@ -213,9 +229,13 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
|
||||
/// The open screen's own bar: its Back, title and actions, or the tab's
|
||||
/// name with Search.
|
||||
SegmentedBar _segmentedBar(ShellBarSpec? spec, String label) {
|
||||
SegmentedBar _segmentedBar(
|
||||
ShellBarSpec? spec,
|
||||
String label, {
|
||||
required bool page,
|
||||
}) {
|
||||
final cupertino = widget.cupertino;
|
||||
final onBack = spec?.onBack;
|
||||
final onBack = spec?.onBack ?? (page ? _closePage : null);
|
||||
final published = spec?.actions ?? const <Widget>[];
|
||||
final onSearch = widget.onSearch;
|
||||
return SegmentedBar(
|
||||
@@ -251,7 +271,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
)
|
||||
// A screen whose main pill is its own field (Search) needs no
|
||||
// separate Search action.
|
||||
else if (onSearch != null && spec?.titleWidget == null)
|
||||
else if (onSearch != null && spec?.titleWidget == null && !page)
|
||||
cupertino
|
||||
? CupertinoButton(
|
||||
key: const ValueKey('shell.search'),
|
||||
@@ -272,8 +292,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _destinationStack(List<Widget> contents, int index) =>
|
||||
IndexedStack(key: _destinationStackKey, index: index, children: contents);
|
||||
Widget _destinationStack(List<Widget> contents) => IndexedStack(
|
||||
key: _destinationStackKey,
|
||||
index: AppDestination.values.indexOf(_selected),
|
||||
children: contents,
|
||||
);
|
||||
}
|
||||
|
||||
/// The shell's top bar, over the list pane only while the tab shows a list
|
||||
|
||||
@@ -3,6 +3,23 @@ import 'package:flutter/cupertino.dart';
|
||||
|
||||
enum AppDestination { pipelines, runs, chat, search, settings }
|
||||
|
||||
/// The destinations the shell's tab bar offers, in order. Settings is a
|
||||
/// destination the shell can show (its route is `/settings`), but it opens
|
||||
/// as a page from the Pipelines bar's gear instead of being a tab.
|
||||
const List<AppDestination> shellTabDestinations = [
|
||||
AppDestination.pipelines,
|
||||
AppDestination.runs,
|
||||
AppDestination.chat,
|
||||
AppDestination.search,
|
||||
];
|
||||
|
||||
/// The tab that owns [destination] in the tab bar: itself, or Pipelines for
|
||||
/// Settings (reached from the Pipelines bar).
|
||||
AppDestination shellTabFor(AppDestination destination) =>
|
||||
shellTabDestinations.contains(destination)
|
||||
? destination
|
||||
: AppDestination.pipelines;
|
||||
|
||||
({String label, IconData icon, IconData cupertinoIcon}) destinationDetails(
|
||||
AppDestination value,
|
||||
) => switch (value) {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/adaptive/host.dart';
|
||||
|
||||
/// The open item's own navigator beside a list on a wide window.
|
||||
///
|
||||
/// A page the item opens (a run's stage page, an artifact, a file) is pushed
|
||||
/// here, so it fills the item's pane while the list and the shell's tab bar
|
||||
/// stay in place: the page's own tabs then float above the shell's bar, as
|
||||
/// the item's tabs do. Dialogs still use the root navigator.
|
||||
///
|
||||
/// The item is this navigator's first page under a fixed key, so a rebuilt
|
||||
/// item updates in place and is never remounted. The system Back pops a page
|
||||
/// pushed here before it leaves the item.
|
||||
class DetailPaneNavigator extends StatefulWidget {
|
||||
const DetailPaneNavigator({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<DetailPaneNavigator> createState() => _DetailPaneNavigatorState();
|
||||
}
|
||||
|
||||
class _DetailPaneNavigatorState extends State<DetailPaneNavigator> {
|
||||
final GlobalKey<NavigatorState> _navigator = GlobalKey();
|
||||
static const _rootKey = ValueKey<String>('list-detail-root');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Page<void> root = usesCupertinoHost(context)
|
||||
? CupertinoPage<void>(key: _rootKey, child: widget.child)
|
||||
: MaterialPage<void>(key: _rootKey, child: widget.child);
|
||||
return NavigatorPopHandler(
|
||||
onPopWithResult: (_) => _navigator.currentState?.maybePop(),
|
||||
child: Navigator(
|
||||
key: _navigator,
|
||||
pages: [root],
|
||||
// The item is never popped from here: its pane closes with the
|
||||
// selection, which the owning screen controls.
|
||||
onDidRemovePage: (_) {},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../ui/adaptive/host.dart';
|
||||
import 'detail_pane_navigator.dart';
|
||||
import 'shell_bar.dart';
|
||||
|
||||
/// At least this wide, a destination keeps its list beside the open item
|
||||
@@ -100,11 +101,14 @@ class ListPaneWidth extends StatelessWidget {
|
||||
/// One body-priority policy for all destinations, derived from the full window
|
||||
/// and actual available space after navigation. No fixed pixel pane widths.
|
||||
///
|
||||
/// Under the shell, the list keeps the shell's bars (both narrowed to the list
|
||||
/// Under the shell, the list keeps the shell's top bar (narrowed to the list
|
||||
/// pane through [ShellPaneSplit], see [ListPaneWidth]) and the open item owns
|
||||
/// the rest of the window: the detail starts at the top edge and reaches the
|
||||
/// bottom edge with only the system insets ([ShellSystemInsets]) as its
|
||||
/// padding, and its own tabs float at its bottom, as on a phone.
|
||||
/// the rest of the window: the detail starts at the top edge below the status
|
||||
/// bar ([ShellSystemInsets]). The shell's tab bar stays at the bottom right,
|
||||
/// over the detail pane, so the detail learns that bar's height plus
|
||||
/// [kStackedBarGap] as its bottom padding: its own tabs (or the chat
|
||||
/// composer) float above the shell's bar, never on it, and its content clears
|
||||
/// both. Pages the item opens stay in its pane ([DetailPaneNavigator]).
|
||||
class ListDetailPanes extends StatelessWidget {
|
||||
const ListDetailPanes({super.key, required this.list, required this.detail});
|
||||
|
||||
@@ -129,21 +133,35 @@ class ListDetailPanes extends StatelessWidget {
|
||||
constraints.maxWidth,
|
||||
);
|
||||
Widget body = detail;
|
||||
Widget listPane = list;
|
||||
if (split) {
|
||||
// Beside the list the item is under neither of the shell's bars
|
||||
// (both stay over the list pane): it keeps only the system's own
|
||||
// insets, so its bar sits just below the status bar at the top
|
||||
// edge, and its tabs or composer own the pane's bottom edge,
|
||||
// floating just above the system inset.
|
||||
// Beside the list the item is not under the shell's top bar (it
|
||||
// stays over the list pane): it keeps the system's own top inset,
|
||||
// so its bar sits just below the status bar at the top edge. The
|
||||
// shell's tab bar floats at the bottom right, over this pane; its
|
||||
// height (the shell's bottom padding here) plus a gap lifts the
|
||||
// item's tabs or composer above it.
|
||||
final system = ShellSystemInsets.of(context);
|
||||
body = MediaQuery(
|
||||
data: media.copyWith(
|
||||
padding: media.padding.copyWith(
|
||||
top: system.top,
|
||||
bottom: system.bottom,
|
||||
bottom: media.padding.bottom + kStackedBarGap,
|
||||
),
|
||||
),
|
||||
child: PageTabsEdge(edge: FloatingBarEdge.bottom, child: body),
|
||||
child: PageTabsEdge(
|
||||
edge: FloatingBarEdge.bottom,
|
||||
child: DetailPaneNavigator(child: body),
|
||||
),
|
||||
);
|
||||
// The tab bar sits over the detail pane, never the list (the
|
||||
// detail is at least half the window, wider than the bar), so
|
||||
// the list clears only the system's bottom inset.
|
||||
listPane = MediaQuery(
|
||||
data: media.copyWith(
|
||||
padding: media.padding.copyWith(bottom: system.bottom),
|
||||
),
|
||||
child: list,
|
||||
);
|
||||
}
|
||||
return Row(
|
||||
@@ -156,7 +174,7 @@ class ListDetailPanes extends StatelessWidget {
|
||||
container: true,
|
||||
explicitChildNodes: true,
|
||||
identifier: 'list-detail-list',
|
||||
child: list,
|
||||
child: listPane,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -7,6 +7,11 @@ const double kFloatingBarWideWidth = 600;
|
||||
/// The gap between a floating tab bar and the edges (and bottom safe area).
|
||||
const double kFloatingBarMargin = 16;
|
||||
|
||||
/// The gap between two floating bars stacked at the bottom right of a wide
|
||||
/// window: the shell's tab bar and, above it, an open item's own tabs (the
|
||||
/// chat composer adds its own padding on top of this).
|
||||
const double kStackedBarGap = 12;
|
||||
|
||||
/// [padding] with the floating bar's clearance added at the bottom.
|
||||
///
|
||||
/// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell)
|
||||
|
||||
@@ -17,6 +17,10 @@ import 'glass_pill.dart';
|
||||
/// way it keeps [kFloatingBarMargin] above the bottom safe area. Only the pill
|
||||
/// takes taps: the space beside it reaches the content behind.
|
||||
///
|
||||
/// The tabs show icons only. Each tab's label stays its accessible name (and
|
||||
/// the Material tooltip), so screen readers still announce it; the icons must
|
||||
/// be distinct within a bar.
|
||||
///
|
||||
/// The controls inside remain the platform navigation controls (Material
|
||||
/// [NavigationBar], Cupertino [CupertinoTabBar]), so tab semantics (selected
|
||||
/// state, "tab n of m") come from the host. The Cupertino path builds no
|
||||
@@ -41,11 +45,17 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
final ValueChanged<int> onTap;
|
||||
final List<FloatingDestinationItem> items;
|
||||
|
||||
/// Height of the Material bar inside the pill (the stock bar is 80).
|
||||
static const double materialHeight = 64;
|
||||
/// Height of the Material bar inside the pill (the stock bar is 80; with
|
||||
/// labels hidden the icon and its indicator need less).
|
||||
static const double materialHeight = 56;
|
||||
|
||||
/// Height of the Cupertino bar inside the pill (the stock bar is 50).
|
||||
static const double cupertinoHeight = 54;
|
||||
/// Height of the Cupertino bar inside the pill (the stock bar's 50).
|
||||
static const double cupertinoHeight = 50;
|
||||
|
||||
/// Width of one icon-only tab on a wide window: a comfortable touch target
|
||||
/// around the Material indicator (64) or the Cupertino selection capsule.
|
||||
static const double materialTabWidth = 72;
|
||||
static const double cupertinoTabWidth = 64;
|
||||
|
||||
/// The side margin at [FloatingBarEdge.top], matching the top bar's own.
|
||||
static const double topMargin = 12;
|
||||
@@ -114,41 +124,10 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// The width the tabs need side by side: every tab as wide as the widest
|
||||
/// label (as the host lays them out), never narrower than a comfortable
|
||||
/// touch target.
|
||||
double _tabsWidth(BuildContext context) {
|
||||
final TextStyle? style;
|
||||
final TextScaler scaler;
|
||||
final double minimum;
|
||||
if (cupertino) {
|
||||
style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle;
|
||||
scaler = TextScaler.noScaling;
|
||||
minimum = 76;
|
||||
} else {
|
||||
final theme = Theme.of(context);
|
||||
style =
|
||||
theme.navigationBarTheme.labelTextStyle?.resolve(const {
|
||||
WidgetState.selected,
|
||||
}) ??
|
||||
theme.textTheme.labelMedium;
|
||||
// NavigationBar clamps its labels at 1.3x.
|
||||
scaler = MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.3);
|
||||
minimum = 88;
|
||||
}
|
||||
var widest = 0.0;
|
||||
for (final item in items) {
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(text: item.label, style: style),
|
||||
textScaler: scaler,
|
||||
textDirection: Directionality.of(context),
|
||||
maxLines: 1,
|
||||
)..layout();
|
||||
widest = math.max(widest, painter.width);
|
||||
painter.dispose();
|
||||
}
|
||||
return math.max(minimum, widest + 24) * items.length;
|
||||
}
|
||||
/// The width the icon-only tabs need side by side. Icons do not scale with
|
||||
/// text, so the pill keeps its size at any text scale.
|
||||
double _tabsWidth(BuildContext context) =>
|
||||
(cupertino ? cupertinoTabWidth : materialTabWidth) * items.length;
|
||||
|
||||
Widget _materialBar(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
@@ -159,7 +138,9 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
surfaceTintColor: Colors.transparent,
|
||||
indicatorColor: scheme.secondaryContainer,
|
||||
height: materialHeight,
|
||||
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
|
||||
// Icons only; the label remains each tab's accessible name and its
|
||||
// tooltip.
|
||||
labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
|
||||
),
|
||||
child: NavigationBar(
|
||||
selectedIndex: currentIndex,
|
||||
@@ -177,10 +158,10 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// The stock Cupertino bar, transparent inside the pill. Each tab's label is
|
||||
/// drawn with its icon (in the bar's own label style and colours) so the
|
||||
/// item's key covers the whole tab, and the selected tab's icon sits in a
|
||||
/// tinted capsule so the selection reads at a glance, not by colour alone.
|
||||
/// The stock Cupertino bar, transparent inside the pill. Each tab shows its
|
||||
/// icon only, named by its label for accessibility; the item's key covers
|
||||
/// the whole tab, and the selected tab's icon sits in a tinted capsule so
|
||||
/// the selection reads at a glance, not by colour alone.
|
||||
Widget _cupertinoBar(BuildContext context) {
|
||||
final active = CupertinoTheme.of(context).primaryColor;
|
||||
Widget tab(FloatingDestinationItem item, {required bool selected}) {
|
||||
@@ -199,14 +180,7 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
}
|
||||
return KeyedSubtree(
|
||||
key: item.key,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
icon,
|
||||
const SizedBox(height: 2),
|
||||
Text(item.label, maxLines: 1, softWrap: false),
|
||||
],
|
||||
),
|
||||
child: Semantics(label: item.label, child: icon),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -218,7 +192,7 @@ class FloatingDestinationBar extends StatelessWidget {
|
||||
// Secondary-label translucency over glass falls below text contrast
|
||||
// requirements. The host label role remains readable in both themes.
|
||||
inactiveColor: CupertinoColors.label.resolveFrom(context),
|
||||
iconSize: 24,
|
||||
iconSize: 26,
|
||||
height: cupertinoHeight,
|
||||
currentIndex: currentIndex,
|
||||
onTap: onTap,
|
||||
@@ -244,9 +218,11 @@ class FloatingDestinationItem {
|
||||
});
|
||||
|
||||
final Widget icon;
|
||||
|
||||
/// The tab's accessible name (and Material tooltip); not drawn.
|
||||
final String label;
|
||||
final Widget? selectedIcon;
|
||||
|
||||
/// Identifies the whole tab (icon and label), for tests and automation.
|
||||
/// Identifies the whole tab, for tests and automation.
|
||||
final Key? key;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user