import 'package:flutter/widgets.dart'; import 'glass_pill.dart'; import 'window_margins.dart'; /// The corner radius of a [TopGlassStrip]. const double kTopGlassStripRadius = 22; /// A page's own controls as one frosted piece floating just under its top /// bar (a run's status and actions, a list's search and filter), so content /// scrolls behind it as it does behind the bar. /// /// Float it with `FloatingBarOverlay(edge: FloatingBarEdge.top)`: the strip /// sits below the bar and the content's top padding grows by the strip's /// height, so at rest nothing is hidden. It starts at the bar's side inset /// ([WindowMargins.sideOf]), is as wide as its content up to [maxWidth] (and the area), and is /// only as tall as its content; the space beside it passes taps through. class TopGlassStrip extends StatelessWidget { const TopGlassStrip({ super.key, required this.child, this.maxWidth = double.infinity, this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 8), }); final Widget child; /// The widest the strip grows on a wide window. final double maxWidth; /// Space between the strip's edge and [child]. final EdgeInsetsGeometry padding; @override Widget build(BuildContext context) { final insets = MediaQuery.paddingOf(context); final side = WindowMargins.sideOf(context); return Padding( padding: EdgeInsets.fromLTRB( side + insets.left, 0, side + insets.right, 8, ), child: Align( alignment: AlignmentDirectional.topStart, heightFactor: 1, child: ConstrainedBox( constraints: BoxConstraints(maxWidth: maxWidth), child: GlassPill( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(kTopGlassStripRadius), ), child: Padding(padding: padding, child: child), ), ), ), ); } }