Merge commit '09389f18cb01effd9c855e5b91722ade4816395a' into tab-spacing-anim

This commit is contained in:
2026-11-01 13:13:26 +00:00
7 changed files with 220 additions and 59 deletions
+34 -8
View File
@@ -111,6 +111,34 @@ class _RunDetailViewState extends State<RunDetailView> {
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<RunDetailView> {
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<RunDetailView> {
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,
+2
View File
@@ -277,6 +277,8 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
subtitle: spec?.subtitle,
subtitleIcon: spec?.subtitleIcon,
onTitlePressed: spec?.onTitlePressed,
expandableTitle: spec?.expandableTitle ?? false,
titleAction: spec?.titleAction,
titleSemanticLabel: spec?.titleSemanticLabel,
titleKey: spec?.titleKey,
actions: [
+2
View File
@@ -144,6 +144,8 @@ class _DetailPaneState extends State<DetailPane> {
subtitle: spec?.subtitle,
subtitleIcon: spec?.subtitleIcon,
onTitlePressed: spec?.onTitlePressed,
expandableTitle: spec?.expandableTitle ?? false,
titleAction: spec?.titleAction,
titleSemanticLabel: spec?.titleSemanticLabel,
titleKey: spec?.titleKey,
actions: actions,
+10
View File
@@ -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<ShellBar> {
subtitle: widget.subtitle,
subtitleIcon: widget.subtitleIcon,
onTitlePressed: widget.onTitlePressed,
expandableTitle: widget.expandableTitle,
titleAction: widget.titleAction,
titleSemanticLabel: widget.titleSemanticLabel,
titleKey: widget.titleKey,
onBack: widget.onBack,
+104 -16
View File
@@ -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,74 @@ class SegmentedBar extends StatelessWidget
Theme.of(context).scaffoldBackgroundColor;
}
@override
State<SegmentedBar> createState() => _SegmentedBarState();
}
class _SegmentedBarState extends State<SegmentedBar> {
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);
if (oldWidget.title != widget.title ||
oldWidget.subtitle != widget.subtitle) {
_expanded = false;
}
}
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);
}
@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: [
@@ -182,17 +250,37 @@ class SegmentedBar extends StatelessWidget
),
),
)
: showTitle && !widget.expandableTitle
? titlePill(false)
: showTitle
? SegmentedTitlePill(
cupertino: cupertino,
title: title,
subtitle: subtitle,
subtitleIcon: subtitleIcon,
onPressed: onTitlePressed,
semanticLabel: titleSemanticLabel,
buttonKey: titleKey,
foreground: foregroundColor,
fill: pillColor,
? LayoutBuilder(
builder: (context, titleSpace) => OverlayPortal(
controller: _expandedTitle,
overlayChildBuilder: (context) =>
!(_expanded && widget.expandableTitle)
? const SizedBox.shrink()
: Positioned(
top: 0,
left: 0,
child: CompositedTransformFollower(
link: _titleLink,
showWhenUnlinked: false,
child: ConstrainedBox(
constraints: BoxConstraints(
maxWidth: titleSpace.maxWidth,
),
child: titlePill(true),
),
),
),
child: CompositedTransformTarget(
link: _titleLink,
child: ExcludeSemantics(
excluding: _expanded && widget.expandableTitle,
child: titlePill(false),
),
),
),
)
: const SizedBox.shrink(),
),
@@ -211,7 +299,7 @@ class SegmentedBar extends StatelessWidget
? 0
: segmentedPieceHeight(cupertino) + 8) -
8 -
constraints.maxWidth * minTitleShare,
constraints.maxWidth * SegmentedBar.minTitleShare,
),
),
child: SegmentedPill(
@@ -230,7 +318,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 +359,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,
),
),
+64 -35
View File
@@ -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,
],
),
);
}
}
@@ -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)]);