import 'package:flutter/widgets.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; import '../../../ui/adaptive/floating_destination_bar.dart'; import '../../../ui/adaptive/glass_pill.dart'; import '../../../ui/adaptive/top_glass_strip.dart'; /// The narrowest detail pane that puts its tabs and header in one row; /// narrower panes stack the header strip over the tabs. const double kRunDetailWideChromeMinWidth = kFloatingBarWideWidth; /// The most of the row the tabs take, leaving the rest to the header. const double kRunDetailWideTabsShare = 0.6; /// The run detail's controls beside a list (a wide split): its tabs and its /// header (status, run actions, notices) share one row under the pane's top /// bar, instead of stacking the header strip above a second tabs strip. /// /// The tabs lead, in line with the bar's title; the header follows as a glass /// piece as wide as its content, and wraps (or scrolls inside its height /// limit) when the pane is narrow. Float the row with `FloatingBarOverlay` /// at the top edge so the tab body pads past it at rest. The header keeps the /// key `run-detail-header`. class RunDetailWideChrome extends StatelessWidget { const RunDetailWideChrome({ super.key, required this.tabs, required this.header, }); /// The tab strip at [FloatingBarEdge.top]; it brings its own 12px margins. final Widget tabs; /// The header's content, already bounded in height. final Widget header; @override Widget build(BuildContext context) { final insets = MediaQuery.paddingOf(context); return Padding( padding: EdgeInsets.only(left: insets.left), child: LayoutBuilder( builder: (context, constraints) => Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ // The tabs keep at most 60% of the row, so the header always has // room for its status and actions (scaled text included). ConstrainedBox( constraints: BoxConstraints( maxWidth: constraints.maxWidth * kRunDetailWideTabsShare, ), child: tabs, ), Flexible( child: Padding( // The tabs' own trailing margin is the gap before the header. padding: EdgeInsets.only( right: FloatingDestinationBar.topMargin + insets.right, bottom: 8, ), child: Align( alignment: AlignmentDirectional.centerStart, heightFactor: 1, child: GlassPill( key: const Key('run-detail-header'), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(kTopGlassStripRadius), ), child: Padding( padding: const EdgeInsets.symmetric(vertical: 4), child: header, ), ), ), ), ), ], ), ), ); } }