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:
@@ -0,0 +1,78 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/window_margins.dart';
|
||||
|
||||
void main() {
|
||||
test('a window is wide when both sides reach the wide breakpoint', () {
|
||||
expect(WindowMargins.isWide(const Size(1280, 800)), isTrue);
|
||||
expect(WindowMargins.isWide(const Size(800, 1000)), isTrue);
|
||||
expect(WindowMargins.isWide(const Size(390, 844)), isFalse);
|
||||
// A phone on its side keeps the phone's margins.
|
||||
expect(WindowMargins.isWide(const Size(844, 390)), isFalse);
|
||||
});
|
||||
|
||||
Future<(EdgeInsets, bool, double)> pumpAt(
|
||||
WidgetTester tester,
|
||||
Size size, {
|
||||
EdgeInsets padding = EdgeInsets.zero,
|
||||
}) async {
|
||||
late EdgeInsets seen;
|
||||
late bool wide;
|
||||
late double side;
|
||||
await tester.pumpWidget(
|
||||
MediaQuery(
|
||||
data: MediaQueryData(size: size, padding: padding),
|
||||
child: WindowMargins(
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
seen = MediaQuery.paddingOf(context);
|
||||
wide = WindowMargins.wideOf(context);
|
||||
side = WindowMargins.sideOf(context);
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
return (seen, wide, side);
|
||||
}
|
||||
|
||||
testWidgets('a wide window adds 8 px to the top padding only', (
|
||||
tester,
|
||||
) async {
|
||||
final (padding, wide, side) = await pumpAt(
|
||||
tester,
|
||||
const Size(1280, 800),
|
||||
padding: const EdgeInsets.fromLTRB(4, 24, 4, 20),
|
||||
);
|
||||
expect(padding, const EdgeInsets.fromLTRB(4, 32, 4, 20));
|
||||
expect(wide, isTrue);
|
||||
expect(side, 16);
|
||||
});
|
||||
|
||||
testWidgets('a phone keeps its padding and the 12 px sides', (tester) async {
|
||||
final (padding, wide, side) = await pumpAt(
|
||||
tester,
|
||||
const Size(390, 844),
|
||||
padding: const EdgeInsets.only(top: 47),
|
||||
);
|
||||
expect(padding, const EdgeInsets.only(top: 47));
|
||||
expect(wide, isFalse);
|
||||
expect(side, 12);
|
||||
});
|
||||
|
||||
testWidgets('without a WindowMargins a bar keeps the phone margins', (
|
||||
tester,
|
||||
) async {
|
||||
late double side;
|
||||
await tester.pumpWidget(
|
||||
Builder(
|
||||
builder: (context) {
|
||||
side = WindowMargins.sideOf(context);
|
||||
return const SizedBox();
|
||||
},
|
||||
),
|
||||
);
|
||||
expect(side, 12);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user