Share one minute clock across time labels and narrow shell and runs rebuilds
Relative-time labels follow one wall-minute RelativeTimeClock instead of a timer per row, skip ticks while their tab is offstage and rebuild only when their text changes. The shell rebuilds its top bar only for the focused destination's published bar and its tab bar only for badge changes. Run events that repeat a row's state no longer notify, and the runs list filters and sorts once per build. Adds a rebuild/timer benchmark.
This commit is contained in:
@@ -140,78 +140,81 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
),
|
||||
);
|
||||
}).toList();
|
||||
return ListenableBuilder(
|
||||
listenable: _bar,
|
||||
builder: (context, _) {
|
||||
final spec = _bar.specFor(_selected);
|
||||
// One floating glass tab bar at every width: full width on a phone,
|
||||
// sized to its tabs at the right edge on a wide window (the bar judges
|
||||
// that itself, live). Content keeps the whole width and scrolls behind
|
||||
// it, learning the bar's height as its bottom media padding. Neither
|
||||
// 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 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 = 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, 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 backable(
|
||||
ShellSystemInsets(
|
||||
padding: system,
|
||||
child: CupertinoPageScaffold(
|
||||
navigationBar: topBar,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: FloatingBarOverlay(
|
||||
bar: bar,
|
||||
child: _destinationStack(contents),
|
||||
),
|
||||
),
|
||||
// Only the bar shows the registry's state, so a published bar or badge
|
||||
// rebuilds its bar alone; the destinations and scaffold stay as built.
|
||||
_bar.focus = _selected;
|
||||
// One floating glass tab bar at every width: full width on a phone,
|
||||
// sized to its tabs at the right edge on a wide window (the bar judges
|
||||
// that itself, live). Content keeps the whole width and scrolls behind
|
||||
// it, learning the bar's height as its bottom media padding. Neither
|
||||
// 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 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 bar = ListenableBuilder(
|
||||
listenable: _bar.badges,
|
||||
builder: (context, _) => 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).
|
||||
SegmentedBar currentBar() =>
|
||||
_segmentedBar(_bar.specFor(_selected), details.label, page: page);
|
||||
final topBar = _ListPaneBar(
|
||||
listenable: _bar.bar,
|
||||
initial: currentBar(),
|
||||
split: () => _bar.split(_selected),
|
||||
bar: currentBar,
|
||||
);
|
||||
// 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 backable(
|
||||
ShellSystemInsets(
|
||||
padding: system,
|
||||
child: CupertinoPageScaffold(
|
||||
navigationBar: topBar,
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: FloatingBarOverlay(
|
||||
bar: bar,
|
||||
child: _destinationStack(contents),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return backable(
|
||||
ShellSystemInsets(
|
||||
padding: system,
|
||||
child: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: topBar,
|
||||
body: _destinationStack(contents),
|
||||
extendBody: true,
|
||||
bottomNavigationBar: bar,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
return backable(
|
||||
ShellSystemInsets(
|
||||
padding: system,
|
||||
child: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: topBar,
|
||||
body: _destinationStack(contents),
|
||||
extendBody: true,
|
||||
bottomNavigationBar: bar,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -328,24 +331,38 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
/// beside an open item ([ShellPaneSplit]); the item's own bar takes the rest
|
||||
/// of the same row. The bar keeps its place in the scaffold either way, so a
|
||||
/// split never remounts it.
|
||||
///
|
||||
/// It rebuilds itself when [listenable] (the focused destination's published
|
||||
/// bar) changes; [initial] supplies the size and obstruction, which do not
|
||||
/// depend on the published contents.
|
||||
class _ListPaneBar extends StatelessWidget
|
||||
implements ObstructingPreferredSizeWidget {
|
||||
const _ListPaneBar({required this.split, required this.bar});
|
||||
const _ListPaneBar({
|
||||
required this.listenable,
|
||||
required this.initial,
|
||||
required this.split,
|
||||
required this.bar,
|
||||
});
|
||||
|
||||
final bool split;
|
||||
final SegmentedBar bar;
|
||||
final Listenable listenable;
|
||||
final SegmentedBar initial;
|
||||
final bool Function() split;
|
||||
final SegmentedBar Function() bar;
|
||||
|
||||
@override
|
||||
Size get preferredSize => bar.preferredSize;
|
||||
Size get preferredSize => initial.preferredSize;
|
||||
|
||||
@override
|
||||
bool shouldFullyObstruct(BuildContext context) =>
|
||||
bar.shouldFullyObstruct(context);
|
||||
initial.shouldFullyObstruct(context);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListPaneWidth(
|
||||
split: split,
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: bar,
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: listenable,
|
||||
builder: (context, _) => ListPaneWidth(
|
||||
split: split(),
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: bar(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user