a49b59a2bc
On a wide window (both sides at least 600 logical px) every SegmentedBar keeps the floating tab bar's 16px from the top and the sides, in every pane and page. A root WindowMargins scope adds the extra 8px to the top media padding, so Cupertino's fixed reserved bar height, list clearances, pinned headers and measured overlays all move together; the bar and the TopGlassStrip read the 16px side inset from the same scope, and sticky section chevrons keep 16px from the trailing edge. Phones keep 8/12.
64 lines
2.0 KiB
Dart
64 lines
2.0 KiB
Dart
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.cupertino,
|
|
required this.child,
|
|
this.maxWidth = double.infinity,
|
|
this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
});
|
|
|
|
final bool cupertino;
|
|
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(
|
|
cupertino: cupertino,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(kTopGlassStripRadius),
|
|
),
|
|
child: Padding(padding: padding, child: child),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|