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
5a7224d1
Unverified
Commit
5a7224d1
authored
Oct 17, 2022
by
luckysmg
Committed by
GitHub
Oct 17, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bar height changes when toggle keyboard (#106542)
parent
0b617e93
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
7 deletions
+113
-7
bottom_tab_bar.dart
packages/flutter/lib/src/cupertino/bottom_tab_bar.dart
+1
-1
bottom_navigation_bar.dart
packages/flutter/lib/src/material/bottom_navigation_bar.dart
+1
-1
bottom_tab_bar_test.dart
packages/flutter/test/cupertino/bottom_tab_bar_test.dart
+56
-2
bottom_navigation_bar_test.dart
...ges/flutter/test/material/bottom_navigation_bar_test.dart
+54
-2
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+1
-1
No files found.
packages/flutter/lib/src/cupertino/bottom_tab_bar.dart
View file @
5a7224d1
...
...
@@ -156,7 +156,7 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMediaQuery
(
context
));
final
double
bottomPadding
=
MediaQuery
.
of
(
context
).
p
adding
.
bottom
;
final
double
bottomPadding
=
MediaQuery
.
of
(
context
).
viewP
adding
.
bottom
;
final
Color
backgroundColor
=
CupertinoDynamicColor
.
resolve
(
this
.
backgroundColor
??
CupertinoTheme
.
of
(
context
).
barBackgroundColor
,
...
...
packages/flutter/lib/src/material/bottom_navigation_bar.dart
View file @
5a7224d1
...
...
@@ -1114,7 +1114,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
final
BottomNavigationBarLandscapeLayout
layout
=
widget
.
landscapeLayout
??
bottomTheme
.
landscapeLayout
??
BottomNavigationBarLandscapeLayout
.
spread
;
final
double
additionalBottomPadding
=
MediaQuery
.
of
(
context
).
p
adding
.
bottom
;
final
double
additionalBottomPadding
=
MediaQuery
.
of
(
context
).
viewP
adding
.
bottom
;
Color
?
backgroundColor
;
switch
(
_effectiveType
)
{
...
...
packages/flutter/test/cupertino/bottom_tab_bar_test.dart
View file @
5a7224d1
...
...
@@ -316,7 +316,7 @@ Future<void> main() async {
// Verify height with bottom padding.
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(
p
adding:
EdgeInsets
.
only
(
bottom:
40.0
)),
data:
const
MediaQueryData
(
viewP
adding:
EdgeInsets
.
only
(
bottom:
40.0
)),
child:
CupertinoTabScaffold
(
tabBar:
tabBar
,
tabBuilder:
(
BuildContext
context
,
int
index
)
{
...
...
@@ -359,7 +359,7 @@ Future<void> main() async {
// Verify height with bottom padding.
const
double
bottomPadding
=
40.0
;
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(
p
adding:
EdgeInsets
.
only
(
bottom:
bottomPadding
)),
data:
const
MediaQueryData
(
viewP
adding:
EdgeInsets
.
only
(
bottom:
bottomPadding
)),
child:
CupertinoTabScaffold
(
tabBar:
tabBar
,
tabBuilder:
(
BuildContext
context
,
int
index
)
{
...
...
@@ -370,6 +370,60 @@ Future<void> main() async {
expect
(
tester
.
getSize
(
find
.
byType
(
CupertinoTabBar
)).
height
,
tabBarHeight
+
bottomPadding
);
});
testWidgets
(
'Ensure bar height will not change when toggle keyboard'
,
(
WidgetTester
tester
)
async
{
const
double
tabBarHeight
=
56.0
;
final
CupertinoTabBar
tabBar
=
CupertinoTabBar
(
height:
tabBarHeight
,
items:
<
BottomNavigationBarItem
>[
BottomNavigationBarItem
(
icon:
ImageIcon
(
MemoryImage
(
Uint8List
.
fromList
(
kTransparentImage
))),
label:
'Aka'
,
),
BottomNavigationBarItem
(
icon:
ImageIcon
(
MemoryImage
(
Uint8List
.
fromList
(
kTransparentImage
))),
label:
'Shiro'
,
),
],
);
const
double
bottomPadding
=
34.0
;
// Test the height is correct when keyboard not showing.
// So viewInset should be 0.0.
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(
padding:
EdgeInsets
.
only
(
bottom:
bottomPadding
),
viewPadding:
EdgeInsets
.
only
(
bottom:
bottomPadding
),
),
child:
CupertinoTabScaffold
(
tabBar:
tabBar
,
tabBuilder:
(
BuildContext
context
,
int
index
)
{
return
const
Placeholder
();
},
),
));
expect
(
tester
.
getSize
(
find
.
byType
(
CupertinoTabBar
)).
height
,
tabBarHeight
+
bottomPadding
);
// Now show keyboard, and test the bar height will not change.
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(
viewPadding:
EdgeInsets
.
only
(
bottom:
bottomPadding
),
viewInsets:
EdgeInsets
.
only
(
bottom:
336.0
),
),
child:
CupertinoTabScaffold
(
tabBar:
tabBar
,
tabBuilder:
(
BuildContext
context
,
int
index
)
{
return
const
Placeholder
();
},
),
),
);
// Expect the bar height should not change.
expect
(
tester
.
getSize
(
find
.
byType
(
CupertinoTabBar
)).
height
,
tabBarHeight
+
bottomPadding
);
});
testWidgets
(
'Opaque background does not add blur effects'
,
(
WidgetTester
tester
)
async
{
await
pumpWidgetWithBoilerplate
(
tester
,
MediaQuery
(
data:
const
MediaQueryData
(),
...
...
packages/flutter/test/material/bottom_navigation_bar_test.dart
View file @
5a7224d1
...
...
@@ -991,7 +991,7 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
p
adding:
EdgeInsets
.
only
(
bottom:
40.0
)),
data:
const
MediaQueryData
(
viewP
adding:
EdgeInsets
.
only
(
bottom:
40.0
)),
child:
Scaffold
(
bottomNavigationBar:
BottomNavigationBar
(
items:
const
<
BottomNavigationBarItem
>[
...
...
@@ -1018,7 +1018,7 @@ void main() {
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
p
adding:
EdgeInsets
.
only
(
bottom:
40.0
)),
data:
const
MediaQueryData
(
viewP
adding:
EdgeInsets
.
only
(
bottom:
40.0
)),
child:
Scaffold
(
bottomNavigationBar:
BottomNavigationBar
(
selectedFontSize:
8
,
...
...
@@ -1042,6 +1042,58 @@ void main() {
expect
(
tester
.
getSize
(
find
.
byType
(
BottomNavigationBar
)).
height
,
expectedHeight
);
});
testWidgets
(
'BottomNavigationBar height will not change when toggle keyboard'
,
(
WidgetTester
tester
)
async
{
final
Widget
child
=
Scaffold
(
bottomNavigationBar:
BottomNavigationBar
(
selectedFontSize:
8
,
items:
const
<
BottomNavigationBarItem
>[
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
ac_unit
),
label:
'AC'
,
),
BottomNavigationBarItem
(
icon:
Icon
(
Icons
.
access_alarm
),
label:
'Alarm'
,
),
],
),
);
// Test the bar height is correct when not showing the keyboard.
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
viewPadding:
EdgeInsets
.
only
(
bottom:
40.0
),
padding:
EdgeInsets
.
only
(
bottom:
40.0
),
),
child:
child
,
),
),
);
// Expect the height is the correct.
const
double
expectedHeight
=
kBottomNavigationBarHeight
+
40.0
;
expect
(
tester
.
getSize
(
find
.
byType
(
BottomNavigationBar
)).
height
,
expectedHeight
);
// Now we show the keyboard.
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
viewPadding:
EdgeInsets
.
only
(
bottom:
40.0
),
viewInsets:
EdgeInsets
.
only
(
bottom:
336.0
),
),
child:
child
,
),
),
);
// Expect the height is the same.
expect
(
tester
.
getSize
(
find
.
byType
(
BottomNavigationBar
)).
height
,
expectedHeight
);
});
testWidgets
(
'BottomNavigationBar action size test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
5a7224d1
...
...
@@ -672,7 +672,7 @@ void main() {
home:
MediaQuery
(
data:
const
MediaQueryData
(
// Representing a navigational notch at the bottom of the screen
p
adding:
EdgeInsets
.
fromLTRB
(
0.0
,
0.0
,
0.0
,
40.0
),
viewP
adding:
EdgeInsets
.
fromLTRB
(
0.0
,
0.0
,
0.0
,
40.0
),
),
child:
Scaffold
(
body:
SingleChildScrollView
(
...
...
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