Keep even 16px window margins for top bars on wide windows

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.
This commit is contained in:
2026-11-10 13:09:36 +00:00
parent 19aa726e7f
commit a49b59a2bc
8 changed files with 396 additions and 15 deletions
+10 -5
View File
@@ -11,6 +11,7 @@ import 'segmented_bar_overflow.dart';
import 'segmented_bar_motion.dart';
import 'segmented_bar_pieces.dart';
import 'window_controls.dart';
import 'window_margins.dart';
export 'segmented_bar_overflow.dart'
show
@@ -43,8 +44,9 @@ export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill;
/// [CupertinoPageScaffold.navigationBar], which inset the content by the
/// 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, and keeps its pieces clear of the
/// system's window controls ([WindowControlsClearance]).
/// It handles the top safe area itself, keeps its pieces clear of the
/// system's window controls ([WindowControlsClearance]), and on a wide window
/// keeps the wider [WindowMargins] from the top and the sides.
class SegmentedBar extends StatefulWidget
implements ObstructingPreferredSizeWidget {
const SegmentedBar({
@@ -142,7 +144,7 @@ class SegmentedBar extends StatefulWidget
/// top edge (a page's own tint, such as a chat's colour). It takes no taps.
final Widget? backdrop;
static const double _topPadding = 8;
static const double _topPadding = WindowMargins.narrowTop;
/// The share of the bar the title always keeps beside the actions.
static const double minTitleShare = 0.25;
@@ -530,6 +532,9 @@ class _SegmentedBarState extends State<SegmentedBar> {
);
final background = widget._background(context);
final inset = MediaQuery.paddingOf(context).top;
// A wide window's extra top margin arrives in the top padding (see
// WindowMargins), so the reserved height stays the bar's own.
final side = WindowMargins.sideOf(context);
return Stack(
children: [
// The scrim: the page's background, opaque at the edge and fading out
@@ -570,9 +575,9 @@ class _SegmentedBarState extends State<SegmentedBar> {
bottom: false,
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
12,
side,
SegmentedBar._topPadding,
12,
side,
bottomPadding,
),
// In a window, iPadOS draws its window controls over the top