Float glass tab bars everywhere the app has bottom tabs
One floating frosted tab bar (host NavigationBar / CupertinoTabBar in the shared GlassPill) replaces the NavigationRail, the Cupertino sidebar and the run detail, stage page and pipeline detail tab strips. Below 600px it spans the width minus 16px margins; wider it is sized to its tabs at the right edge. Content keeps the full width, scrolls behind the bar and learns its height as bottom media padding; lists pad their end clear of it and FABs sit above it. The bar now sizes itself from its own constraints instead of the screen size, which fixes the widget_test failure where a MediaQuery without a size gave it negative width constraints.
This commit is contained in:
@@ -9,6 +9,7 @@ import 'artifact_record_row.dart';
|
|||||||
import 'artifact_tile.dart';
|
import 'artifact_tile.dart';
|
||||||
import 'artifact_viewer_fetch.dart';
|
import 'artifact_viewer_fetch.dart';
|
||||||
import 'artifact_row_labels.dart';
|
import 'artifact_row_labels.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
export 'artifact_row_labels.dart'
|
export 'artifact_row_labels.dart'
|
||||||
show
|
show
|
||||||
@@ -141,7 +142,10 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CustomScrollView(slivers: slivers);
|
// Clear of a floating tab bar when the gallery is a tab.
|
||||||
|
return CustomScrollView(
|
||||||
|
slivers: [...slivers, const SliverFloatingBarClearance()],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One collapsible section: its title stays pinned at the top while its
|
/// One collapsible section: its title stays pinned at the top while its
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'capture_section.dart';
|
|||||||
import 'change_style.dart';
|
import 'change_style.dart';
|
||||||
import 'file_diff_viewer.dart';
|
import 'file_diff_viewer.dart';
|
||||||
import 'visit_pager.dart';
|
import 'visit_pager.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The run's Changes surface: an honest final-state summary followed by the
|
/// The run's Changes surface: an honest final-state summary followed by the
|
||||||
/// recorded stage/visit captures, with changed-filename filtering and the
|
/// recorded stage/visit captures, with changed-filename filtering and the
|
||||||
@@ -148,7 +149,10 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: run.files.isEmpty
|
child: run.files.isEmpty
|
||||||
? SingleChildScrollView(
|
? SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: withFloatingBarClearance(
|
||||||
|
context,
|
||||||
|
const EdgeInsets.all(16),
|
||||||
|
),
|
||||||
child: Text(noChangeDetail(run)),
|
child: Text(noChangeDetail(run)),
|
||||||
)
|
)
|
||||||
: ListView(
|
: ListView(
|
||||||
@@ -171,7 +175,10 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: visit == null
|
child: visit == null
|
||||||
? SingleChildScrollView(
|
? SingleChildScrollView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: withFloatingBarClearance(
|
||||||
|
context,
|
||||||
|
const EdgeInsets.all(16),
|
||||||
|
),
|
||||||
child: Text(noChangeDetail(run)),
|
child: Text(noChangeDetail(run)),
|
||||||
)
|
)
|
||||||
: SingleChildScrollView(
|
: SingleChildScrollView(
|
||||||
@@ -180,6 +187,7 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
|||||||
key: ValueKey<String>(
|
key: ValueKey<String>(
|
||||||
'changes-visit-${visit.stage}-${visit.sequence}',
|
'changes-visit-${visit.stage}-${visit.sequence}',
|
||||||
),
|
),
|
||||||
|
padding: withFloatingBarClearance(context, EdgeInsets.zero),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'chat_sessions_body.dart';
|
|||||||
import 'session_actions.dart';
|
import 'session_actions.dart';
|
||||||
import 'session_row_content.dart';
|
import 'session_row_content.dart';
|
||||||
import 'session_row_style.dart';
|
import 'session_row_style.dart';
|
||||||
|
import '../../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
class CupertinoSessionList extends StatelessWidget {
|
class CupertinoSessionList extends StatelessWidget {
|
||||||
const CupertinoSessionList({
|
const CupertinoSessionList({
|
||||||
@@ -47,7 +48,10 @@ class CupertinoSessionList extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: const EdgeInsets.only(bottom: 24),
|
padding: withFloatingBarClearance(
|
||||||
|
context,
|
||||||
|
const EdgeInsets.only(bottom: 24),
|
||||||
|
),
|
||||||
children: [
|
children: [
|
||||||
for (final section in sections) ..._section(section),
|
for (final section in sections) ..._section(section),
|
||||||
if (emptyMessage != null)
|
if (emptyMessage != null)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
import '../../graph/domain/graph_definition.dart';
|
import '../../graph/domain/graph_definition.dart';
|
||||||
import '../../graph/widgets/stage_definition_view.dart';
|
import '../../graph/widgets/stage_definition_view.dart';
|
||||||
import '../pipeline_models.dart';
|
import '../pipeline_models.dart';
|
||||||
@@ -100,11 +101,10 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
|||||||
final panel = LayoutBuilder(
|
final panel = LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final headerLimit = _headerLimit(constraints);
|
final headerLimit = _headerLimit(constraints);
|
||||||
// On a phone the tabs are a bottom bar, as in the run detail.
|
// The tabs float over the bottom of the tab body, as in the run
|
||||||
final bottomTabs = constraints.maxWidth < 600;
|
// detail: full width on a phone, at the right edge of a wide pane.
|
||||||
final tabs = PipelineDetailTabs(
|
final tabs = PipelineDetailTabs(
|
||||||
selected: _tab,
|
selected: _tab,
|
||||||
bottom: bottomTabs,
|
|
||||||
onSelected: (tab) => setState(() => _tab = tab),
|
onSelected: (tab) => setState(() => _tab = tab),
|
||||||
);
|
);
|
||||||
return Column(
|
return Column(
|
||||||
@@ -130,7 +130,6 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
|||||||
message: _controller.detailError!,
|
message: _controller.detailError!,
|
||||||
onRetry: _controller.retryDetail,
|
onRetry: _controller.retryDetail,
|
||||||
),
|
),
|
||||||
if (!bottomTabs) tabs,
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -139,36 +138,40 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
|||||||
// scroll their own content; the graph fills the slot so its canvas
|
// scroll their own content; the graph fills the slot so its canvas
|
||||||
// is never asked for an unbounded extent inside a scroll view.
|
// is never asked for an unbounded extent inside a scroll view.
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Stack(
|
child: FloatingBarOverlay(
|
||||||
children: [
|
bar: tabs,
|
||||||
Positioned.fill(
|
child: Builder(
|
||||||
child: switch (_tab) {
|
builder: (context) => Stack(
|
||||||
PipelineDetailTab.summary => _scrolling(
|
children: [
|
||||||
PipelineSummaryView(
|
Positioned.fill(
|
||||||
controller: _controller,
|
child: switch (_tab) {
|
||||||
detail: detail,
|
PipelineDetailTab.summary => _scrolling(
|
||||||
gateway: widget.gateway,
|
PipelineSummaryView(
|
||||||
),
|
controller: _controller,
|
||||||
|
detail: detail,
|
||||||
|
gateway: widget.gateway,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
PipelineDetailTab.graph => PipelineGraphTab(
|
||||||
|
detail: detail,
|
||||||
|
selectedStage: _graphSelection,
|
||||||
|
onSelected: (stageKey) =>
|
||||||
|
_openGraphStage(context, detail, stageKey),
|
||||||
|
),
|
||||||
|
PipelineDetailTab.source => _source(context, detail),
|
||||||
|
},
|
||||||
),
|
),
|
||||||
PipelineDetailTab.graph => PipelineGraphTab(
|
// Run and Runs float over the content, above the tabs.
|
||||||
detail: detail,
|
PositionedDirectional(
|
||||||
selectedStage: _graphSelection,
|
end: 16,
|
||||||
onSelected: (stageKey) =>
|
bottom: 16 + MediaQuery.paddingOf(context).bottom,
|
||||||
_openGraphStage(context, detail, stageKey),
|
child: _fabs(context, detail),
|
||||||
),
|
),
|
||||||
PipelineDetailTab.source => _source(context, detail),
|
],
|
||||||
},
|
|
||||||
),
|
),
|
||||||
// Run and Runs float over the content, above the tabs.
|
),
|
||||||
PositionedDirectional(
|
|
||||||
end: 16,
|
|
||||||
bottom: 16,
|
|
||||||
child: _fabs(context, detail),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (bottomTabs) SafeArea(top: false, child: tabs),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -391,7 +394,7 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
|||||||
|
|
||||||
Widget _source(BuildContext context, PipelineDetail detail) {
|
Widget _source(BuildContext context, PipelineDetail detail) {
|
||||||
return ListView(
|
return ListView(
|
||||||
padding: const EdgeInsets.all(16),
|
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
|
||||||
children: [
|
children: [
|
||||||
if (detail.source.isEmpty)
|
if (detail.source.isEmpty)
|
||||||
Text('No source recorded.', style: pipelineMutedStyle(context))
|
Text('No source recorded.', style: pipelineMutedStyle(context))
|
||||||
|
|||||||
@@ -1,150 +1,45 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/floating_destination_bar.dart';
|
||||||
import 'pipeline_controls.dart';
|
import 'pipeline_controls.dart';
|
||||||
import 'pipeline_detail_tab.dart';
|
import 'pipeline_detail_tab.dart';
|
||||||
|
|
||||||
export 'pipeline_detail_tab.dart';
|
export 'pipeline_detail_tab.dart';
|
||||||
|
|
||||||
/// Platform tabs: a Material segmented button or a Cupertino segmented control.
|
/// The pipeline detail's tabs: the app's floating glass tab bar, full width on
|
||||||
|
/// a phone and sized to its tabs at the right edge of a wide pane.
|
||||||
///
|
///
|
||||||
/// Keep the native control at every width. Horizontal scrolling gives scaled
|
/// Float it over the tab body with `FloatingBarOverlay`. The whole bar is
|
||||||
/// labels their intrinsic width instead of squeezing or replacing the control.
|
/// keyed `pipeline-detail-tabs`, each tab `pipeline-detail-tab-<name>`.
|
||||||
class PipelineDetailTabs extends StatelessWidget {
|
class PipelineDetailTabs extends StatelessWidget {
|
||||||
const PipelineDetailTabs({
|
const PipelineDetailTabs({
|
||||||
super.key,
|
super.key,
|
||||||
required this.selected,
|
required this.selected,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
this.bottom = false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/// The phone layout: a full-width bar under the content, with icons.
|
|
||||||
final bool bottom;
|
|
||||||
|
|
||||||
final PipelineDetailTab selected;
|
final PipelineDetailTab selected;
|
||||||
final ValueChanged<PipelineDetailTab> onSelected;
|
final ValueChanged<PipelineDetailTab> onSelected;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = useCupertinoControls(context);
|
final cupertino = useCupertinoControls(context);
|
||||||
if (bottom) {
|
const tabs = PipelineDetailTab.values;
|
||||||
final divider = cupertino
|
return KeyedSubtree(
|
||||||
? CupertinoColors.separator.resolveFrom(context)
|
key: const Key('pipeline-detail-tabs'),
|
||||||
: Theme.of(context).colorScheme.outlineVariant;
|
child: FloatingDestinationBar(
|
||||||
return DecoratedBox(
|
cupertino: cupertino,
|
||||||
decoration: BoxDecoration(
|
currentIndex: tabs.indexOf(selected),
|
||||||
border: Border(top: BorderSide(color: divider, width: 0.5)),
|
onTap: (value) => onSelected(tabs[value]),
|
||||||
),
|
items: [
|
||||||
child: Padding(
|
for (final tab in tabs)
|
||||||
padding: const EdgeInsets.all(8),
|
FloatingDestinationItem(
|
||||||
child: SizedBox(
|
key: ValueKey('pipeline-detail-tab-${tab.name}'),
|
||||||
width: double.infinity,
|
icon: Icon(cupertino ? tab.cupertinoIcon : tab.icon),
|
||||||
child: KeyedSubtree(
|
label: tab.label,
|
||||||
key: const Key('pipeline-detail-tabs'),
|
|
||||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
||||||
child: _ScrollWhenOverflowing(
|
|
||||||
child: KeyedSubtree(
|
|
||||||
key: const Key('pipeline-detail-tabs'),
|
|
||||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _materialControl() {
|
|
||||||
return SegmentedButton<PipelineDetailTab>(
|
|
||||||
segments: [
|
|
||||||
for (final tab in PipelineDetailTab.values)
|
|
||||||
ButtonSegment(value: tab, label: _label(tab)),
|
|
||||||
],
|
|
||||||
selected: {selected},
|
|
||||||
showSelectedIcon: false,
|
|
||||||
expandedInsets: bottom ? EdgeInsets.zero : null,
|
|
||||||
onSelectionChanged: (selection) => onSelected(selection.single),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _cupertinoControl() {
|
|
||||||
return CupertinoSegmentedControl<PipelineDetailTab>(
|
|
||||||
// The strip already insets 16; the control's default inset would push
|
|
||||||
// the tabs out of line with the content.
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
groupValue: selected,
|
|
||||||
onValueChanged: onSelected,
|
|
||||||
children: {
|
|
||||||
for (final tab in PipelineDetailTab.values)
|
|
||||||
tab: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
child: _label(tab),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _label(PipelineDetailTab tab) {
|
|
||||||
// One line, and let the control size the segment to the whole word rather
|
|
||||||
// than wrapping inside it when scaled text is wider than the pane.
|
|
||||||
final text = Text(tab.label, maxLines: 1, softWrap: false);
|
|
||||||
if (!bottom) return text;
|
|
||||||
return FittedBox(
|
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Builder(
|
|
||||||
builder: (context) => Icon(
|
|
||||||
useCupertinoControls(context) ? tab.cupertinoIcon : tab.icon,
|
|
||||||
size: 18,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
text,
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gives [child] the full available width as a minimum, then scrolls instead of
|
|
||||||
/// squeezing it below its content width.
|
|
||||||
class _ScrollWhenOverflowing extends StatelessWidget {
|
|
||||||
const _ScrollWhenOverflowing({required this.child});
|
|
||||||
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
if (!constraints.hasBoundedWidth) return child;
|
|
||||||
return ScrollConfiguration(
|
|
||||||
// Desktop pointer scrolling is vertical only, so allow dragging the
|
|
||||||
// tab row with a mouse as well as touch and trackpad.
|
|
||||||
behavior: ScrollConfiguration.of(context).copyWith(
|
|
||||||
dragDevices: const {
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.stylus,
|
|
||||||
PointerDeviceKind.invertedStylus,
|
|
||||||
PointerDeviceKind.trackpad,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(minWidth: constraints.maxWidth),
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import 'run_field_body.dart';
|
|||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import '../../../ui/layout/sticky_section.dart';
|
import '../../../ui/layout/sticky_section.dart';
|
||||||
import '../../../ui/text/monospace.dart';
|
import '../../../ui/text/monospace.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The Summary tab: the run's identity, the recorded facts as key/value rows,
|
/// The Summary tab: the run's identity, the recorded facts as key/value rows,
|
||||||
/// the stored original prompt with its copy control and the collapsible Input
|
/// the stored original prompt with its copy control and the collapsible Input
|
||||||
@@ -99,6 +100,7 @@ Widget runDetailSummaryTab({
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SliverToBoxAdapter(child: SizedBox(height: 16)),
|
const SliverToBoxAdapter(child: SizedBox(height: 16)),
|
||||||
|
const SliverFloatingBarClearance(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -198,6 +200,7 @@ Widget runDetailFieldTab({
|
|||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return ListView(
|
return ListView(
|
||||||
key: Key('run-detail-tab-body-$tabKey'),
|
key: Key('run-detail-tab-body-$tabKey'),
|
||||||
|
// Clear of a floating tab bar (the list pads its media insets itself).
|
||||||
children: [
|
children: [
|
||||||
CupertinoListSection.insetGrouped(
|
CupertinoListSection.insetGrouped(
|
||||||
backgroundColor: AppColors.groupedBackground,
|
backgroundColor: AppColors.groupedBackground,
|
||||||
@@ -206,10 +209,12 @@ Widget runDetailFieldTab({
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ListView(
|
return Builder(
|
||||||
key: Key('run-detail-tab-body-$tabKey'),
|
builder: (context) => ListView(
|
||||||
padding: const EdgeInsets.all(16),
|
key: Key('run-detail-tab-body-$tabKey'),
|
||||||
children: [body],
|
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
|
||||||
|
children: [body],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/floating_destination_bar.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import 'run_detail_tab.dart';
|
import 'run_detail_tab.dart';
|
||||||
|
|
||||||
/// The tabs the strip renders, in the web's order: Summary first so it is the
|
/// The tabs the strip renders, in the web's order: Summary first so it is the
|
||||||
/// default, then the run Graph and the Timeline. Input and Output are
|
/// default, then the Timeline, the run's Artifacts and its Changes. Input and
|
||||||
/// collapsible Summary sections now, so their stable enum keys stay available
|
/// Output are collapsible Summary sections now, so their stable enum keys stay
|
||||||
/// for old routes but they are not separate tabs.
|
/// available for old routes but they are not separate tabs. The graph is a
|
||||||
/// The graph is a preview on Summary that opens full screen, so it has no tab
|
/// preview on Summary that opens full screen, so it has no tab of its own.
|
||||||
/// of its own; the run's artifacts and changes do.
|
|
||||||
const List<RunDetailTab> renderedRunDetailTabs = [
|
const List<RunDetailTab> renderedRunDetailTabs = [
|
||||||
RunDetailTab.summary,
|
RunDetailTab.summary,
|
||||||
RunDetailTab.timeline,
|
RunDetailTab.timeline,
|
||||||
@@ -18,20 +16,19 @@ const List<RunDetailTab> renderedRunDetailTabs = [
|
|||||||
RunDetailTab.changes,
|
RunDetailTab.changes,
|
||||||
];
|
];
|
||||||
|
|
||||||
/// The run detail's platform tab strip: a Material segmented button or a
|
/// The run detail's tabs: the app's floating glass tab bar, full width on a
|
||||||
/// Cupertino segmented control, in the web's Summary/Graph/Timeline order.
|
/// phone and sized to its tabs at the right edge of a wide pane.
|
||||||
///
|
///
|
||||||
/// The native control keeps every label at its intrinsic width: a narrow pane
|
/// Float it over the tab body with `FloatingBarOverlay`; every tab is always
|
||||||
/// or scaled text scrolls the strip horizontally instead of squeezing or
|
/// visible, so a tab selected by the Graph is shown selected without
|
||||||
/// wrapping the words. A tab selected by the Graph (not tapped in the strip)
|
/// scrolling. The whole bar is keyed `run-detail-tabs`, each tab
|
||||||
/// is scrolled into view, so the operator can see which section is selected.
|
/// `run-detail-tab-<name>`.
|
||||||
class RunDetailTabStrip extends StatefulWidget {
|
class RunDetailTabStrip extends StatelessWidget {
|
||||||
const RunDetailTabStrip({
|
const RunDetailTabStrip({
|
||||||
super.key,
|
super.key,
|
||||||
required this.selected,
|
required this.selected,
|
||||||
required this.onSelected,
|
required this.onSelected,
|
||||||
this.tabs = renderedRunDetailTabs,
|
this.tabs = renderedRunDetailTabs,
|
||||||
this.bottom = false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final RunDetailTab selected;
|
final RunDetailTab selected;
|
||||||
@@ -40,162 +37,25 @@ class RunDetailTabStrip extends StatefulWidget {
|
|||||||
/// The tabs this run offers, in [renderedRunDetailTabs] order.
|
/// The tabs this run offers, in [renderedRunDetailTabs] order.
|
||||||
final List<RunDetailTab> tabs;
|
final List<RunDetailTab> tabs;
|
||||||
|
|
||||||
/// The phone layout: a full-width bar under the content instead of a compact
|
|
||||||
/// strip under the header.
|
|
||||||
final bool bottom;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<RunDetailTabStrip> createState() => _RunDetailTabStripState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _RunDetailTabStripState extends State<RunDetailTabStrip> {
|
|
||||||
final Map<RunDetailTab, GlobalKey> _labels = {
|
|
||||||
for (final tab in renderedRunDetailTabs) tab: GlobalKey(),
|
|
||||||
};
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(covariant RunDetailTabStrip oldWidget) {
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
if (oldWidget.selected == widget.selected) return;
|
|
||||||
// The Graph can select Timeline without a strip tap. Wait for the new
|
|
||||||
// segment to be laid out, then reveal it inside the strip's own scroll.
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
||||||
if (!mounted) return;
|
|
||||||
final context = _labels[widget.selected]?.currentContext;
|
|
||||||
if (context == null) return;
|
|
||||||
Scrollable.ensureVisible(
|
|
||||||
context,
|
|
||||||
alignment: 0.5,
|
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
final cupertino = usesCupertinoHost(context);
|
||||||
if (widget.bottom) {
|
final index = tabs.indexOf(selected);
|
||||||
final divider = cupertino
|
return KeyedSubtree(
|
||||||
? CupertinoColors.separator.resolveFrom(context)
|
key: const Key('run-detail-tabs'),
|
||||||
: Theme.of(context).colorScheme.outlineVariant;
|
child: FloatingDestinationBar(
|
||||||
return DecoratedBox(
|
cupertino: cupertino,
|
||||||
decoration: BoxDecoration(
|
currentIndex: index < 0 ? 0 : index,
|
||||||
border: Border(top: BorderSide(color: divider, width: 0.5)),
|
onTap: (value) => onSelected(tabs[value]),
|
||||||
),
|
items: [
|
||||||
child: Padding(
|
for (final tab in tabs)
|
||||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
|
FloatingDestinationItem(
|
||||||
child: SizedBox(
|
key: ValueKey('run-detail-tab-${tab.name}'),
|
||||||
width: double.infinity,
|
icon: Icon(cupertino ? tab.cupertinoIcon : tab.icon),
|
||||||
child: KeyedSubtree(
|
label: tab.label,
|
||||||
key: const Key('run-detail-tabs'),
|
|
||||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
||||||
child: ScrollWhenOverflowing(
|
|
||||||
child: KeyedSubtree(
|
|
||||||
key: const Key('run-detail-tabs'),
|
|
||||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _materialControl() => SegmentedButton<RunDetailTab>(
|
|
||||||
segments: [
|
|
||||||
for (final tab in widget.tabs)
|
|
||||||
ButtonSegment(value: tab, label: _label(tab)),
|
|
||||||
],
|
|
||||||
selected: {widget.selected},
|
|
||||||
showSelectedIcon: false,
|
|
||||||
// The bottom bar spans the width; the header strip keeps its content size.
|
|
||||||
expandedInsets: widget.bottom ? EdgeInsets.zero : null,
|
|
||||||
onSelectionChanged: (selection) => widget.onSelected(selection.single),
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _cupertinoControl() => CupertinoSegmentedControl<RunDetailTab>(
|
|
||||||
// The strip already insets 16; the control's own default inset would put
|
|
||||||
// the tabs out of line with the header and body text.
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
groupValue: widget.selected,
|
|
||||||
onValueChanged: widget.onSelected,
|
|
||||||
children: {
|
|
||||||
for (final tab in widget.tabs)
|
|
||||||
tab: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
||||||
child: _label(tab),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _label(RunDetailTab tab) => KeyedSubtree(
|
|
||||||
key: _labels[tab],
|
|
||||||
child: KeyedSubtree(
|
|
||||||
key: ValueKey('run-detail-tab-${tab.name}'),
|
|
||||||
// A full-width bar shrinks a long label rather than overflowing it,
|
|
||||||
// and shows the tab's glyph above its name.
|
|
||||||
child: widget.bottom
|
|
||||||
? FittedBox(
|
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Icon(
|
|
||||||
usesCupertinoHost(context) ? tab.cupertinoIcon : tab.icon,
|
|
||||||
size: 18,
|
|
||||||
),
|
|
||||||
Text(tab.label, maxLines: 1, softWrap: false),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Text(tab.label, maxLines: 1, softWrap: false),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gives [child] at least the pane width, then scrolls instead of squeezing it
|
|
||||||
/// below its content width.
|
|
||||||
///
|
|
||||||
/// The run detail's tab strips both use this, so the pointer-drag rule and the
|
|
||||||
/// minimum-width rule live in one place.
|
|
||||||
class ScrollWhenOverflowing extends StatelessWidget {
|
|
||||||
const ScrollWhenOverflowing({super.key, required this.child});
|
|
||||||
|
|
||||||
final Widget child;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
if (!constraints.hasBoundedWidth) return child;
|
|
||||||
return ScrollConfiguration(
|
|
||||||
// Desktop pointer scrolling is vertical only, so a mouse can drag
|
|
||||||
// the tab row as well as touch and trackpad.
|
|
||||||
behavior: ScrollConfiguration.of(context).copyWith(
|
|
||||||
dragDevices: const {
|
|
||||||
PointerDeviceKind.touch,
|
|
||||||
PointerDeviceKind.mouse,
|
|
||||||
PointerDeviceKind.stylus,
|
|
||||||
PointerDeviceKind.invertedStylus,
|
|
||||||
PointerDeviceKind.trackpad,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
child: SingleChildScrollView(
|
|
||||||
scrollDirection: Axis.horizontal,
|
|
||||||
child: ConstrainedBox(
|
|
||||||
// Content width, not the pane width: the web's tabs are compact
|
|
||||||
// and left-aligned, not a full-width segmented bar. The scroll
|
|
||||||
// view still reveals every segment on a narrow pane.
|
|
||||||
constraints: const BoxConstraints(),
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
import '../../../ui/adaptive/segmented_bar.dart';
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
@@ -28,11 +29,8 @@ import 'run_search_selection.dart';
|
|||||||
/// reserve keeps its bounded canvas positive at 320px with 2x text.
|
/// reserve keeps its bounded canvas positive at 320px with 2x text.
|
||||||
const double kRunDetailMinContentHeight = 240;
|
const double kRunDetailMinContentHeight = 240;
|
||||||
|
|
||||||
/// Below this width (a phone) the run detail's tabs sit at the bottom.
|
/// The run detail's tabbed body: the host-built header above the bounded
|
||||||
const double kRunDetailBottomTabsWidth = 600;
|
/// selected tab, with the floating tab bar over the bottom of the tab.
|
||||||
|
|
||||||
/// The run detail's tabbed body: the host-built header and platform tab strip
|
|
||||||
/// above the bounded selected tab.
|
|
||||||
///
|
///
|
||||||
/// The Graph tab fills its slot with [RunGraphView] from the run's own pinned
|
/// The Graph tab fills its slot with [RunGraphView] from the run's own pinned
|
||||||
/// graph and recorded steps. A visited stage click selects that stage's latest
|
/// graph and recorded steps. A visited stage click selects that stage's latest
|
||||||
@@ -369,14 +367,6 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
|||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final headerLimit = _headerLimit(constraints);
|
final headerLimit = _headerLimit(constraints);
|
||||||
// On a phone the tabs are a bottom bar, under the content they switch.
|
|
||||||
final bottomTabs = constraints.maxWidth < kRunDetailBottomTabsWidth;
|
|
||||||
final strip = RunDetailTabStrip(
|
|
||||||
tabs: tabs,
|
|
||||||
selected: shown,
|
|
||||||
bottom: bottomTabs,
|
|
||||||
onSelected: (tab) => setState(() => _tab = tab),
|
|
||||||
);
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: [
|
children: [
|
||||||
@@ -384,20 +374,24 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
|||||||
constraints: BoxConstraints(maxHeight: headerLimit),
|
constraints: BoxConstraints(maxHeight: headerLimit),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
key: ValueKey('run-detail-header-${widget.run['id']}'),
|
key: ValueKey('run-detail-header-${widget.run['id']}'),
|
||||||
child: Column(
|
child: widget.header,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [widget.header, if (!bottomTabs) strip],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Every tab gets the bounded remaining height. The scrolling tabs
|
// Every tab gets the bounded remaining height. The scrolling tabs
|
||||||
// own their content; the Graph tab fills the slot so its canvas is
|
// own their content; the Graph tab fills the slot so its canvas is
|
||||||
// never asked for an unbounded extent.
|
// never asked for an unbounded extent. The tabs float over the
|
||||||
|
// bottom of it, and the tab learns their height as bottom padding.
|
||||||
Expanded(
|
Expanded(
|
||||||
key: ValueKey('run-detail-body-${widget.run['id']}'),
|
key: ValueKey('run-detail-body-${widget.run['id']}'),
|
||||||
child: _body(shown),
|
child: FloatingBarOverlay(
|
||||||
|
bar: RunDetailTabStrip(
|
||||||
|
tabs: tabs,
|
||||||
|
selected: shown,
|
||||||
|
onSelected: (tab) => setState(() => _tab = tab),
|
||||||
|
),
|
||||||
|
child: _body(shown),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (bottomTabs) SafeArea(top: false, child: strip),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
|||||||
import '../../../ui/status/run_status_icon.dart';
|
import '../../../ui/status/run_status_icon.dart';
|
||||||
import '../domain/run_models.dart';
|
import '../domain/run_models.dart';
|
||||||
import 'run_detail_content.dart';
|
import 'run_detail_content.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The Timeline tab's recorded visits, one native row per visit.
|
/// The Timeline tab's recorded visits, one native row per visit.
|
||||||
///
|
///
|
||||||
@@ -33,7 +34,7 @@ class RunTimelineList extends StatelessWidget {
|
|||||||
if (visits.isEmpty) {
|
if (visits.isEmpty) {
|
||||||
return ListView(
|
return ListView(
|
||||||
key: const Key('run-detail-tab-body-timeline'),
|
key: const Key('run-detail-tab-body-timeline'),
|
||||||
padding: const EdgeInsets.all(16),
|
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
|
||||||
children: const [Text('No visits recorded.')],
|
children: const [Text('No visits recorded.')],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -63,7 +64,10 @@ class RunTimelineList extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return ListView(
|
return ListView(
|
||||||
key: const Key('run-detail-tab-body-timeline'),
|
key: const Key('run-detail-tab-body-timeline'),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
padding: withFloatingBarClearance(
|
||||||
|
context,
|
||||||
|
const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
),
|
||||||
children: rows,
|
children: rows,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import 'run_detail_content.dart';
|
import 'run_detail_content.dart';
|
||||||
import 'run_detail_visit_facts.dart';
|
import 'run_detail_visit_facts.dart';
|
||||||
@@ -105,26 +106,26 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
// The sections are floating tabs over the bottom of what they
|
||||||
|
// show; the section learns their height as bottom padding.
|
||||||
Expanded(
|
Expanded(
|
||||||
child: runVisitSectionBody(
|
child: FloatingBarOverlay(
|
||||||
section: _section,
|
bar: RunVisitSectionStrip(
|
||||||
run: widget.run,
|
selected: _section,
|
||||||
step: widget.step,
|
onSelected: (section) => setState(() => _section = section),
|
||||||
visitIndex: widget.visitIndex,
|
),
|
||||||
stageKey: widget.visit.stage,
|
child: runVisitSectionBody(
|
||||||
runSteps: widget.runSteps,
|
section: _section,
|
||||||
gateway: widget.gateway,
|
run: widget.run,
|
||||||
onRunChanged: widget.onRunChanged,
|
step: widget.step,
|
||||||
configuredEndpoint: widget.configuredEndpoint,
|
visitIndex: widget.visitIndex,
|
||||||
cupertino: widget.cupertino,
|
stageKey: widget.visit.stage,
|
||||||
),
|
runSteps: widget.runSteps,
|
||||||
),
|
gateway: widget.gateway,
|
||||||
// The sections are tabs at the bottom, under what they show.
|
onRunChanged: widget.onRunChanged,
|
||||||
SafeArea(
|
configuredEndpoint: widget.configuredEndpoint,
|
||||||
top: false,
|
cupertino: widget.cupertino,
|
||||||
child: RunVisitSectionStrip(
|
),
|
||||||
selected: _section,
|
|
||||||
onSelected: (section) => setState(() => _section = section),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
|
import '../../../ui/adaptive/floating_destination_bar.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
import '../../changes/changes.dart';
|
import '../../changes/changes.dart';
|
||||||
import 'run_detail_tab_bodies.dart';
|
import 'run_detail_tab_bodies.dart';
|
||||||
@@ -12,6 +13,7 @@ import 'run_detail_visit_artifacts.dart';
|
|||||||
import 'run_detail_visit_definition.dart';
|
import 'run_detail_visit_definition.dart';
|
||||||
import 'run_detail_visit_facts.dart';
|
import 'run_detail_visit_facts.dart';
|
||||||
import 'run_detail_visit_session.dart';
|
import 'run_detail_visit_session.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The visit pane's recorded sections, in the Android audit order the web
|
/// The visit pane's recorded sections, in the Android audit order the web
|
||||||
/// client follows: the turn's Input and Output, its Artifacts, the files this
|
/// client follows: the turn's Input and Output, its Artifacts, the files this
|
||||||
@@ -43,9 +45,10 @@ enum RunVisitSection {
|
|||||||
final IconData cupertinoIcon;
|
final IconData cupertinoIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The visit pane's native tab strip: a Material segmented button or a Cupertino
|
/// The stage page's tabs: the app's floating glass tab bar, full width on a
|
||||||
/// segmented control. It scrolls instead of squeezing the labels when a narrow
|
/// phone and sized to its tabs at the right edge of a wide pane. Float it over
|
||||||
/// pane or scaled text cannot fit them.
|
/// the section with `FloatingBarOverlay`. The whole bar is keyed
|
||||||
|
/// `run-visit-tabs`, each tab `run-visit-tab-<name>`.
|
||||||
class RunVisitSectionStrip extends StatelessWidget {
|
class RunVisitSectionStrip extends StatelessWidget {
|
||||||
const RunVisitSectionStrip({
|
const RunVisitSectionStrip({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -59,72 +62,24 @@ class RunVisitSectionStrip extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
final cupertino = usesCupertinoHost(context);
|
||||||
// A full-width bar under the section, as the run's own tabs on a phone.
|
final index = shownVisitSections.indexOf(visitTabFor(selected));
|
||||||
final divider = cupertino
|
return KeyedSubtree(
|
||||||
? CupertinoColors.separator.resolveFrom(context)
|
key: const Key('run-visit-tabs'),
|
||||||
: Theme.of(context).colorScheme.outlineVariant;
|
child: FloatingDestinationBar(
|
||||||
return DecoratedBox(
|
cupertino: cupertino,
|
||||||
decoration: BoxDecoration(
|
currentIndex: index < 0 ? 0 : index,
|
||||||
border: Border(top: BorderSide(color: divider, width: 0.5)),
|
onTap: (value) => onSelected(shownVisitSections[value]),
|
||||||
),
|
items: [
|
||||||
child: Padding(
|
for (final section in shownVisitSections)
|
||||||
padding: const EdgeInsets.fromLTRB(8, 8, 8, 8),
|
FloatingDestinationItem(
|
||||||
child: SizedBox(
|
key: ValueKey('run-visit-tab-${section.name}'),
|
||||||
width: double.infinity,
|
icon: Icon(cupertino ? section.cupertinoIcon : section.icon),
|
||||||
child: KeyedSubtree(
|
label: section.label,
|
||||||
key: const Key('run-visit-tabs'),
|
),
|
||||||
child: cupertino ? _cupertinoControl() : _materialControl(),
|
],
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _materialControl() => SegmentedButton<RunVisitSection>(
|
|
||||||
segments: [
|
|
||||||
for (final section in shownVisitSections)
|
|
||||||
ButtonSegment(value: section, label: _label(section)),
|
|
||||||
],
|
|
||||||
selected: {selected},
|
|
||||||
showSelectedIcon: false,
|
|
||||||
expandedInsets: EdgeInsets.zero,
|
|
||||||
onSelectionChanged: (selection) => onSelected(selection.single),
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _cupertinoControl() => CupertinoSegmentedControl<RunVisitSection>(
|
|
||||||
// The strip already insets 16; the control's default inset would push
|
|
||||||
// the tabs out of line with the content.
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
groupValue: selected,
|
|
||||||
onValueChanged: onSelected,
|
|
||||||
children: {
|
|
||||||
for (final section in shownVisitSections)
|
|
||||||
section: Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 2),
|
|
||||||
child: _label(section),
|
|
||||||
),
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
Widget _label(RunVisitSection section) => KeyedSubtree(
|
|
||||||
key: ValueKey('run-visit-tab-${section.name}'),
|
|
||||||
// Six sections share the width; a long label shrinks rather than clips.
|
|
||||||
child: FittedBox(
|
|
||||||
fit: BoxFit.scaleDown,
|
|
||||||
child: Column(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Builder(
|
|
||||||
builder: (context) => Icon(
|
|
||||||
usesCupertinoHost(context) ? section.cupertinoIcon : section.icon,
|
|
||||||
size: 18,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Text(section.label, maxLines: 1, softWrap: false),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The stage page's tabs: Summary (Input and Output), Artifacts, Changes and
|
/// The stage page's tabs: Summary (Input and Output), Artifacts, Changes and
|
||||||
@@ -298,6 +253,7 @@ class _VisitSummaryState extends State<_VisitSummary> {
|
|||||||
slivers: [
|
slivers: [
|
||||||
_section('Input', widget.input, visitEmptyInput),
|
_section('Input', widget.input, visitEmptyInput),
|
||||||
_section('Output', widget.output, visitEmptyOutput),
|
_section('Output', widget.output, visitEmptyOutput),
|
||||||
|
const SliverFloatingBarClearance(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import '../actions/session_export_repair_action.dart';
|
|||||||
import 'run_detail_visit_recorded.dart';
|
import 'run_detail_visit_recorded.dart';
|
||||||
import 'run_detail_visit_documents.dart';
|
import 'run_detail_visit_documents.dart';
|
||||||
import 'run_detail_visit_session_state.dart';
|
import 'run_detail_visit_session_state.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The visit's recorded session pointer, its recorded export state and, when
|
/// The visit's recorded session pointer, its recorded export state and, when
|
||||||
/// the visit exported one, a read-only external open of that document.
|
/// the visit exported one, a read-only external open of that document.
|
||||||
@@ -133,7 +134,7 @@ class _RunVisitSessionState extends State<RunVisitSession> {
|
|||||||
}
|
}
|
||||||
return ListView(
|
return ListView(
|
||||||
key: const Key('run-visit-body-session'),
|
key: const Key('run-visit-body-session'),
|
||||||
padding: const EdgeInsets.all(16),
|
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
|
||||||
children: _spaced(children),
|
children: _spaced(children),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _materialScreen() {
|
Widget _materialScreen() {
|
||||||
|
// Results scroll behind a floating tab bar; the list clears it itself.
|
||||||
final body = SafeArea(
|
final body = SafeArea(
|
||||||
|
bottom: false,
|
||||||
child: SearchArtifactScope(
|
child: SearchArtifactScope(
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
onOpen: widget.onOpen,
|
onOpen: widget.onOpen,
|
||||||
@@ -192,6 +194,7 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
|
|
||||||
Widget _cupertinoScreen() {
|
Widget _cupertinoScreen() {
|
||||||
final body = SafeArea(
|
final body = SafeArea(
|
||||||
|
bottom: false,
|
||||||
child: SearchArtifactScope(
|
child: SearchArtifactScope(
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
onOpen: widget.onOpen,
|
onOpen: widget.onOpen,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import '../../../core/api_gateway.dart';
|
|||||||
import '../domain/search_controller.dart';
|
import '../domain/search_controller.dart';
|
||||||
import '../domain/search_row.dart';
|
import '../domain/search_row.dart';
|
||||||
import 'search_result_view.dart';
|
import 'search_result_view.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The Cupertino search view: native search/kind controls and grouped list rows
|
/// The Cupertino search view: native search/kind controls and grouped list rows
|
||||||
/// in one scroll view, with standard activity and retry controls.
|
/// in one scroll view, with standard activity and retry controls.
|
||||||
@@ -35,6 +36,7 @@ class CupertinoSearchBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
..._content(context),
|
..._content(context),
|
||||||
|
const SliverFloatingBarClearance(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import '../../../core/api_gateway.dart';
|
|||||||
import '../domain/search_controller.dart';
|
import '../domain/search_controller.dart';
|
||||||
import '../domain/search_row.dart';
|
import '../domain/search_row.dart';
|
||||||
import 'search_result_view.dart';
|
import 'search_result_view.dart';
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The Material search view: the controls header and a flat native result list
|
/// The Material search view: the controls header and a flat native result list
|
||||||
/// in one scroll view, so text scaling can never clip the controls or a row.
|
/// in one scroll view, so text scaling can never clip the controls or a row.
|
||||||
@@ -29,6 +30,7 @@ class MaterialSearchBody extends StatelessWidget {
|
|||||||
if (controller.showProgress)
|
if (controller.showProgress)
|
||||||
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
||||||
..._content(context),
|
..._content(context),
|
||||||
|
const SliverFloatingBarClearance(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import 'settings_templates_section.dart';
|
|||||||
import 'server_connections.dart';
|
import 'server_connections.dart';
|
||||||
import 'saved_servers_section.dart';
|
import 'saved_servers_section.dart';
|
||||||
import 'managed_connection_section.dart';
|
import 'managed_connection_section.dart';
|
||||||
|
import '../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
/// The Settings destination: the server connection and the server-side
|
/// The Settings destination: the server connection and the server-side
|
||||||
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
|
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
|
||||||
@@ -134,15 +135,21 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// The content scrolls behind a floating tab bar and pads its end clear of
|
||||||
|
// it (or of the system inset on its own page).
|
||||||
final content = SafeArea(
|
final content = SafeArea(
|
||||||
|
bottom: false,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
// Web `.settings` page insets: 20 above the title, 16 at the sides and
|
// Web `.settings` page insets: 20 above the title, 16 at the sides and
|
||||||
// a clear 32 below the last section.
|
// a clear 32 below the last section.
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
padding: withFloatingBarClearance(
|
||||||
settingsPageSidePadding,
|
context,
|
||||||
settingsPageTopPadding,
|
const EdgeInsetsDirectional.fromSTEB(
|
||||||
settingsPageSidePadding,
|
settingsPageSidePadding,
|
||||||
settingsPageBottomPadding,
|
settingsPageTopPadding,
|
||||||
|
settingsPageSidePadding,
|
||||||
|
settingsPageBottomPadding,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../ui/adaptive/segmented_bar.dart';
|
import '../ui/adaptive/segmented_bar.dart';
|
||||||
|
import '../ui/adaptive/floating_bar_layout.dart';
|
||||||
import '../ui/adaptive/floating_destination_bar.dart';
|
import '../ui/adaptive/floating_destination_bar.dart';
|
||||||
import 'attention_badge.dart';
|
import 'attention_badge.dart';
|
||||||
import 'destination.dart';
|
import 'destination.dart';
|
||||||
@@ -43,8 +44,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
late AppDestination _selected;
|
late AppDestination _selected;
|
||||||
final Set<AppDestination> _visited = {};
|
final Set<AppDestination> _visited = {};
|
||||||
final ShellBarRegistry _bar = ShellBarRegistry();
|
final ShellBarRegistry _bar = ShellBarRegistry();
|
||||||
// The Cupertino sidebar and tab layouts have different parents. Preserve
|
// Keeps every destination's state if the stack's parent ever changes.
|
||||||
// destination selection/state while the same content moves between them.
|
|
||||||
final GlobalKey _destinationStackKey = GlobalKey();
|
final GlobalKey _destinationStackKey = GlobalKey();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -82,9 +82,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
List<T> _items<T>(T Function(AppDestination) build) =>
|
|
||||||
AppDestination.values.map(build).toList();
|
|
||||||
|
|
||||||
/// The destination's icon; only Runs carries the attention count.
|
/// The destination's icon; only Runs carries the attention count.
|
||||||
Widget _icon(AppDestination destination, IconData data) {
|
Widget _icon(AppDestination destination, IconData data) {
|
||||||
Widget icon = Icon(data);
|
Widget icon = Icon(data);
|
||||||
@@ -137,97 +134,58 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
}).toList();
|
}).toList();
|
||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: _bar,
|
listenable: _bar,
|
||||||
builder: (context, _) => LayoutBuilder(
|
builder: (context, _) {
|
||||||
builder: (context, constraints) {
|
final spec = _bar.specFor(_selected);
|
||||||
final wide = constraints.maxWidth >= 600;
|
// One floating glass tab bar at every width: full width on a phone,
|
||||||
if (widget.cupertino) {
|
// sized to its tabs at the right edge on a wide window (the bar judges
|
||||||
final spec = _bar.specFor(_selected);
|
// that itself, live). Content keeps the whole width and scrolls behind
|
||||||
return CupertinoPageScaffold(
|
// it, learning the bar's height as its bottom media padding. Neither
|
||||||
navigationBar: _segmentedBar(spec, details.label),
|
// scaffold's structure depends on the width, so resizing never
|
||||||
child: SafeArea(
|
// remounts a destination.
|
||||||
child: wide
|
final bar = FloatingDestinationBar(
|
||||||
// The web keeps a destination rail on a wide window. A native
|
cupertino: widget.cupertino,
|
||||||
// Cupertino sidebar list is the same idea with the host's own
|
currentIndex: index,
|
||||||
// controls; the tab bar stays the narrow-window navigation.
|
onTap: (value) => _select(AppDestination.values[value]),
|
||||||
? Row(
|
items: _destinationItems(),
|
||||||
children: [
|
);
|
||||||
_CupertinoSidebar(
|
if (widget.cupertino) {
|
||||||
selected: _selected,
|
return CupertinoPageScaffold(
|
||||||
onSelected: _select,
|
navigationBar: _segmentedBar(spec, details.label),
|
||||||
attentionCount: widget.attentionCount,
|
child: SafeArea(
|
||||||
),
|
|
||||||
Expanded(child: _destinationStack(contents, index)),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
: Column(
|
|
||||||
children: [
|
|
||||||
Expanded(child: _destinationStack(contents, index)),
|
|
||||||
// Keep the host's native tab semantics while giving
|
|
||||||
// the selector the same floating glass treatment as
|
|
||||||
// the top bar.
|
|
||||||
MediaQuery.withNoTextScaling(
|
|
||||||
child: FloatingDestinationBar(
|
|
||||||
cupertino: true,
|
|
||||||
currentIndex: index,
|
|
||||||
onTap: (value) =>
|
|
||||||
_select(AppDestination.values[value]),
|
|
||||||
items: _destinationItems(cupertino: true),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
final spec = _bar.specFor(_selected);
|
|
||||||
return Scaffold(
|
|
||||||
extendBodyBehindAppBar: true,
|
|
||||||
appBar: _segmentedBar(spec, details.label),
|
|
||||||
// Destinations start below the floating bar.
|
|
||||||
body: SafeArea(
|
|
||||||
left: false,
|
|
||||||
right: false,
|
|
||||||
bottom: false,
|
bottom: false,
|
||||||
child: Row(
|
child: FloatingBarOverlay(
|
||||||
children: [
|
bar: bar,
|
||||||
if (wide)
|
child: _destinationStack(contents, index),
|
||||||
NavigationRail(
|
|
||||||
selectedIndex: index,
|
|
||||||
onDestinationSelected: (value) =>
|
|
||||||
_select(AppDestination.values[value]),
|
|
||||||
labelType: NavigationRailLabelType.all,
|
|
||||||
destinations: _items((destination) {
|
|
||||||
final item = destinationDetails(destination);
|
|
||||||
return NavigationRailDestination(
|
|
||||||
icon: _icon(destination, item.icon),
|
|
||||||
label: Text(item.label),
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
Expanded(child: _destinationStack(contents, index)),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
extendBody: true,
|
|
||||||
bottomNavigationBar: wide
|
|
||||||
? null
|
|
||||||
: FloatingDestinationBar(
|
|
||||||
cupertino: false,
|
|
||||||
currentIndex: index,
|
|
||||||
onTap: (value) => _select(AppDestination.values[value]),
|
|
||||||
items: _destinationItems(),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
),
|
return Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: _segmentedBar(spec, details.label),
|
||||||
|
// Destinations start below the floating top bar.
|
||||||
|
body: SafeArea(
|
||||||
|
left: false,
|
||||||
|
right: false,
|
||||||
|
bottom: false,
|
||||||
|
child: _destinationStack(contents, index),
|
||||||
|
),
|
||||||
|
extendBody: true,
|
||||||
|
bottomNavigationBar: bar,
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FloatingDestinationItem> _destinationItems({bool cupertino = false}) =>
|
List<FloatingDestinationItem> _destinationItems() =>
|
||||||
AppDestination.values.map((destination) {
|
AppDestination.values.map((destination) {
|
||||||
final item = destinationDetails(destination);
|
final item = destinationDetails(destination);
|
||||||
return FloatingDestinationItem(
|
return FloatingDestinationItem(
|
||||||
icon: _icon(destination, cupertino ? item.cupertinoIcon : item.icon),
|
key: ValueKey('shell.destination.${destination.name}'),
|
||||||
|
icon: _icon(
|
||||||
|
destination,
|
||||||
|
widget.cupertino ? item.cupertinoIcon : item.icon,
|
||||||
|
),
|
||||||
label: item.label,
|
label: item.label,
|
||||||
);
|
);
|
||||||
}).toList();
|
}).toList();
|
||||||
@@ -286,61 +244,3 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
|||||||
Widget _destinationStack(List<Widget> contents, int index) =>
|
Widget _destinationStack(List<Widget> contents, int index) =>
|
||||||
IndexedStack(key: _destinationStackKey, index: index, children: contents);
|
IndexedStack(key: _destinationStackKey, index: index, children: contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The wide-window Cupertino destination list: the web's 200px rail with the
|
|
||||||
/// host's own grouped list controls.
|
|
||||||
class _CupertinoSidebar extends StatelessWidget {
|
|
||||||
const _CupertinoSidebar({
|
|
||||||
required this.selected,
|
|
||||||
required this.onSelected,
|
|
||||||
this.attentionCount = 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
final AppDestination selected;
|
|
||||||
final ValueChanged<AppDestination> onSelected;
|
|
||||||
final int attentionCount;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
final theme = CupertinoTheme.of(context);
|
|
||||||
return Container(
|
|
||||||
width: 200,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
|
|
||||||
context,
|
|
||||||
),
|
|
||||||
border: Border(
|
|
||||||
right: BorderSide(
|
|
||||||
color: CupertinoColors.separator.resolveFrom(context),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
child: ListView(
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
|
||||||
children: [
|
|
||||||
for (final destination in AppDestination.values)
|
|
||||||
CupertinoListTile(
|
|
||||||
key: ValueKey('shell.destination.${destination.name}'),
|
|
||||||
leading: destination == AppDestination.runs
|
|
||||||
? AttentionDestinationIcon(
|
|
||||||
count: attentionCount,
|
|
||||||
cupertino: true,
|
|
||||||
child: Icon(
|
|
||||||
destinationDetails(destination).cupertinoIcon,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
: Icon(destinationDetails(destination).cupertinoIcon),
|
|
||||||
title: Text(destinationDetails(destination).label),
|
|
||||||
trailing: destination == selected
|
|
||||||
? Icon(
|
|
||||||
CupertinoIcons.checkmark_alt,
|
|
||||||
color: theme.primaryColor,
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
onTap: () => onSelected(destination),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -143,16 +143,19 @@ class _DetailPaneState extends State<DetailPane> {
|
|||||||
title: title,
|
title: title,
|
||||||
actions: actions,
|
actions: actions,
|
||||||
);
|
);
|
||||||
|
// The bottom inset (the system's, or a floating tab bar's when the
|
||||||
|
// pane sits beside a list) passes through: the open item's content
|
||||||
|
// floats its own tabs above it and pads its lists clear of it.
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: bar,
|
navigationBar: bar,
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(bottom: false, child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
appBar: bar,
|
appBar: bar,
|
||||||
body: SafeArea(child: body),
|
body: SafeArea(bottom: false, child: body),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
/// At least this wide, a floating tab bar is sized to its tabs and sits at the
|
||||||
|
/// trailing edge; narrower, it spans the width minus [kFloatingBarMargin].
|
||||||
|
const double kFloatingBarWideWidth = 600;
|
||||||
|
|
||||||
|
/// The gap between a floating tab bar and the edges (and bottom safe area).
|
||||||
|
const double kFloatingBarMargin = 16;
|
||||||
|
|
||||||
|
/// [padding] with the floating bar's clearance added at the bottom.
|
||||||
|
///
|
||||||
|
/// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell)
|
||||||
|
/// reads the bar's height as [MediaQuery.paddingOf] bottom; adding it to the
|
||||||
|
/// list's own padding lets the content scroll behind the bar yet still bring
|
||||||
|
/// its last item clear of it at rest. Lists without explicit padding already
|
||||||
|
/// do this themselves.
|
||||||
|
EdgeInsetsGeometry withFloatingBarClearance(
|
||||||
|
BuildContext context,
|
||||||
|
EdgeInsetsGeometry padding,
|
||||||
|
) => padding.add(EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom));
|
||||||
|
|
||||||
|
/// Empty space as tall as the floating bar's clearance
|
||||||
|
/// ([MediaQuery.paddingOf] bottom), ending a scrolling column so its last item
|
||||||
|
/// comes clear of the bar at rest.
|
||||||
|
class FloatingBarClearance extends StatelessWidget {
|
||||||
|
const FloatingBarClearance({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) =>
|
||||||
|
SizedBox(height: MediaQuery.paddingOf(context).bottom);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [FloatingBarClearance] as the last sliver of a [CustomScrollView].
|
||||||
|
class SliverFloatingBarClearance extends StatelessWidget {
|
||||||
|
const SliverFloatingBarClearance({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) =>
|
||||||
|
const SliverToBoxAdapter(child: FloatingBarClearance());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Floats [bar] over the bottom of [child], the way a scaffold with
|
||||||
|
/// `extendBody` floats its bottom bar, for a bar that is not a scaffold's.
|
||||||
|
///
|
||||||
|
/// [child] fills the whole area and scrolls behind the bar; it learns the
|
||||||
|
/// bar's measured height (bottom safe area and margins included) as its
|
||||||
|
/// [MediaQuery.paddingOf] bottom, so a list can pad its last item clear of the
|
||||||
|
/// bar at rest (see [withFloatingBarClearance]). Taps the bar does not take,
|
||||||
|
/// such as beside a bar narrower than the area, reach [child].
|
||||||
|
class FloatingBarOverlay extends StatelessWidget {
|
||||||
|
const FloatingBarOverlay({super.key, required this.bar, required this.child});
|
||||||
|
|
||||||
|
final Widget bar;
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => CustomMultiChildLayout(
|
||||||
|
delegate: _OverlayLayout(),
|
||||||
|
children: [
|
||||||
|
// Painted first, so the bar draws (and takes taps) above it.
|
||||||
|
LayoutId(
|
||||||
|
id: _Slot.content,
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
final barHeight = constraints is _ContentConstraints
|
||||||
|
? constraints.barHeight
|
||||||
|
: 0.0;
|
||||||
|
final media = MediaQuery.of(context);
|
||||||
|
return MediaQuery(
|
||||||
|
data: media.copyWith(
|
||||||
|
padding: media.padding.copyWith(
|
||||||
|
bottom: barHeight > media.padding.bottom
|
||||||
|
? barHeight
|
||||||
|
: media.padding.bottom,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
LayoutId(id: _Slot.bar, child: bar),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum _Slot { content, bar }
|
||||||
|
|
||||||
|
/// The content's tight constraints, carrying the bar's height so the content
|
||||||
|
/// rebuilds its inset when the bar grows or shrinks.
|
||||||
|
class _ContentConstraints extends BoxConstraints {
|
||||||
|
_ContentConstraints(Size size, {required this.barHeight})
|
||||||
|
: super(
|
||||||
|
minWidth: size.width,
|
||||||
|
maxWidth: size.width,
|
||||||
|
minHeight: size.height,
|
||||||
|
maxHeight: size.height,
|
||||||
|
);
|
||||||
|
|
||||||
|
final double barHeight;
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(Object other) =>
|
||||||
|
other is _ContentConstraints &&
|
||||||
|
super == other &&
|
||||||
|
other.barHeight == barHeight;
|
||||||
|
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(super.hashCode, barHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
class _OverlayLayout extends MultiChildLayoutDelegate {
|
||||||
|
@override
|
||||||
|
void performLayout(Size size) {
|
||||||
|
final bar = layoutChild(
|
||||||
|
_Slot.bar,
|
||||||
|
BoxConstraints(
|
||||||
|
minWidth: size.width,
|
||||||
|
maxWidth: size.width,
|
||||||
|
maxHeight: size.height,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
positionChild(_Slot.bar, Offset(0, size.height - bar.height));
|
||||||
|
layoutChild(
|
||||||
|
_Slot.content,
|
||||||
|
_ContentConstraints(size, barHeight: bar.height),
|
||||||
|
);
|
||||||
|
positionChild(_Slot.content, Offset.zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRelayout(_OverlayLayout oldDelegate) => false;
|
||||||
|
}
|
||||||
@@ -1,12 +1,26 @@
|
|||||||
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'floating_bar_layout.dart';
|
||||||
import 'glass_pill.dart';
|
import 'glass_pill.dart';
|
||||||
|
|
||||||
/// A compact destination switcher which floats above the bottom edge instead
|
/// A tab bar which floats above the bottom edge in a frosted [GlassPill]
|
||||||
/// of becoming a full-width system bar. The controls inside remain the
|
/// instead of becoming a full-width system bar. Used for the app's
|
||||||
/// platform navigation controls, so their labels, semantics and selection
|
/// destinations and for every page's own tabs.
|
||||||
/// behaviour are not recreated by the glass treatment.
|
///
|
||||||
|
/// Placement follows the width the bar is given, live: below
|
||||||
|
/// [kFloatingBarWideWidth] the pill spans it minus [kFloatingBarMargin] on
|
||||||
|
/// each side; at or above it the pill is only as wide as its tabs and sits at
|
||||||
|
/// the trailing (right, in left-to-right text) edge, near the thumb. Either
|
||||||
|
/// way it keeps [kFloatingBarMargin] above the bottom safe area. Only the pill
|
||||||
|
/// takes taps: the space beside it reaches the content behind.
|
||||||
|
///
|
||||||
|
/// 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
|
||||||
|
/// Material widget.
|
||||||
class FloatingDestinationBar extends StatelessWidget {
|
class FloatingDestinationBar extends StatelessWidget {
|
||||||
const FloatingDestinationBar({
|
const FloatingDestinationBar({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -21,23 +35,90 @@ class FloatingDestinationBar extends StatelessWidget {
|
|||||||
final ValueChanged<int> onTap;
|
final ValueChanged<int> onTap;
|
||||||
final List<FloatingDestinationItem> items;
|
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 Cupertino bar inside the pill (the stock bar is 50).
|
||||||
|
static const double cupertinoHeight = 54;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final width = MediaQuery.sizeOf(context).width;
|
|
||||||
final bar = cupertino ? _cupertinoBar() : _materialBar(context);
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
top: false,
|
top: false,
|
||||||
minimum: const EdgeInsets.fromLTRB(16, 0, 16, 8),
|
minimum: const EdgeInsets.fromLTRB(
|
||||||
child: Align(
|
kFloatingBarMargin,
|
||||||
alignment: Alignment.bottomCenter,
|
0,
|
||||||
child: ConstrainedBox(
|
kFloatingBarMargin,
|
||||||
constraints: BoxConstraints(maxWidth: width - 32),
|
kFloatingBarMargin,
|
||||||
child: GlassPill(cupertino: cupertino, child: bar),
|
),
|
||||||
),
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) {
|
||||||
|
// Wide is judged on the space the bar is given, margins included,
|
||||||
|
// the way the shell and the pages judge their own layouts.
|
||||||
|
final available = constraints.maxWidth;
|
||||||
|
final wide =
|
||||||
|
available + 2 * kFloatingBarMargin >= kFloatingBarWideWidth;
|
||||||
|
final width = wide
|
||||||
|
? math.min(available, _tabsWidth(context))
|
||||||
|
: available;
|
||||||
|
return Align(
|
||||||
|
// As tall as the pill, so a scaffold or overlay measures the bar
|
||||||
|
// and not the whole area it may grow into.
|
||||||
|
heightFactor: 1,
|
||||||
|
alignment: wide
|
||||||
|
? AlignmentDirectional.bottomEnd
|
||||||
|
: Alignment.bottomCenter,
|
||||||
|
child: SizedBox(
|
||||||
|
width: math.max(0, width),
|
||||||
|
child: GlassPill(
|
||||||
|
cupertino: cupertino,
|
||||||
|
child: cupertino
|
||||||
|
? _cupertinoBar(context)
|
||||||
|
: _materialBar(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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;
|
||||||
|
}
|
||||||
|
|
||||||
Widget _materialBar(BuildContext context) {
|
Widget _materialBar(BuildContext context) {
|
||||||
final scheme = Theme.of(context).colorScheme;
|
final scheme = Theme.of(context).colorScheme;
|
||||||
return NavigationBarTheme(
|
return NavigationBarTheme(
|
||||||
@@ -46,6 +127,8 @@ class FloatingDestinationBar extends StatelessWidget {
|
|||||||
elevation: 0,
|
elevation: 0,
|
||||||
surfaceTintColor: Colors.transparent,
|
surfaceTintColor: Colors.transparent,
|
||||||
indicatorColor: scheme.secondaryContainer,
|
indicatorColor: scheme.secondaryContainer,
|
||||||
|
height: materialHeight,
|
||||||
|
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
|
||||||
),
|
),
|
||||||
child: NavigationBar(
|
child: NavigationBar(
|
||||||
selectedIndex: currentIndex,
|
selectedIndex: currentIndex,
|
||||||
@@ -53,6 +136,7 @@ class FloatingDestinationBar extends StatelessWidget {
|
|||||||
destinations: [
|
destinations: [
|
||||||
for (final item in items)
|
for (final item in items)
|
||||||
NavigationDestination(
|
NavigationDestination(
|
||||||
|
key: item.key,
|
||||||
icon: item.icon,
|
icon: item.icon,
|
||||||
selectedIcon: item.selectedIcon ?? item.icon,
|
selectedIcon: item.selectedIcon ?? item.icon,
|
||||||
label: item.label,
|
label: item.label,
|
||||||
@@ -62,19 +146,58 @@ class FloatingDestinationBar extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _cupertinoBar() => CupertinoTabBar(
|
/// The stock Cupertino bar, transparent inside the pill. Each tab's label is
|
||||||
backgroundColor: CupertinoColors.transparent,
|
/// drawn with its icon (in the bar's own label style and colours) so the
|
||||||
currentIndex: currentIndex,
|
/// item's key covers the whole tab, and the selected tab's icon sits in a
|
||||||
onTap: onTap,
|
/// tinted capsule so the selection reads at a glance, not by colour alone.
|
||||||
items: [
|
Widget _cupertinoBar(BuildContext context) {
|
||||||
for (final item in items)
|
final active = CupertinoTheme.of(context).primaryColor;
|
||||||
BottomNavigationBarItem(
|
Widget tab(FloatingDestinationItem item, {required bool selected}) {
|
||||||
icon: item.icon,
|
Widget icon = item.icon;
|
||||||
activeIcon: item.selectedIcon ?? item.icon,
|
if (selected) {
|
||||||
label: item.label,
|
icon = DecoratedBox(
|
||||||
|
decoration: ShapeDecoration(
|
||||||
|
color: active.withValues(alpha: 0.16),
|
||||||
|
shape: const StadiumBorder(),
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 2),
|
||||||
|
child: item.selectedIcon ?? item.icon,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return KeyedSubtree(
|
||||||
|
key: item.key,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
icon,
|
||||||
|
const SizedBox(height: 2),
|
||||||
|
Text(item.label, maxLines: 1, softWrap: false),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
// The tab bar does not scale its text on iOS either; its height is fixed.
|
||||||
|
return MediaQuery.withNoTextScaling(
|
||||||
|
child: CupertinoTabBar(
|
||||||
|
backgroundColor: CupertinoColors.transparent,
|
||||||
|
border: null,
|
||||||
|
iconSize: 24,
|
||||||
|
height: cupertinoHeight,
|
||||||
|
currentIndex: currentIndex,
|
||||||
|
onTap: onTap,
|
||||||
|
items: [
|
||||||
|
for (var index = 0; index < items.length; index += 1)
|
||||||
|
BottomNavigationBarItem(
|
||||||
|
icon: tab(items[index], selected: false),
|
||||||
|
activeIcon: tab(items[index], selected: true),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The platform-neutral data needed by [FloatingDestinationBar].
|
/// The platform-neutral data needed by [FloatingDestinationBar].
|
||||||
@@ -83,9 +206,13 @@ class FloatingDestinationItem {
|
|||||||
required this.icon,
|
required this.icon,
|
||||||
required this.label,
|
required this.label,
|
||||||
this.selectedIcon,
|
this.selectedIcon,
|
||||||
|
this.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
final Widget icon;
|
final Widget icon;
|
||||||
final String label;
|
final String label;
|
||||||
final Widget? selectedIcon;
|
final Widget? selectedIcon;
|
||||||
|
|
||||||
|
/// Identifies the whole tab (icon and label), for tests and automation.
|
||||||
|
final Key? key;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
# Floating glass tab bars
|
||||||
|
|
||||||
|
Every bottom tab bar in the app is now one ChatGPT-style floating glass bar:
|
||||||
|
the shell's destinations, the run detail's tabs, the stage (visit) page's tabs
|
||||||
|
and the pipeline detail's tabs. The NavigationRail (Material) and the 200px
|
||||||
|
Cupertino sidebar are gone.
|
||||||
|
|
||||||
|
## Shared pieces (`lib/ui/adaptive/`)
|
||||||
|
|
||||||
|
- `floating_destination_bar.dart` — `FloatingDestinationBar({cupertino,
|
||||||
|
currentIndex, onTap, items})`, `FloatingDestinationItem({icon, label,
|
||||||
|
selectedIcon, key})`. The host's own `NavigationBar` (Material, 64 high,
|
||||||
|
labels always shown, `secondaryContainer` indicator) or `CupertinoTabBar`
|
||||||
|
(54 high, no text scaling, transparent, no border; the selected icon sits in
|
||||||
|
a tinted capsule so selection does not rely on colour alone) inside the
|
||||||
|
shared `GlassPill`. Tab semantics (selected, "tab n of m") come from the
|
||||||
|
host control. The item key covers the whole tab (icon and label) on both
|
||||||
|
hosts. The Cupertino path builds no Material widget.
|
||||||
|
- Placement follows the width the bar is given, live (its own
|
||||||
|
`LayoutBuilder`): below `kFloatingBarWideWidth` (600) the pill spans the
|
||||||
|
width minus `kFloatingBarMargin` (16) per side; at or above it the pill is
|
||||||
|
sized to its tabs (every tab as wide as the widest label + 24, at least
|
||||||
|
88 Material / 76 Cupertino) and aligned to the trailing (right) edge.
|
||||||
|
Either way it floats 16 above the bottom safe area (`SafeArea.minimum`).
|
||||||
|
- `Align(heightFactor: 1)`, so a scaffold/overlay measures the pill, not
|
||||||
|
the whole area; space beside a narrow pill does not take taps.
|
||||||
|
- `floating_bar_layout.dart`
|
||||||
|
- `FloatingBarOverlay(bar:, child:)` — floats a bar over the bottom of
|
||||||
|
content outside a scaffold (the bottom twin of `SegmentedBarOverlay`); the
|
||||||
|
content fills the area and gets the bar's measured height as
|
||||||
|
`MediaQuery.paddingOf(context).bottom`.
|
||||||
|
- `withFloatingBarClearance(context, padding)`, `FloatingBarClearance`,
|
||||||
|
`SliverFloatingBarClearance` — add that bottom padding to a list's own
|
||||||
|
padding / end a column or `CustomScrollView`, so the last item clears the
|
||||||
|
bar at rest. Lists without explicit padding (`ListView` default) already
|
||||||
|
consume media padding.
|
||||||
|
|
||||||
|
## Where
|
||||||
|
|
||||||
|
- Shell (`shell/adaptive_shell.dart`): Material keeps `Scaffold(extendBody:
|
||||||
|
true, bottomNavigationBar: bar)` at every width; Cupertino uses
|
||||||
|
`FloatingBarOverlay` inside `SafeArea(bottom: false)`. Neither structure
|
||||||
|
depends on width, so resizing never remounts a destination (the destination
|
||||||
|
`IndexedStack` keeps its GlobalKey). Destination keys
|
||||||
|
`shell.destination.<name>` now live on the floating bar items (both hosts).
|
||||||
|
Badges (attention, running, unread) unchanged.
|
||||||
|
- Run detail (`features/runs/ui/run_detail_tab_strip.dart`,
|
||||||
|
`run_detail_tabs.dart`): the header no longer carries the strip; the tab
|
||||||
|
body is a `FloatingBarOverlay` with the tabs at every width. Keys
|
||||||
|
`run-detail-tabs`, `run-detail-tab-<name>` kept.
|
||||||
|
`kRunDetailBottomTabsWidth`, the `bottom` flag and the strip's
|
||||||
|
scroll-into-view are gone (all tabs are always visible).
|
||||||
|
- Stage page (`run_detail_visit_sections.dart`, `run_detail_visit.dart`): the
|
||||||
|
same; keys `run-visit-tabs`, `run-visit-tab-<name>` kept. The selected tab
|
||||||
|
is `visitTabFor(section)`, so Input/Output highlight Summary.
|
||||||
|
- Pipeline detail (`features/pipelines/widgets/pipeline_tabs.dart`,
|
||||||
|
`pipeline_detail_panel.dart`): the same (it was a bottom bar on phones);
|
||||||
|
`pipeline-detail-tabs`, new `pipeline-detail-tab-<name>`. Run/Runs FABs sit
|
||||||
|
16 above the bar (`bottom: 16 + MediaQuery.paddingOf(context).bottom`).
|
||||||
|
- `DetailPane` (`shell/detail_page.dart`) no longer consumes the bottom inset;
|
||||||
|
its content (run detail, pipeline detail, chat thread with its own
|
||||||
|
`SafeArea` composer) handles it. Beside a list on a wide window the open
|
||||||
|
item's tabs therefore float just above the shell's bar (two stacked pills
|
||||||
|
at the right edge) and content scrolls behind both.
|
||||||
|
- Not converted (judged not bottom tabs): the segmented filters/toggles at the
|
||||||
|
top of lists and viewers (`SegmentedButton` / `CupertinoSlidingSegmentedControl`
|
||||||
|
in markdown source view, artifact gallery mode, diff form, pipeline scope,
|
||||||
|
schedules filter). They switch a view's mode in place, not pages.
|
||||||
|
|
||||||
|
## Content clearance
|
||||||
|
|
||||||
|
Scrollables under a floating bar that use explicit padding (or slivers) now
|
||||||
|
add the clearance: run Summary (`run_detail_tab_bodies.dart`), field tabs,
|
||||||
|
Timeline, artifacts gallery (`artifact_visit_list.dart`), Changes
|
||||||
|
(`changes_viewer.dart`), visit Summary and Session, pipeline Source, Settings
|
||||||
|
(now `SafeArea(bottom: false)`), Search (both bodies,
|
||||||
|
`SafeArea(bottom: false)`), Cupertino chat sessions list. Runs, Pipelines and
|
||||||
|
Material chat lists use default `ListView` padding.
|
||||||
|
|
||||||
|
## widget_test failure on main
|
||||||
|
|
||||||
|
`Material shell adapts at width 390.0 and supports large text` failed with
|
||||||
|
`BoxConstraints(0.0<=w<=-32.0) NOT NORMALIZED`. The test wraps the shell in
|
||||||
|
`MediaQuery(data: MediaQueryData(textScaler: 2x))`, whose default size is
|
||||||
|
`Size.zero`; `FloatingDestinationBar` sized itself from
|
||||||
|
`MediaQuery.sizeOf(context).width - 32` (the screen) instead of the space it
|
||||||
|
was laid out in. The bar now measures its own constraints (`LayoutBuilder`),
|
||||||
|
which is also what lets it follow a pane's width rather than the window's. The
|
||||||
|
test keeps its intent (2x text, both widths, tab switching) and now also
|
||||||
|
asserts no rail and no exception.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
New: `test/shell/floating_tab_bar_test.dart` (phone full width; wide
|
||||||
|
right-aligned, under 60% of 1200, content full width, tap beside the bar
|
||||||
|
reaches content; content bottom padding equals the bar's height + margin;
|
||||||
|
resizing moves the bar without remounting content; bottom safe area; selected
|
||||||
|
semantics; no Material widget in the Cupertino bar; 320px at 2x),
|
||||||
|
`test/ui/adaptive/floating_bar_layout_test.dart` (last list item clears the
|
||||||
|
bar at rest at 390 and 1200; taps beside the wide bar reach content).
|
||||||
|
Updated: `widget_test.dart`, `shell/attention_badge_test.dart`,
|
||||||
|
`application/list_detail_consistency_test.dart` (taps destination keys),
|
||||||
|
`application/chat_registration_test.dart`,
|
||||||
|
`features/chat/chat_list_detail_test.dart`,
|
||||||
|
`features/pipelines/pipeline_tabs_test.dart` (floating placement at
|
||||||
|
320/390/720/1200 at 2x), `features/pipelines/pipelines_adaptive_test.dart`,
|
||||||
|
`features/runs/ui/run_detail_tabs_test.dart` (floating full width / right
|
||||||
|
aligned, content behind the bar with clearance),
|
||||||
|
`features/runs/ui/run_detail_visit_sections_test.dart` (placement at
|
||||||
|
390/884/1000), `features/runs/ui/run_decision_wiring_test.dart` (banner spans
|
||||||
|
the header inset instead of the old strip). Test-font widths are inflated
|
||||||
|
(every glyph a full em), so wide-width assertions in run/visit tests use 70%.
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
Headless Chrome captures in `/tmp/floating-tabs-evidence/`:
|
||||||
|
`shell-{material,cupertino}-560`, `shell-material-1200`,
|
||||||
|
`shell-cupertino-1200-dark` (new `tool/floating_tabs_probe_entry.dart`,
|
||||||
|
`?platform=cupertino&theme=dark&tab=runs`), `run-detail-*`,
|
||||||
|
`run-timeline-cupertino-*`, `stage-page-*` (`tool/run_detail_visit_probe.dart`,
|
||||||
|
stage pages opened by CDP clicks), and the real app over the loopback
|
||||||
|
fixtures: `app-runs-material-560`, `app-run-detail-material-{560,1200}`,
|
||||||
|
`app-pipelines-material-560`, `app-pipeline-detail-material-{560,1200}`
|
||||||
|
(`tool/runs_probe_entry.dart`, `tool/pipelines_wiring_probe_entry.dart`). The
|
||||||
|
full app is Material on the web by design (`prefersCupertino` is false on web),
|
||||||
|
so Cupertino evidence comes from the standalone probes.
|
||||||
|
|
||||||
|
Known gaps: no device run (Android/iOS unverified); the existing
|
||||||
|
`tool/run_detail_visit_probe.mjs` predates this change (it still looks for a
|
||||||
|
Graph tab) and was not updated.
|
||||||
@@ -31,7 +31,7 @@ pill on the page's own background) is now the app's only top bar.
|
|||||||
`BackdropFilter` blur, sigma 16, clipped to the shape; fill
|
`BackdropFilter` blur, sigma 16, clipped to the shape; fill
|
||||||
`surfaceContainerHigh` / `systemGrey6` at 72%; hairline `outlineVariant` /
|
`surfaceContainerHigh` / `systemGrey6` at 72%; hairline `outlineVariant` /
|
||||||
`separator` border). Under `MediaQuery.highContrast` the fill is solid and
|
`separator` border). Under `MediaQuery.highContrast` the fill is solid and
|
||||||
nothing blurs. Intended for the floating tab bar follow-up too.
|
nothing blurs. Also the floating tab bars' pill (`notes/floating-tab-bars.md`).
|
||||||
- `segmented_bar_overlay.dart` — `SegmentedBarOverlay(bar:, child:)`: floats a
|
- `segmented_bar_overlay.dart` — `SegmentedBarOverlay(bar:, child:)`: floats a
|
||||||
bar over content outside a scaffold (like `extendBodyBehindAppBar`), giving
|
bar over content outside a scaffold (like `extendBodyBehindAppBar`), giving
|
||||||
the content the bar's measured height as `MediaQuery.paddingOf(context).top`.
|
the content the bar's measured height as `MediaQuery.paddingOf(context).top`.
|
||||||
@@ -49,7 +49,7 @@ pill on the page's own background) is now the app's only top bar.
|
|||||||
schedules bodies gained a top-only `SafeArea`). They show the new bar but
|
schedules bodies gained a top-only `SafeArea`). They show the new bar but
|
||||||
their content does not yet scroll behind it — each list has its own fixed
|
their content does not yet scroll behind it — each list has its own fixed
|
||||||
padding/headers and needs a per-screen change to consume the media padding.
|
padding/headers and needs a per-screen change to consume the media padding.
|
||||||
- The bottom tab bar is unchanged (floating tab bars are a separate change).
|
- Bottom tab bars float too: see `notes/floating-tab-bars.md`.
|
||||||
|
|
||||||
## Converted
|
## Converted
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||||
@@ -208,14 +209,12 @@ void main() {
|
|||||||
expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget);
|
expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget);
|
||||||
expect(find.text('Kept behind a native disclosure.'), findsNothing);
|
expect(find.text('Kept behind a native disclosure.'), findsNothing);
|
||||||
|
|
||||||
// The shell bar stays over the list and rail; the open chat draws its
|
// The shell bar stays over the list and tabs; the open chat draws its
|
||||||
// own floating bar in its pane, with no Back: the list beside it is the
|
// own floating bar in its pane, with no Back: the list beside it is the
|
||||||
// way out.
|
// way out.
|
||||||
expect(find.byType(ChatSessionsScreen), findsOneWidget);
|
expect(find.byType(ChatSessionsScreen), findsOneWidget);
|
||||||
expect(
|
expect(find.byType(NavigationRail), findsNothing);
|
||||||
find.byType(NavigationRail),
|
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
||||||
cupertino ? findsNothing : findsOneWidget,
|
|
||||||
);
|
|
||||||
// The shell's bar and the conversation's own header.
|
// The shell's bar and the conversation's own header.
|
||||||
expect(find.byType(SegmentedBar), findsNWidgets(2));
|
expect(find.byType(SegmentedBar), findsNWidgets(2));
|
||||||
expect(find.byType(AppBar), findsNothing);
|
expect(find.byType(AppBar), findsNothing);
|
||||||
|
|||||||
@@ -109,7 +109,11 @@ void main() {
|
|||||||
final bodyWidths = <double>[];
|
final bodyWidths = <double>[];
|
||||||
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
|
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
|
||||||
if (destination != 'Pipelines') {
|
if (destination != 'Pipelines') {
|
||||||
await tester.tap(find.text(destination).first);
|
await tester.tap(
|
||||||
|
find.byKey(
|
||||||
|
ValueKey('shell.destination.${destination.toLowerCase()}'),
|
||||||
|
),
|
||||||
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(
|
expect(
|
||||||
tester.takeException(),
|
tester.takeException(),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/chat/screen.dart';
|
import 'package:pipelines_app/features/chat/screen.dart';
|
||||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||||
@@ -47,7 +48,7 @@ Future<void> _pumpShell(WidgetTester tester, Size size) async {
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
for (final size in [const Size(1280, 800), const Size(800, 830)]) {
|
for (final size in [const Size(1280, 800), const Size(800, 830)]) {
|
||||||
testWidgets('a wide window keeps the rail and list beside the open chat '
|
testWidgets('a wide window keeps the tab bar and list beside the open chat '
|
||||||
'at $size', (tester) async {
|
'at $size', (tester) async {
|
||||||
await _pumpShell(tester, size);
|
await _pumpShell(tester, size);
|
||||||
expect(find.text('Select a chat to open it here.'), findsOneWidget);
|
expect(find.text('Select a chat to open it here.'), findsOneWidget);
|
||||||
@@ -60,7 +61,8 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
||||||
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
|
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
|
||||||
expect(find.byType(NavigationRail), findsOneWidget);
|
expect(find.byType(NavigationRail), findsNothing);
|
||||||
|
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
||||||
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
||||||
expect(find.text('Second chat'), findsOneWidget);
|
expect(find.text('Second chat'), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import 'dart:ui' show PointerDeviceKind;
|
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
||||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_styles.dart';
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_styles.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
testWidgets('code-like values still use native host typography', (
|
testWidgets('code-like values still use native host typography', (
|
||||||
@@ -30,7 +28,7 @@ void main() {
|
|||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
for (final cupertino in [false, true]) {
|
||||||
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
|
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
|
||||||
testWidgets('native tabs at $width, 2x, Cupertino=$cupertino', (
|
testWidgets('floating tabs at $width, 2x, Cupertino=$cupertino', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
tester.view.physicalSize = Size(width, 640);
|
tester.view.physicalSize = Size(width, 640);
|
||||||
@@ -38,7 +36,7 @@ void main() {
|
|||||||
addTearDown(tester.view.reset);
|
addTearDown(tester.view.reset);
|
||||||
PipelineDetailTab? selected;
|
PipelineDetailTab? selected;
|
||||||
final body = Align(
|
final body = Align(
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.bottomCenter,
|
||||||
child: PipelineDetailTabs(
|
child: PipelineDetailTabs(
|
||||||
selected: PipelineDetailTab.summary,
|
selected: PipelineDetailTab.summary,
|
||||||
onSelected: (value) => selected = value,
|
onSelected: (value) => selected = value,
|
||||||
@@ -62,30 +60,27 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
// The host's own tab bar inside the shared glass pill.
|
||||||
expect(
|
expect(
|
||||||
cupertino
|
find.byType(cupertino ? CupertinoTabBar : NavigationBar),
|
||||||
? find.byType(CupertinoSegmentedControl<PipelineDetailTab>)
|
|
||||||
: find.byType(SegmentedButton<PipelineDetailTab>),
|
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
for (final tab in PipelineDetailTab.values) {
|
final pill = tester.getRect(find.byType(GlassPill));
|
||||||
final paragraph = tester.renderObject<RenderParagraph>(
|
if (width < 600) {
|
||||||
find.text(tab.label),
|
expect(pill.left, 16);
|
||||||
);
|
expect(pill.right, width - 16);
|
||||||
expect(
|
} else {
|
||||||
paragraph.size.width,
|
// Sized to its three tabs at the right edge.
|
||||||
greaterThanOrEqualTo(
|
expect(pill.right, width - 16);
|
||||||
paragraph.getMaxIntrinsicWidth(double.infinity) - 0.01,
|
expect(pill.width, lessThan(width * 0.6));
|
||||||
),
|
}
|
||||||
reason: 'Whole labels must not be squeezed inside a native segment',
|
for (final tab in PipelineDetailTab.values) {
|
||||||
);
|
final rect = tester.getRect(
|
||||||
|
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
|
||||||
|
);
|
||||||
|
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
|
||||||
|
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
|
||||||
}
|
}
|
||||||
await tester.drag(
|
|
||||||
find.byType(SingleChildScrollView),
|
|
||||||
const Offset(-1000, 0),
|
|
||||||
kind: PointerDeviceKind.mouse,
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await tester.tap(find.text('Source'));
|
await tester.tap(find.text('Source'));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(selected, PipelineDetailTab.source);
|
expect(selected, PipelineDetailTab.source);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
|
|||||||
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
|
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
|
||||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
|
||||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
|
||||||
|
|
||||||
import 'fixtures.dart';
|
import 'fixtures.dart';
|
||||||
import 'test_helpers.dart';
|
import 'test_helpers.dart';
|
||||||
@@ -127,8 +126,12 @@ void main() {
|
|||||||
expect(find.byType(CupertinoActionSheet), findsNothing);
|
expect(find.byType(CupertinoActionSheet), findsNothing);
|
||||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
// The tabs are the floating glass Cupertino tab bar.
|
||||||
expect(
|
expect(
|
||||||
find.byType(CupertinoSegmentedControl<PipelineDetailTab>),
|
find.descendant(
|
||||||
|
of: find.byKey(const Key('pipeline-detail-tabs')),
|
||||||
|
matching: find.byType(CupertinoTabBar),
|
||||||
|
),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
);
|
);
|
||||||
expect(find.byType(CupertinoListTile), findsWidgets);
|
expect(find.byType(CupertinoListTile), findsWidgets);
|
||||||
|
|||||||
@@ -73,13 +73,16 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||||
// The web's decision banner spans the header, with Decide trailing.
|
// The web's decision banner spans the header at its 16px inset, with
|
||||||
|
// Decide trailing.
|
||||||
final banner = tester.getRect(
|
final banner = tester.getRect(
|
||||||
find.byKey(const Key('run-decision-banner')),
|
find.byKey(const Key('run-decision-banner')),
|
||||||
);
|
);
|
||||||
final tabs = tester.getRect(find.byKey(const Key('run-detail-tabs')));
|
final pane = tester.getRect(
|
||||||
expect(banner.left, tabs.left);
|
find.byKey(const ValueKey('list-detail-body')),
|
||||||
expect(banner.width, greaterThanOrEqualTo(tabs.width));
|
);
|
||||||
|
expect(banner.left, pane.left + 16);
|
||||||
|
expect(banner.right, pane.right - 16);
|
||||||
expect(
|
expect(
|
||||||
tester.getCenter(find.byKey(decisionActionKey)).dx,
|
tester.getCenter(find.byKey(decisionActionKey)).dx,
|
||||||
greaterThan(banner.center.dx),
|
greaterThan(banner.center.dx),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
|||||||
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
|
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||||
|
|
||||||
import 'run_detail_graph_support.dart';
|
import 'run_detail_graph_support.dart';
|
||||||
|
|
||||||
@@ -48,19 +49,15 @@ void main() {
|
|||||||
previous = center.dx;
|
previous = center.dx;
|
||||||
}
|
}
|
||||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||||
// The strip lines up with the header's 16px inset on both hosts: the
|
// The tabs are the floating glass bar: on this 900px detail it is sized
|
||||||
// first label sits within its segment's own padding of that inset, not
|
// to its tabs at the right edge, above the bottom.
|
||||||
// behind a second 16px control inset (which put it at 48 on Cupertino).
|
final pill = tester.getRect(
|
||||||
expect(
|
find.descendant(of: strip, matching: find.byType(GlassPill)),
|
||||||
tester
|
|
||||||
.getTopLeft(
|
|
||||||
find.descendant(of: strip, matching: find.text('Summary')),
|
|
||||||
)
|
|
||||||
.dx,
|
|
||||||
// Segments share the widest label's width, so a short first label
|
|
||||||
// sits a little in from its edge; a doubled inset would be 48+.
|
|
||||||
lessThan(46),
|
|
||||||
);
|
);
|
||||||
|
expect(pill.right, 900 - 16);
|
||||||
|
expect(pill.bottom, 1000 - 16);
|
||||||
|
// (The test font draws every glyph a full em wide.)
|
||||||
|
expect(pill.width, lessThan(900 * 0.7));
|
||||||
|
|
||||||
for (final tab in [
|
for (final tab in [
|
||||||
RunDetailTab.timeline,
|
RunDetailTab.timeline,
|
||||||
@@ -74,30 +71,50 @@ void main() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('${platform.name} phone tabs sit at the bottom, wide ones '
|
testWidgets('${platform.name} tabs float full width on a phone and at '
|
||||||
'under the header', (tester) async {
|
'the right edge when wide, over content that scrolls behind them', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
await pumpRunDetail(tester, platform, size: const Size(390, 844));
|
await pumpRunDetail(tester, platform, size: const Size(390, 844));
|
||||||
final strip = tester.getRect(find.byKey(const Key('run-detail-tabs')));
|
final strip = find.byKey(const Key('run-detail-tabs'));
|
||||||
final body = tester.getRect(
|
final pill = tester.getRect(
|
||||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
find.descendant(of: strip, matching: find.byType(GlassPill)),
|
||||||
);
|
);
|
||||||
expect(strip.top, greaterThanOrEqualTo(body.bottom));
|
final body = find.byKey(const Key('run-detail-tab-body-summary'));
|
||||||
expect(strip.bottom, greaterThan(844 - 80));
|
// Full width minus the margins, floating above the bottom.
|
||||||
|
expect(pill.left, 16);
|
||||||
|
expect(pill.right, 390 - 16);
|
||||||
|
expect(pill.bottom, 844 - 16);
|
||||||
|
// The tab's content reaches the bottom edge, behind the bar.
|
||||||
|
expect(tester.getRect(body).bottom, 844);
|
||||||
// Every tab is on screen without scrolling the bar.
|
// Every tab is on screen without scrolling the bar.
|
||||||
for (final tab in renderedRunDetailTabs) {
|
for (final tab in renderedRunDetailTabs) {
|
||||||
final rect = tester.getRect(runDetailTab(tab));
|
final rect = tester.getRect(runDetailTab(tab));
|
||||||
expect(rect.left, greaterThanOrEqualTo(0), reason: tab.name);
|
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
|
||||||
expect(rect.right, lessThanOrEqualTo(390), reason: tab.name);
|
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
|
||||||
}
|
}
|
||||||
|
// At rest after scrolling to the end, the last content clears the bar.
|
||||||
|
final scrollable = find.descendant(
|
||||||
|
of: body,
|
||||||
|
matching: find.byType(Scrollable),
|
||||||
|
);
|
||||||
|
final position = tester.state<ScrollableState>(scrollable.first).position;
|
||||||
|
position.jumpTo(position.maxScrollExtent);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
MediaQuery.paddingOf(tester.element(body)).bottom,
|
||||||
|
greaterThanOrEqualTo(844 - pill.top),
|
||||||
|
);
|
||||||
|
|
||||||
await pumpRunDetail(tester, platform, size: const Size(1000, 844));
|
await pumpRunDetail(tester, platform, size: const Size(1000, 844));
|
||||||
final wideStrip = tester.getRect(
|
final widePill = tester.getRect(
|
||||||
find.byKey(const Key('run-detail-tabs')),
|
find.descendant(of: strip, matching: find.byType(GlassPill)),
|
||||||
);
|
);
|
||||||
final wideBody = tester.getRect(
|
expect(widePill.right, 1000 - 16);
|
||||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
expect(widePill.bottom, 844 - 16);
|
||||||
);
|
expect(widePill.width, lessThan(1000 * 0.6));
|
||||||
expect(wideStrip.bottom, lessThanOrEqualTo(wideBody.top));
|
// Beside the bar the content takes taps: the body spans the width.
|
||||||
|
expect(tester.getRect(body).width, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('${platform.name} missing graph states the exact wording', (
|
testWidgets('${platform.name} missing graph states the exact wording', (
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart'
|
|||||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
|
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
|
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
|
||||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
|
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||||
import 'package:pipelines_app/ui/layout/sticky_section.dart';
|
import 'package:pipelines_app/ui/layout/sticky_section.dart';
|
||||||
|
|
||||||
import 'run_detail_graph_support.dart';
|
import 'run_detail_graph_support.dart';
|
||||||
@@ -236,6 +237,22 @@ void main() {
|
|||||||
final strip = tester.getRect(find.byType(RunVisitSectionStrip));
|
final strip = tester.getRect(find.byType(RunVisitSectionStrip));
|
||||||
expect(strip.bottom, size.height, reason: section.name);
|
expect(strip.bottom, size.height, reason: section.name);
|
||||||
}
|
}
|
||||||
|
// The floating glass bar: full width on a phone, sized to its tabs
|
||||||
|
// at the right edge of a wide page.
|
||||||
|
final pill = tester.getRect(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(RunVisitSectionStrip),
|
||||||
|
matching: find.byType(GlassPill),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(pill.right, size.width - 16);
|
||||||
|
expect(pill.bottom, size.height - 16);
|
||||||
|
if (size.width < 600) {
|
||||||
|
expect(pill.left, 16);
|
||||||
|
} else {
|
||||||
|
// (The test font draws every glyph a full em wide.)
|
||||||
|
expect(pill.width, lessThan(size.width * 0.7));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
|||||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||||
|
|
||||||
/// The Runs tab mirrors the attention count in every mount of both hosts:
|
/// The Runs tab mirrors the attention count in every mount of both hosts:
|
||||||
/// Material rail and bottom bar, Cupertino sidebar and tab bar. Zero draws the
|
/// the floating tab bar at full width on a phone and right-aligned on a wide
|
||||||
|
/// window. Zero draws the
|
||||||
/// bare icon with no count and no attention semantics.
|
/// bare icon with no count and no attention semantics.
|
||||||
void main() {
|
void main() {
|
||||||
final needingAttention = RegExp('Notifications, 3 needing attention');
|
final needingAttention = RegExp('Notifications, 3 needing attention');
|
||||||
@@ -27,17 +28,15 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final width in [390.0, 1000.0]) {
|
for (final width in [390.0, 1000.0]) {
|
||||||
final mount = width < 600 ? 'bottom bar' : 'rail';
|
final mount = width < 600 ? 'bottom bar' : 'wide bar';
|
||||||
|
|
||||||
testWidgets('Material $mount shows the count on the Runs tab', (
|
testWidgets('Material $mount shows the count on the Runs tab', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
final semantics = tester.ensureSemantics();
|
final semantics = tester.ensureSemantics();
|
||||||
await pumpShell(tester, width: width, cupertino: false, count: 3);
|
await pumpShell(tester, width: width, cupertino: false, count: 3);
|
||||||
expect(
|
expect(find.byType(NavigationBar), findsOneWidget);
|
||||||
find.byType(width < 600 ? NavigationBar : NavigationRail),
|
expect(find.byType(NavigationRail), findsNothing);
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
final badge = find.byType(Badge);
|
final badge = find.byType(Badge);
|
||||||
expect(badge, findsOneWidget);
|
expect(badge, findsOneWidget);
|
||||||
expect(tester.widget<Badge>(badge).isLabelVisible, isTrue);
|
expect(tester.widget<Badge>(badge).isLabelVisible, isTrue);
|
||||||
@@ -68,17 +67,14 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final width in [390.0, 1280.0]) {
|
for (final width in [390.0, 1280.0]) {
|
||||||
final mount = width < 600 ? 'tab bar' : 'sidebar';
|
final mount = width < 600 ? 'tab bar' : 'wide tab bar';
|
||||||
|
|
||||||
testWidgets('Cupertino $mount shows the count on the Runs item', (
|
testWidgets('Cupertino $mount shows the count on the Runs item', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
final semantics = tester.ensureSemantics();
|
final semantics = tester.ensureSemantics();
|
||||||
await pumpShell(tester, width: width, cupertino: true, count: 3);
|
await pumpShell(tester, width: width, cupertino: true, count: 3);
|
||||||
expect(
|
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||||
find.byType(CupertinoTabBar),
|
|
||||||
width < 600 ? findsOneWidget : findsNothing,
|
|
||||||
);
|
|
||||||
expect(find.byType(Badge), findsNothing, reason: 'no Material badge');
|
expect(find.byType(Badge), findsNothing, reason: 'no Material badge');
|
||||||
expect(find.text('3'), findsOneWidget);
|
expect(find.text('3'), findsOneWidget);
|
||||||
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
|
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||||
|
import 'package:pipelines_app/shell/destination.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||||
|
|
||||||
|
/// The shell's one floating glass tab bar: full width on a phone, sized to its
|
||||||
|
/// tabs at the right edge on a wide window, with content behind it.
|
||||||
|
void main() {
|
||||||
|
Finder pill() => find.descendant(
|
||||||
|
of: find.byType(FloatingDestinationBar),
|
||||||
|
matching: find.byType(GlassPill),
|
||||||
|
);
|
||||||
|
|
||||||
|
Finder barText(String label) => find.descendant(
|
||||||
|
of: find.byType(FloatingDestinationBar),
|
||||||
|
matching: find.text(label),
|
||||||
|
);
|
||||||
|
|
||||||
|
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||||
|
tester.view.physicalSize = size;
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
}
|
||||||
|
|
||||||
|
var taps = 0;
|
||||||
|
double? contentBottomPadding;
|
||||||
|
|
||||||
|
Widget shell({required bool cupertino}) {
|
||||||
|
final app = AdaptiveShell(
|
||||||
|
cupertino: cupertino,
|
||||||
|
destinationBodies: {
|
||||||
|
AppDestination.pipelines: (_) => Builder(
|
||||||
|
builder: (context) {
|
||||||
|
contentBottomPadding = MediaQuery.paddingOf(context).bottom;
|
||||||
|
return StatefulBuilder(
|
||||||
|
builder: (context, setState) => GestureDetector(
|
||||||
|
key: const Key('content'),
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: () => setState(() => taps++),
|
||||||
|
child: SizedBox.expand(child: Text('taps $taps')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
final host = cupertino ? 'Cupertino' : 'Material';
|
||||||
|
|
||||||
|
testWidgets('$host: phone bar spans the width minus its margins', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await setSize(tester, const Size(390, 844));
|
||||||
|
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||||
|
final rect = tester.getRect(pill());
|
||||||
|
expect(rect.left, 16);
|
||||||
|
expect(rect.right, 390 - 16);
|
||||||
|
expect(rect.bottom, 844 - 16);
|
||||||
|
expect(find.byType(NavigationRail), findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: wide bar hugs its tabs at the right edge, content '
|
||||||
|
'keeps the width and taps beside the bar reach it', (tester) async {
|
||||||
|
taps = 0;
|
||||||
|
await setSize(tester, const Size(1200, 800));
|
||||||
|
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||||
|
final rect = tester.getRect(pill());
|
||||||
|
expect(rect.right, 1200 - 16);
|
||||||
|
expect(rect.bottom, 800 - 16);
|
||||||
|
expect(rect.width, lessThan(1200 * 0.6));
|
||||||
|
expect(rect.width, greaterThan(5 * 72));
|
||||||
|
// No rail or sidebar: the content starts at the left edge.
|
||||||
|
expect(find.byType(NavigationRail), findsNothing);
|
||||||
|
expect(find.byType(CupertinoListTile), findsNothing);
|
||||||
|
expect(tester.getRect(find.byKey(const Key('content'))).left, 0);
|
||||||
|
// Beside the bar, at the bar's height, the content takes the tap.
|
||||||
|
await tester.tapAt(Offset(rect.left - 40, rect.center.dy));
|
||||||
|
await tester.pump();
|
||||||
|
expect(taps, 1);
|
||||||
|
// On the bar, the tab takes it.
|
||||||
|
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: content learns the bar height as bottom padding', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
for (final size in const [Size(390, 844), Size(1200, 800)]) {
|
||||||
|
await setSize(tester, size);
|
||||||
|
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||||
|
await tester.pump();
|
||||||
|
final rect = tester.getRect(pill());
|
||||||
|
// The content's bottom padding clears the whole bar and its margin.
|
||||||
|
expect(
|
||||||
|
contentBottomPadding,
|
||||||
|
moreOrLessEquals(size.height - rect.top, epsilon: 0.5),
|
||||||
|
reason: '$size',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: resizing moves the bar without remounting content', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
taps = 0;
|
||||||
|
await setSize(tester, const Size(390, 844));
|
||||||
|
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||||
|
await tester.tap(find.byKey(const Key('content')));
|
||||||
|
await tester.pump();
|
||||||
|
expect(find.text('taps 1'), findsOneWidget);
|
||||||
|
final state = tester.state(find.byType(StatefulBuilder));
|
||||||
|
|
||||||
|
tester.view.physicalSize = const Size(1200, 800);
|
||||||
|
await tester.pump();
|
||||||
|
expect(tester.getRect(pill()).right, 1200 - 16);
|
||||||
|
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
|
||||||
|
expect(tester.state(find.byType(StatefulBuilder)), same(state));
|
||||||
|
|
||||||
|
tester.view.physicalSize = const Size(390, 844);
|
||||||
|
await tester.pump();
|
||||||
|
expect(tester.getRect(pill()).width, 390 - 32);
|
||||||
|
expect(tester.state(find.byType(StatefulBuilder)), same(state));
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: the bar respects the bottom safe area', (tester) async {
|
||||||
|
await setSize(tester, const Size(390, 844));
|
||||||
|
tester.view.padding = const FakeViewPadding(bottom: 34);
|
||||||
|
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||||
|
expect(tester.getRect(pill()).bottom, 844 - 34);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: the selected tab is marked selected for assistive '
|
||||||
|
'technology', (tester) async {
|
||||||
|
final semantics = tester.ensureSemantics();
|
||||||
|
await setSize(tester, const Size(1200, 800));
|
||||||
|
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||||
|
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
tester.getSemantics(barText('Runs')),
|
||||||
|
isSemantics(isSelected: true),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
tester.getSemantics(barText('Chat')),
|
||||||
|
isNot(isSemantics(isSelected: true)),
|
||||||
|
);
|
||||||
|
semantics.dispose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
testWidgets('Cupertino bar builds no Material widget', (tester) async {
|
||||||
|
await setSize(tester, const Size(1200, 800));
|
||||||
|
await tester.pumpWidget(shell(cupertino: true));
|
||||||
|
expect(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(FloatingDestinationBar),
|
||||||
|
matching: find.byWidgetPredicate(
|
||||||
|
(widget) =>
|
||||||
|
widget is Material ||
|
||||||
|
widget is NavigationBar ||
|
||||||
|
widget is InkWell,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
findsNothing,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('phone at 320 with 2x text does not overflow', (tester) async {
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
await setSize(tester, const Size(320, 568));
|
||||||
|
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||||
|
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||||
|
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
expect(tester.getRect(pill()).width, 320 - 32);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
Widget page({
|
||||||
|
required Widget Function(BuildContext) list,
|
||||||
|
VoidCallback? onTap,
|
||||||
|
}) => MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: FloatingBarOverlay(
|
||||||
|
bar: FloatingDestinationBar(
|
||||||
|
cupertino: false,
|
||||||
|
currentIndex: 0,
|
||||||
|
onTap: (_) {},
|
||||||
|
items: const [
|
||||||
|
FloatingDestinationItem(icon: Icon(Icons.list), label: 'One'),
|
||||||
|
FloatingDestinationItem(icon: Icon(Icons.map), label: 'Two'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: GestureDetector(
|
||||||
|
behavior: HitTestBehavior.translucent,
|
||||||
|
onTap: onTap,
|
||||||
|
child: Builder(builder: list),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (final width in [390.0, 1200.0]) {
|
||||||
|
testWidgets('a padded list scrolls behind the bar and its last item '
|
||||||
|
'clears it at rest (width $width)', (tester) async {
|
||||||
|
tester.view.physicalSize = Size(width, 800);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
page(
|
||||||
|
list: (context) => ListView(
|
||||||
|
padding: withFloatingBarClearance(
|
||||||
|
context,
|
||||||
|
const EdgeInsets.all(16),
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
for (var i = 0; i < 40; i += 1)
|
||||||
|
SizedBox(height: 48, child: Text('Item $i')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final pill = tester.getRect(find.byType(GlassPill));
|
||||||
|
// The list fills the area, behind the bar.
|
||||||
|
expect(tester.getRect(find.byType(ListView)).bottom, 800);
|
||||||
|
await tester.drag(find.byType(ListView), const Offset(0, -5000));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
final last = tester.getRect(find.text('Item 39'));
|
||||||
|
expect(last.bottom, lessThanOrEqualTo(pill.top));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
testWidgets('taps beside a wide bar reach the content', (tester) async {
|
||||||
|
tester.view.physicalSize = const Size(1200, 800);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.reset);
|
||||||
|
var taps = 0;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
page(list: (_) => const SizedBox.expand(), onTap: () => taps++),
|
||||||
|
);
|
||||||
|
final pill = tester.getRect(find.byType(GlassPill));
|
||||||
|
expect(pill.right, 1200 - kFloatingBarMargin);
|
||||||
|
await tester.tapAt(Offset(pill.left - 24, pill.center.dy));
|
||||||
|
expect(taps, 1);
|
||||||
|
await tester.tapAt(pill.center);
|
||||||
|
expect(taps, 1, reason: 'the bar takes its own taps');
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -24,14 +24,10 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(find.text('Pipelines'), findsWidgets);
|
expect(find.text('Pipelines'), findsWidgets);
|
||||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||||
expect(
|
// One floating tab bar at every width; no rail.
|
||||||
find.byType(NavigationBar),
|
expect(find.byType(NavigationBar), findsOneWidget);
|
||||||
width < 600 ? findsOneWidget : findsNothing,
|
expect(find.byType(NavigationRail), findsNothing);
|
||||||
);
|
expect(tester.takeException(), isNull);
|
||||||
expect(
|
|
||||||
find.byType(NavigationRail),
|
|
||||||
width >= 600 ? findsOneWidget : findsNothing,
|
|
||||||
);
|
|
||||||
await tester.tap(find.text('Runs').last);
|
await tester.tap(find.text('Runs').last);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.text('Runs — Not implemented'), findsOneWidget);
|
expect(find.text('Runs — Not implemented'), findsOneWidget);
|
||||||
@@ -53,7 +49,7 @@ void main() {
|
|||||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Cupertino shell uses a sidebar on a wide window', (
|
testWidgets('Cupertino shell floats its tab bar on a wide window', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
tester.view.physicalSize = const Size(1280, 900);
|
tester.view.physicalSize = const Size(1280, 900);
|
||||||
@@ -61,7 +57,8 @@ void main() {
|
|||||||
addTearDown(tester.view.resetPhysicalSize);
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
addTearDown(tester.view.resetDevicePixelRatio);
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||||
expect(find.byType(CupertinoTabBar), findsNothing);
|
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||||
|
expect(find.byType(CupertinoListTile), findsNothing);
|
||||||
expect(
|
expect(
|
||||||
find.byKey(const ValueKey('shell.destination.pipelines')),
|
find.byKey(const ValueKey('shell.destination.pipelines')),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
// Standalone browser fixture for the floating glass tab bar in the shell.
|
||||||
|
//
|
||||||
|
// Build and capture (from app/):
|
||||||
|
// flutter build web --target tool/floating_tabs_probe_entry.dart \
|
||||||
|
// -o build/probe-floating-tabs
|
||||||
|
// python3 -I -m http.server 0 --bind 127.0.0.1 \
|
||||||
|
// --directory build/probe-floating-tabs
|
||||||
|
// Chrome --headless=new --window-size=W,H --screenshot=OUT \
|
||||||
|
// 'http://127.0.0.1:PORT/?platform=cupertino&theme=dark'
|
||||||
|
//
|
||||||
|
// Query: platform=cupertino (else Material), theme=dark, tab=runs|chat|...
|
||||||
|
// The destinations are long local lists, so the capture shows content passing
|
||||||
|
// behind the bar and the last row clearing it. No server is involved.
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||||
|
import 'package:pipelines_app/shell/destination.dart';
|
||||||
|
import 'package:pipelines_app/shell/shell_bar.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
final params = Uri.base.queryParameters;
|
||||||
|
final cupertino = params['platform'] == 'cupertino';
|
||||||
|
final dark = params['theme'] == 'dark';
|
||||||
|
final tab = AppDestination.values.firstWhere(
|
||||||
|
(value) => value.name == params['tab'],
|
||||||
|
orElse: () => AppDestination.pipelines,
|
||||||
|
);
|
||||||
|
final end = params['end'] == '1';
|
||||||
|
runApp(_Probe(cupertino: cupertino, dark: dark, tab: tab, end: end));
|
||||||
|
}
|
||||||
|
|
||||||
|
class _Probe extends StatelessWidget {
|
||||||
|
const _Probe({
|
||||||
|
required this.cupertino,
|
||||||
|
required this.dark,
|
||||||
|
required this.tab,
|
||||||
|
required this.end,
|
||||||
|
});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final bool dark;
|
||||||
|
final AppDestination tab;
|
||||||
|
|
||||||
|
/// Starts every list scrolled to its end, to show the last row at rest.
|
||||||
|
final bool end;
|
||||||
|
|
||||||
|
Widget _list(String noun, {required int count}) =>
|
||||||
|
_ProbeList(noun: noun, count: count, cupertino: cupertino, end: end);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final shell = AdaptiveShell(
|
||||||
|
cupertino: cupertino,
|
||||||
|
destination: tab,
|
||||||
|
attentionCount: 3,
|
||||||
|
destinationBodies: {
|
||||||
|
AppDestination.pipelines: (_) => _list('Pipeline', count: 40),
|
||||||
|
AppDestination.runs: (_) => ShellBadge(
|
||||||
|
kind: ShellBadgeKind.running,
|
||||||
|
count: 2,
|
||||||
|
child: _list('Run', count: 40),
|
||||||
|
),
|
||||||
|
AppDestination.chat: (_) => ShellBadge(
|
||||||
|
kind: ShellBadgeKind.unread,
|
||||||
|
count: 1,
|
||||||
|
child: _list('Chat', count: 12),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (cupertino) {
|
||||||
|
return CupertinoApp(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
theme: CupertinoThemeData(
|
||||||
|
brightness: dark ? Brightness.dark : Brightness.light,
|
||||||
|
),
|
||||||
|
home: shell,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return MaterialApp(
|
||||||
|
debugShowCheckedModeBanner: false,
|
||||||
|
theme: ThemeData(
|
||||||
|
brightness: dark ? Brightness.dark : Brightness.light,
|
||||||
|
colorSchemeSeed: Colors.indigo,
|
||||||
|
),
|
||||||
|
home: shell,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProbeList extends StatefulWidget {
|
||||||
|
const _ProbeList({
|
||||||
|
required this.noun,
|
||||||
|
required this.count,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.end,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String noun;
|
||||||
|
final int count;
|
||||||
|
final bool cupertino;
|
||||||
|
final bool end;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_ProbeList> createState() => _ProbeListState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ProbeListState extends State<_ProbeList> {
|
||||||
|
final _scroll = ScrollController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
if (widget.end) {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if (_scroll.hasClients) {
|
||||||
|
_scroll.jumpTo(_scroll.position.maxScrollExtent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_scroll.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
// No explicit padding: the list pads itself by the media insets, which
|
||||||
|
// include the floating bar's height.
|
||||||
|
return ListView.builder(
|
||||||
|
controller: _scroll,
|
||||||
|
itemCount: widget.count,
|
||||||
|
itemBuilder: (context, index) {
|
||||||
|
final title = '${widget.noun} ${index + 1}';
|
||||||
|
final subtitle = index.isEven
|
||||||
|
? 'Succeeded · 2m 05s'
|
||||||
|
: 'Running · started 1m ago';
|
||||||
|
if (widget.cupertino) {
|
||||||
|
return CupertinoListTile(
|
||||||
|
leading: const Icon(CupertinoIcons.circle_fill, size: 12),
|
||||||
|
title: Text(title),
|
||||||
|
subtitle: Text(subtitle),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return ListTile(
|
||||||
|
leading: Icon(
|
||||||
|
index.isEven ? Icons.check_circle_outline : Icons.timelapse,
|
||||||
|
),
|
||||||
|
title: Text(title),
|
||||||
|
subtitle: Text(subtitle),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user