Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a7a3d8ba
Unverified
Commit
a7a3d8ba
authored
Feb 08, 2022
by
Jonah Williams
Committed by
GitHub
Feb 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] don't hit test for system nav bar or system chrome on desktop (#97883)
parent
41a70b50
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
29 deletions
+103
-29
view.dart
packages/flutter/lib/src/rendering/view.dart
+40
-21
nav_bar_test.dart
packages/flutter/test/cupertino/nav_bar_test.dart
+10
-4
view_chrome_style_test.dart
packages/flutter/test/rendering/view_chrome_style_test.dart
+53
-4
No files found.
packages/flutter/lib/src/rendering/view.dart
View file @
a7a3d8ba
...
...
@@ -265,6 +265,13 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
// | |
// ++++++++++++++++++++++++++ <- bounds.bottom
final
Rect
bounds
=
paintBounds
;
// Only Android / iOS / Fuchsia have a customizable status bar.
SystemUiOverlayStyle
?
upperOverlayStyle
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
fuchsia
:
// Center of the status bar
final
Offset
top
=
Offset
(
// Horizontal center of the screen
...
...
@@ -273,6 +280,23 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
// height is kept as top window padding.
_window
.
padding
.
top
/
2.0
,
);
upperOverlayStyle
=
layer
!.
find
<
SystemUiOverlayStyle
>(
top
);
break
;
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
break
;
}
// Only Android has a customizable system navigation bar.
SystemUiOverlayStyle
?
lowerOverlayStyle
;
switch
(
defaultTargetPlatform
)
{
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
...
...
@@ -284,11 +308,6 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin<RenderBox>
// bottom drawn pixel is at 1919 position.
bounds
.
bottom
-
1.0
-
_window
.
padding
.
bottom
/
2.0
,
);
final
SystemUiOverlayStyle
?
upperOverlayStyle
=
layer
!.
find
<
SystemUiOverlayStyle
>(
top
);
// Only android has a customizable system navigation bar.
SystemUiOverlayStyle
?
lowerOverlayStyle
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
lowerOverlayStyle
=
layer
!.
find
<
SystemUiOverlayStyle
>(
bottom
);
break
;
case
TargetPlatform
.
fuchsia
:
...
...
packages/flutter/test/cupertino/nav_bar_test.dart
View file @
a7a3d8ba
...
...
@@ -974,8 +974,11 @@ void main() {
},
),
);
expect
(
SystemChrome
.
latestStyle
,
SystemUiOverlayStyle
.
light
);
});
expect
(
SystemChrome
.
latestStyle
,
const
SystemUiOverlayStyle
(
statusBarIconBrightness:
Brightness
.
light
,
statusBarBrightness:
Brightness
.
dark
,
));
},
variant:
TargetPlatformVariant
.
mobile
());
testWidgets
(
'NavBar draws a dark system bar for a light background'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
...
...
@@ -994,8 +997,11 @@ void main() {
},
),
);
expect
(
SystemChrome
.
latestStyle
,
SystemUiOverlayStyle
.
dark
);
});
expect
(
SystemChrome
.
latestStyle
,
const
SystemUiOverlayStyle
(
statusBarIconBrightness:
Brightness
.
dark
,
statusBarBrightness:
Brightness
.
light
,
));
},
variant:
TargetPlatformVariant
.
mobile
());
testWidgets
(
'CupertinoNavigationBarBackButton shows an error when manually added outside a route'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
CupertinoNavigationBarBackButton
());
...
...
packages/flutter/test/rendering/view_chrome_style_test.dart
View file @
a7a3d8ba
...
...
@@ -16,11 +16,11 @@ void main() {
const
double
deviceWidth
=
480.0
;
const
double
devicePixelRatio
=
2.0
;
void
setupTestDevice
()
{
void
setupTestDevice
(
{
double
bottomPadding
=
navigationBarHeight
*
devicePixelRatio
}
)
{
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
ensureInitialized
();
const
FakeWindowPadding
padding
=
FakeWindowPadding
(
final
FakeWindowPadding
padding
=
FakeWindowPadding
(
top:
statusBarHeight
*
devicePixelRatio
,
bottom:
navigationBarHeight
*
devicePixelRatio
,
bottom:
bottomPadding
,
);
binding
.
window
...
...
@@ -94,8 +94,35 @@ void main() {
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
(
'statusBarColor is set when view covers more than half of t
y
e system status bar'
,
'statusBarColor is set when view covers more than half of t
h
e system status bar'
,
(
WidgetTester
tester
)
async
{
setupTestDevice
();
const
double
moreThanHalfOfTheStatusBarHeight
=
...
...
@@ -228,6 +255,28 @@ void main() {
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
));
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment