From 6e6559235fb7cc1caf8cfce5182d8b4d98645ebe Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sun, 1 Nov 2026 12:43:27 +0000 Subject: [PATCH 1/2] WIP: expandable run title (run #224) --- app/lib/features/runs/ui/run_detail_view.dart | 42 +++++-- app/lib/shell/adaptive_shell.dart | 2 + app/lib/shell/detail_page.dart | 2 + app/lib/shell/shell_bar.dart | 10 ++ app/lib/ui/adaptive/segmented_bar.dart | 110 +++++++++++++++--- app/lib/ui/adaptive/segmented_bar_pieces.dart | 99 ++++++++++------ .../runs/ui/run_detail_header_test.dart | 4 + 7 files changed, 210 insertions(+), 59 deletions(-) diff --git a/app/lib/features/runs/ui/run_detail_view.dart b/app/lib/features/runs/ui/run_detail_view.dart index 57bf6b44..d923c8e1 100644 --- a/app/lib/features/runs/ui/run_detail_view.dart +++ b/app/lib/features/runs/ui/run_detail_view.dart @@ -111,6 +111,34 @@ class _RunDetailViewState extends State { final subtitle = detailSubtitle(run); final openPipeline = _openPipeline(run); final pipelineName = detailPipeline(run); + final pipelineAction = openPipeline == null + ? null + : (cupertino + ? Semantics( + button: true, + label: 'Open pipeline $pipelineName', + child: CupertinoButton( + key: runPipelineLinkKey, + padding: EdgeInsets.zero, + minimumSize: Size.zero, + onPressed: openPipeline, + child: const Icon(CupertinoIcons.arrow_branch), + ), + ) + : Semantics( + button: true, + label: 'Open pipeline $pipelineName', + excludeSemantics: true, + child: GestureDetector( + key: runPipelineLinkKey, + behavior: HitTestBehavior.opaque, + onTap: openPipeline, + child: const Padding( + padding: EdgeInsets.all(12), + child: Icon(Icons.account_tree_outlined), + ), + ), + )); final more = RunMoreMenu( run: run, gateway: widget.gateway, @@ -124,10 +152,9 @@ class _RunDetailViewState extends State { title: title, subtitle: subtitle, onTitlePressed: openPipeline, - titleSemanticLabel: openPipeline == null - ? null - : 'Open pipeline $pipelineName', - titleKey: openPipeline == null ? null : runPipelineLinkKey, + expandableTitle: true, + titleAction: pipelineAction, + titleSemanticLabel: 'Run title $title', onBack: widget.onBack, actions: [more], child: detail, @@ -145,10 +172,9 @@ class _RunDetailViewState extends State { title: title, subtitle: subtitle, onTitlePressed: openPipeline, - titleSemanticLabel: openPipeline == null - ? null - : 'Open pipeline $pipelineName', - titleKey: openPipeline == null ? null : runPipelineLinkKey, + expandableTitle: true, + titleAction: pipelineAction, + titleSemanticLabel: 'Run title $title', actions: [more], ), child: detail, diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index 17a7eb51..365928b3 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -277,6 +277,8 @@ class _AdaptiveShellState extends State { subtitle: spec?.subtitle, subtitleIcon: spec?.subtitleIcon, onTitlePressed: spec?.onTitlePressed, + expandableTitle: spec?.expandableTitle ?? false, + titleAction: spec?.titleAction, titleSemanticLabel: spec?.titleSemanticLabel, titleKey: spec?.titleKey, actions: [ diff --git a/app/lib/shell/detail_page.dart b/app/lib/shell/detail_page.dart index f5a4a1a0..0de9f47e 100644 --- a/app/lib/shell/detail_page.dart +++ b/app/lib/shell/detail_page.dart @@ -144,6 +144,8 @@ class _DetailPaneState extends State { subtitle: spec?.subtitle, subtitleIcon: spec?.subtitleIcon, onTitlePressed: spec?.onTitlePressed, + expandableTitle: spec?.expandableTitle ?? false, + titleAction: spec?.titleAction, titleSemanticLabel: spec?.titleSemanticLabel, titleKey: spec?.titleKey, actions: actions, diff --git a/app/lib/shell/shell_bar.dart b/app/lib/shell/shell_bar.dart index f668067a..e621426b 100644 --- a/app/lib/shell/shell_bar.dart +++ b/app/lib/shell/shell_bar.dart @@ -10,6 +10,8 @@ class ShellBarSpec { this.subtitle, this.subtitleIcon, this.onTitlePressed, + this.expandableTitle = false, + this.titleAction, this.titleSemanticLabel, this.titleKey, this.onBack, @@ -38,6 +40,8 @@ class ShellBarSpec { /// Makes the title pill a button; see `SegmentedBar.onTitlePressed`. final VoidCallback? onTitlePressed; + final bool expandableTitle; + final Widget? titleAction; final String? titleSemanticLabel; final Key? titleKey; final VoidCallback? onBack; @@ -136,6 +140,8 @@ class ShellBar extends StatefulWidget { this.subtitle, this.subtitleIcon, this.onTitlePressed, + this.expandableTitle = false, + this.titleAction, this.titleSemanticLabel, this.titleKey, this.onBack, @@ -168,6 +174,8 @@ class ShellBar extends StatefulWidget { final String? subtitle; final IconData? subtitleIcon; final VoidCallback? onTitlePressed; + final bool expandableTitle; + final Widget? titleAction; final String? titleSemanticLabel; final Key? titleKey; final VoidCallback? onBack; @@ -207,6 +215,8 @@ class _ShellBarState extends State { subtitle: widget.subtitle, subtitleIcon: widget.subtitleIcon, onTitlePressed: widget.onTitlePressed, + expandableTitle: widget.expandableTitle, + titleAction: widget.titleAction, titleSemanticLabel: widget.titleSemanticLabel, titleKey: widget.titleKey, onBack: widget.onBack, diff --git a/app/lib/ui/adaptive/segmented_bar.dart b/app/lib/ui/adaptive/segmented_bar.dart index c1247e6d..ce9dea59 100644 --- a/app/lib/ui/adaptive/segmented_bar.dart +++ b/app/lib/ui/adaptive/segmented_bar.dart @@ -28,7 +28,7 @@ export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill; /// bar's height through [MediaQuery.paddingOf], so a page keeps its /// scaffold's structure; [SegmentedBarOverlay] does the same anywhere else. /// It handles the top safe area itself. -class SegmentedBar extends StatelessWidget +class SegmentedBar extends StatefulWidget implements ObstructingPreferredSizeWidget { const SegmentedBar({ super.key, @@ -41,6 +41,8 @@ class SegmentedBar extends StatelessWidget this.subtitle, this.subtitleIcon, this.onTitlePressed, + this.expandableTitle = false, + this.titleAction, this.titleSemanticLabel, this.titleKey, this.actions = const [], @@ -79,6 +81,12 @@ class SegmentedBar extends StatelessWidget /// Makes the title pill a button (an information page, a picker). final VoidCallback? onTitlePressed; + + /// Lets the title expand over the content without changing bar clearance. + final bool expandableTitle; + + /// An action shown inside the expanded title pill. + final Widget? titleAction; final String? titleSemanticLabel; /// The key of the title's button (or its content when not pressable). @@ -142,14 +150,64 @@ class SegmentedBar extends StatelessWidget Theme.of(context).scaffoldBackgroundColor; } + @override + State createState() => _SegmentedBarState(); +} + +class _SegmentedBarState extends State { + bool _expanded = false; + + @override + void didUpdateWidget(covariant SegmentedBar oldWidget) { + super.didUpdateWidget(oldWidget); + if (oldWidget.title != widget.title || + oldWidget.subtitle != widget.subtitle) { + _expanded = false; + } + } + + void _toggleTitle() { + setState(() => _expanded = !_expanded); + } + @override Widget build(BuildContext context) { + final cupertino = widget.cupertino; + final title = widget.title; + final titleWidget = widget.titleWidget; + final titleWidgetMaxWidth = widget.titleWidgetMaxWidth; + final leadingWidget = widget.leading; + final automaticallyImplyLeading = widget.automaticallyImplyLeading; + final subtitle = widget.subtitle; + final subtitleIcon = widget.subtitleIcon; + final onTitlePressed = widget.onTitlePressed; + final titleSemanticLabel = widget.titleSemanticLabel; + final titleKey = widget.titleKey; + final actions = widget.actions; + final pillColor = widget.pillColor; + final foregroundColor = widget.foregroundColor; + final bottomPadding = widget.bottomPadding; final leading = - this.leading ?? + leadingWidget ?? (automaticallyImplyLeading ? impliedSegmentedLeading(context, cupertino) : null); final showTitle = title.isNotEmpty || (subtitle ?? '').isNotEmpty; + Widget titlePill(bool expanded) => SegmentedTitlePill( + cupertino: cupertino, + title: title, + subtitle: subtitle, + subtitleIcon: subtitleIcon, + onPressed: widget.expandableTitle ? _toggleTitle : onTitlePressed, + semanticLabel: widget.expandableTitle + ? '${titleSemanticLabel ?? title}, ${expanded ? 'expanded' : 'collapsed'}' + : titleSemanticLabel, + buttonKey: expanded ? null : titleKey, + expanded: expanded, + titleAction: expanded ? widget.titleAction : null, + foreground: foregroundColor, + fill: pillColor, + ); final Widget bar = LayoutBuilder( builder: (context, constraints) => Row( children: [ @@ -183,16 +241,36 @@ class SegmentedBar extends StatelessWidget ), ) : showTitle - ? SegmentedTitlePill( - cupertino: cupertino, - title: title, - subtitle: subtitle, - subtitleIcon: subtitleIcon, - onPressed: onTitlePressed, - semanticLabel: titleSemanticLabel, - buttonKey: titleKey, - foreground: foregroundColor, - fill: pillColor, + ? Align( + alignment: AlignmentDirectional.centerStart, + widthFactor: _expanded && widget.expandableTitle + ? null + : 1, + child: ConstrainedBox( + constraints: _expanded && widget.expandableTitle + ? BoxConstraints(minWidth: constraints.maxWidth) + : const BoxConstraints(), + child: Stack( + clipBehavior: Clip.none, + children: [ + ExcludeSemantics( + excluding: _expanded && widget.expandableTitle, + child: titlePill(false), + ), + if (_expanded && widget.expandableTitle) + Positioned( + top: 0, + left: 0, + child: ConstrainedBox( + constraints: BoxConstraints( + maxWidth: constraints.maxWidth, + ), + child: titlePill(true), + ), + ), + ], + ), + ), ) : const SizedBox.shrink(), ), @@ -211,7 +289,7 @@ class SegmentedBar extends StatelessWidget ? 0 : segmentedPieceHeight(cupertino) + 8) - 8 - - constraints.maxWidth * minTitleShare, + constraints.maxWidth * SegmentedBar.minTitleShare, ), ), child: SegmentedPill( @@ -230,7 +308,7 @@ class SegmentedBar extends StatelessWidget ], ), ); - final background = _background(context); + final background = widget._background(context); final inset = MediaQuery.paddingOf(context).top; return Stack( children: [ @@ -271,12 +349,12 @@ class SegmentedBar extends StatelessWidget child: Padding( padding: EdgeInsetsDirectional.fromSTEB( 12, - _topPadding, + SegmentedBar._topPadding, 12, bottomPadding, ), child: MediaQuery.withClampedTextScaling( - maxScaleFactor: maxTextScale, + maxScaleFactor: SegmentedBar.maxTextScale, child: bar, ), ), diff --git a/app/lib/ui/adaptive/segmented_bar_pieces.dart b/app/lib/ui/adaptive/segmented_bar_pieces.dart index 1dc46c36..a3c4bc5a 100644 --- a/app/lib/ui/adaptive/segmented_bar_pieces.dart +++ b/app/lib/ui/adaptive/segmented_bar_pieces.dart @@ -94,6 +94,8 @@ class SegmentedTitlePill extends StatelessWidget { this.onPressed, this.semanticLabel, this.buttonKey, + this.expanded = false, + this.titleAction, this.foreground, this.fill, }); @@ -107,6 +109,8 @@ class SegmentedTitlePill extends StatelessWidget { /// The key of the pressable title, for finders. final Key? buttonKey; + final bool expanded; + final Widget? titleAction; final Color? foreground; final Color? fill; @@ -137,44 +141,56 @@ class SegmentedTitlePill extends StatelessWidget { final subtitle = this.subtitle ?? ''; final content = Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), - child: Column( + child: Row( mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, children: [ - Semantics( - header: true, - child: Text( - title, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: titleStyle, + Flexible( + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Semantics( + header: true, + child: Text( + title, + maxLines: expanded ? null : 1, + overflow: expanded + ? TextOverflow.visible + : TextOverflow.ellipsis, + style: titleStyle, + ), + ), + if (subtitle.isNotEmpty) + // One line that ellipsises as a whole, so a narrow pill never + // overflows on the icon. + Text.rich( + TextSpan( + children: [ + if (subtitleIcon != null) ...[ + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: Icon( + subtitleIcon, + size: subtitleStyle.fontSize, + color: subtitleStyle.color, + ), + ), + const TextSpan(text: ' '), + ], + TextSpan(text: subtitle), + ], + ), + maxLines: expanded ? null : 1, + overflow: expanded + ? TextOverflow.visible + : TextOverflow.ellipsis, + style: subtitleStyle, + ), + ], ), ), - if (subtitle.isNotEmpty) - // One line that ellipsises as a whole, so a narrow pill never - // overflows on the icon. - Text.rich( - TextSpan( - children: [ - if (subtitleIcon != null) ...[ - WidgetSpan( - alignment: PlaceholderAlignment.middle, - child: Icon( - subtitleIcon, - size: subtitleStyle.fontSize, - color: subtitleStyle.color, - ), - ), - const TextSpan(text: ' '), - ], - TextSpan(text: subtitle), - ], - ), - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: subtitleStyle, - ), ], ), ); @@ -200,6 +216,19 @@ class SegmentedTitlePill extends StatelessWidget { : InkWell(key: buttonKey, onTap: onPressed, child: content), ); } - return SegmentedPill(cupertino: cupertino, fill: fill, child: body); + return SegmentedPill( + cupertino: cupertino, + fill: fill, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Flexible( + fit: FlexFit.loose, + child: IntrinsicWidth(child: body), + ), + ?titleAction, + ], + ), + ); } } diff --git a/app/test/features/runs/ui/run_detail_header_test.dart b/app/test/features/runs/ui/run_detail_header_test.dart index 2aaa1700..f0c80d93 100644 --- a/app/test/features/runs/ui/run_detail_header_test.dart +++ b/app/test/features/runs/ui/run_detail_header_test.dart @@ -86,6 +86,10 @@ void main() { cupertino, onOpenPipeline: (id, version) => opened.add((id, version)), ); + // The title expands first; the pipeline action is intentionally only + // available in that expanded state. + await tester.tap(find.text('Nightly build').first); + await tester.pump(); await tester.tap(find.byKey(runPipelineLinkKey)); await tester.pump(); expect(opened, [(10, 3)]); From 331509106c405e8b1a95d9ff2cf8cf25d1d73909 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sun, 1 Nov 2026 12:57:44 +0000 Subject: [PATCH 2/2] Expandable run title: full title on tap, pipeline link as an icon Tapping the run detail's title expands it to the whole title and subtitle with an icon button that opens the pipeline; tapping again, or another run, collapses it. The expanded title is drawn in the overlay, anchored to the bar and sized beside the actions, so its pipeline icon receives taps and the actions stay visible. Other bars keep their title behaviour. Finishes run #224. --- app/lib/ui/adaptive/segmented_bar.dart | 56 +++++++++++++++----------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/app/lib/ui/adaptive/segmented_bar.dart b/app/lib/ui/adaptive/segmented_bar.dart index ce9dea59..3eda670b 100644 --- a/app/lib/ui/adaptive/segmented_bar.dart +++ b/app/lib/ui/adaptive/segmented_bar.dart @@ -157,6 +157,12 @@ class SegmentedBar extends StatefulWidget class _SegmentedBarState extends State { bool _expanded = false; + /// The expanded title is drawn in the overlay, anchored to the collapsed + /// pill: drawn inside the bar it would overflow the bar's bounds, where + /// its pipeline action could be seen but not tapped. + final _titleLink = LayerLink(); + final _expandedTitle = OverlayPortalController(); + @override void didUpdateWidget(covariant SegmentedBar oldWidget) { super.didUpdateWidget(oldWidget); @@ -167,6 +173,10 @@ class _SegmentedBarState extends State { } void _toggleTitle() { + // The portal stays attached once used and draws nothing while + // collapsed, so collapsing on a new run (during a rebuild) needs no + // overlay call. + if (!_expandedTitle.isShowing) _expandedTitle.show(); setState(() => _expanded = !_expanded); } @@ -240,35 +250,35 @@ class _SegmentedBarState extends State { ), ), ) + : showTitle && !widget.expandableTitle + ? titlePill(false) : showTitle - ? Align( - alignment: AlignmentDirectional.centerStart, - widthFactor: _expanded && widget.expandableTitle - ? null - : 1, - child: ConstrainedBox( - constraints: _expanded && widget.expandableTitle - ? BoxConstraints(minWidth: constraints.maxWidth) - : const BoxConstraints(), - child: Stack( - clipBehavior: Clip.none, - children: [ - ExcludeSemantics( - excluding: _expanded && widget.expandableTitle, - child: titlePill(false), - ), - if (_expanded && widget.expandableTitle) - Positioned( + ? LayoutBuilder( + builder: (context, titleSpace) => OverlayPortal( + controller: _expandedTitle, + overlayChildBuilder: (context) => + !(_expanded && widget.expandableTitle) + ? const SizedBox.shrink() + : Positioned( top: 0, left: 0, - child: ConstrainedBox( - constraints: BoxConstraints( - maxWidth: constraints.maxWidth, + child: CompositedTransformFollower( + link: _titleLink, + showWhenUnlinked: false, + child: ConstrainedBox( + constraints: BoxConstraints( + maxWidth: titleSpace.maxWidth, + ), + child: titlePill(true), ), - child: titlePill(true), ), ), - ], + child: CompositedTransformTarget( + link: _titleLink, + child: ExcludeSemantics( + excluding: _expanded && widget.expandableTitle, + child: titlePill(false), + ), ), ), )