Unverified Commit 984d8a8b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "[framework] don't hit test for system nav bar or system chrome on desktop" (#100263)

parent 30846de3
...@@ -265,49 +265,30 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox> ...@@ -265,49 +265,30 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
// | | // | |
// ++++++++++++++++++++++++++ <- bounds.bottom // ++++++++++++++++++++++++++ <- bounds.bottom
final Rect bounds = paintBounds; final Rect bounds = paintBounds;
// Center of the status bar
// Only Android / iOS / Fuchsia have a customizable status bar. final Offset top = Offset(
SystemUiOverlayStyle? upperOverlayStyle; // Horizontal center of the screen
switch (defaultTargetPlatform) { bounds.center.dx,
case TargetPlatform.android: // The vertical center of the system status bar. The system status bar
case TargetPlatform.iOS: // height is kept as top window padding.
case TargetPlatform.fuchsia: _window.padding.top / 2.0,
// Center of the status bar );
final Offset top = Offset( // Center of the navigation bar
// Horizontal center of the screen final Offset bottom = Offset(
bounds.center.dx, // Horizontal center of the screen
// The vertical center of the system status bar. The system status bar bounds.center.dx,
// height is kept as top window padding. // Vertical center of the system navigation bar. The system navigation bar
_window.padding.top / 2.0, // height is kept as bottom window padding. The "1" needs to be subtracted
); // from the bottom because available pixels are in (0..bottom) range.
upperOverlayStyle = layer!.find<SystemUiOverlayStyle>(top); // I.e. for a device with 1920 height, bound.bottom is 1920, but the most
break; // bottom drawn pixel is at 1919 position.
case TargetPlatform.linux: bounds.bottom - 1.0 - _window.padding.bottom / 2.0,
case TargetPlatform.macOS: );
case TargetPlatform.windows: final SystemUiOverlayStyle? upperOverlayStyle = layer!.find<SystemUiOverlayStyle>(top);
break; // Only android has a customizable system navigation bar.
}
// Only Android has a customizable system navigation bar.
SystemUiOverlayStyle? lowerOverlayStyle; SystemUiOverlayStyle? lowerOverlayStyle;
switch (defaultTargetPlatform) { switch (defaultTargetPlatform) {
case TargetPlatform.android: case TargetPlatform.android:
// If there is no bottom view padding, then there is no navigation bar
// and the hit test can be skipped.
if (_window.viewPadding.bottom == 0.0) {
break;
}
// Center of the navigation bar
final Offset bottom = Offset(
// Horizontal center of the screen
bounds.center.dx,
// Vertical center of the system navigation bar. The system navigation bar
// height is kept as bottom window padding. The "1" needs to be subtracted
// from the bottom because available pixels are in (0..bottom) range.
// I.e. for a device with 1920 height, bound.bottom is 1920, but the most
// bottom drawn pixel is at 1919 position.
bounds.bottom - 1.0 - _window.padding.bottom / 2.0,
);
lowerOverlayStyle = layer!.find<SystemUiOverlayStyle>(bottom); lowerOverlayStyle = layer!.find<SystemUiOverlayStyle>(bottom);
break; break;
case TargetPlatform.fuchsia: case TargetPlatform.fuchsia:
......
...@@ -974,11 +974,8 @@ void main() { ...@@ -974,11 +974,8 @@ void main() {
}, },
), ),
); );
expect(SystemChrome.latestStyle, const SystemUiOverlayStyle( expect(SystemChrome.latestStyle, SystemUiOverlayStyle.light);
statusBarIconBrightness: Brightness.light, });
statusBarBrightness: Brightness.dark,
));
}, variant: TargetPlatformVariant.mobile());
testWidgets('NavBar draws a dark system bar for a light background', (WidgetTester tester) async { testWidgets('NavBar draws a dark system bar for a light background', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
...@@ -997,11 +994,8 @@ void main() { ...@@ -997,11 +994,8 @@ void main() {
}, },
), ),
); );
expect(SystemChrome.latestStyle, const SystemUiOverlayStyle( expect(SystemChrome.latestStyle, SystemUiOverlayStyle.dark);
statusBarIconBrightness: Brightness.dark, });
statusBarBrightness: Brightness.light,
));
}, variant: TargetPlatformVariant.mobile());
testWidgets('CupertinoNavigationBarBackButton shows an error when manually added outside a route', (WidgetTester tester) async { testWidgets('CupertinoNavigationBarBackButton shows an error when manually added outside a route', (WidgetTester tester) async {
await tester.pumpWidget(const CupertinoNavigationBarBackButton()); await tester.pumpWidget(const CupertinoNavigationBarBackButton());
......
...@@ -16,11 +16,11 @@ void main() { ...@@ -16,11 +16,11 @@ void main() {
const double deviceWidth = 480.0; const double deviceWidth = 480.0;
const double devicePixelRatio = 2.0; const double devicePixelRatio = 2.0;
void setupTestDevice({ double bottomPadding = navigationBarHeight * devicePixelRatio }) { void setupTestDevice() {
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
final FakeWindowPadding padding = FakeWindowPadding( const FakeWindowPadding padding = FakeWindowPadding(
top: statusBarHeight * devicePixelRatio, top: statusBarHeight * devicePixelRatio,
bottom: bottomPadding, bottom: navigationBarHeight * devicePixelRatio,
); );
binding.window binding.window
...@@ -94,35 +94,8 @@ void main() { ...@@ -94,35 +94,8 @@ void main() {
variant: TargetPlatformVariant.mobile(), variant: TargetPlatformVariant.mobile(),
); );
testWidgets("statusBarColor isn't set on desktop platforms",
(WidgetTester tester) async {
setupTestDevice();
const double moreThanHalfOfTheStatusBarHeight =
statusBarHeight / 2.0 + 1;
await tester.pumpWidget(const Align(
alignment: Alignment.topCenter,
child: AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
statusBarColor: Colors.blue,
),
child: SizedBox(
width: 100,
height: moreThanHalfOfTheStatusBarHeight,
),
),
));
await tester.pumpAndSettle();
expect(
SystemChrome.latestStyle?.statusBarColor,
isNull,
);
},
variant: TargetPlatformVariant.desktop(),
);
testWidgets( testWidgets(
'statusBarColor is set when view covers more than half of the system status bar', 'statusBarColor is set when view covers more than half of tye system status bar',
(WidgetTester tester) async { (WidgetTester tester) async {
setupTestDevice(); setupTestDevice();
const double moreThanHalfOfTheStatusBarHeight = const double moreThanHalfOfTheStatusBarHeight =
...@@ -255,28 +228,6 @@ void main() { ...@@ -255,28 +228,6 @@ void main() {
variant: TargetPlatformVariant.only(TargetPlatform.android), variant: TargetPlatformVariant.only(TargetPlatform.android),
); );
}); });
testWidgets('systemNavigationBarColor is not set when there is no window padding', (WidgetTester tester) async {
setupTestDevice(bottomPadding: 0);
await tester.pumpWidget(const Align(
alignment: Alignment.bottomCenter,
child: AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle(
systemNavigationBarColor: Colors.blue,
),
child: SizedBox(
width: 100,
height: 100
),
),
));
await tester.pumpAndSettle();
expect(
SystemChrome.latestStyle?.systemNavigationBarColor,
null,
);
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment