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
f8a2fc7c
Commit
f8a2fc7c
authored
Aug 27, 2018
by
Sebastian Podjasek
Committed by
xster
Aug 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement resizeToAvoidBottomPadding in CupertinoPageScaffold (#20929)
parent
38d155a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
4 deletions
+72
-4
page_scaffold.dart
packages/flutter/lib/src/cupertino/page_scaffold.dart
+23
-4
scaffold_test.dart
packages/flutter/test/cupertino/scaffold_test.dart
+49
-0
No files found.
packages/flutter/lib/src/cupertino/page_scaffold.dart
View file @
f8a2fc7c
...
...
@@ -22,8 +22,10 @@ class CupertinoPageScaffold extends StatelessWidget {
Key
key
,
this
.
navigationBar
,
this
.
backgroundColor
=
CupertinoColors
.
white
,
this
.
resizeToAvoidBottomInset
=
true
,
@required
this
.
child
,
})
:
assert
(
child
!=
null
),
assert
(
resizeToAvoidBottomInset
!=
null
),
super
(
key:
key
);
/// The [navigationBar], typically a [CupertinoNavigationBar], is drawn at the
...
...
@@ -49,6 +51,15 @@ class CupertinoPageScaffold extends StatelessWidget {
/// By default uses [CupertinoColors.white] color.
final
Color
backgroundColor
;
/// Whether the [child] should size itself to avoid the window's bottom inset.
///
/// For example, if there is an onscreen keyboard displayed above the
/// scaffold, the body can be resized to avoid overlapping the keyboard, which
/// prevents widgets inside the body from being obscured by the keyboard.
///
/// Defaults to true.
final
bool
resizeToAvoidBottomInset
;
@override
Widget
build
(
BuildContext
context
)
{
final
List
<
Widget
>
stacked
=
<
Widget
>[];
...
...
@@ -59,15 +70,20 @@ class CupertinoPageScaffold extends StatelessWidget {
// TODO(xster): Use real size after partial layout instead of preferred size.
// https://github.com/flutter/flutter/issues/12912
final
double
topPadding
=
navigationBar
.
preferredSize
.
height
+
existingMediaQuery
.
padding
.
top
;
final
double
topPadding
=
navigationBar
.
preferredSize
.
height
+
existingMediaQuery
.
padding
.
top
;
// Propagate bottom padding and include viewInsets if appropriate
final
double
bottomPadding
=
resizeToAvoidBottomInset
?
existingMediaQuery
.
viewInsets
.
bottom
:
0.0
;
// If navigation bar is opaquely obstructing, directly shift the main content
// down. If translucent, let main content draw behind navigation bar but hint the
// obstructed area.
if
(
navigationBar
.
fullObstruction
)
{
paddedContent
=
new
Padding
(
padding:
new
EdgeInsets
.
only
(
top:
topPadding
),
padding:
new
EdgeInsets
.
only
(
top:
topPadding
,
bottom:
bottomPadding
),
child:
child
,
);
}
else
{
...
...
@@ -77,7 +93,10 @@ class CupertinoPageScaffold extends StatelessWidget {
top:
topPadding
,
),
),
child:
child
,
child:
new
Padding
(
padding:
new
EdgeInsets
.
only
(
bottom:
bottomPadding
),
child:
child
,
),
);
}
}
...
...
packages/flutter/test/cupertino/scaffold_test.dart
View file @
f8a2fc7c
...
...
@@ -25,6 +25,55 @@ void main() {
expect
(
tester
.
getTopLeft
(
find
.
byType
(
Center
)),
const
Offset
(
0.0
,
0.0
));
});
testWidgets
(
'Contents padding from viewInsets'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(
viewInsets:
EdgeInsets
.
only
(
bottom:
100.0
)),
child:
CupertinoPageScaffold
(
navigationBar:
const
CupertinoNavigationBar
(
middle:
Text
(
'Opaque'
),
backgroundColor:
Color
(
0xFFF8F8F8
),
),
child:
Container
(),
),
),
));
expect
(
tester
.
getSize
(
find
.
byType
(
Container
)).
height
,
600.0
-
44.0
-
100.0
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(
viewInsets:
EdgeInsets
.
only
(
bottom:
100.0
)),
child:
CupertinoPageScaffold
(
navigationBar:
const
CupertinoNavigationBar
(
middle:
Text
(
'Transparent'
),
),
child:
Container
(),
),
),
));
expect
(
tester
.
getSize
(
find
.
byType
(
Container
)).
height
,
600.0
-
100.0
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(
viewInsets:
EdgeInsets
.
only
(
bottom:
100.0
)),
child:
CupertinoPageScaffold
(
navigationBar:
const
CupertinoNavigationBar
(
middle:
Text
(
'Title'
),
),
resizeToAvoidBottomInset:
false
,
child:
Container
(),
),
),
));
expect
(
tester
.
getSize
(
find
.
byType
(
Container
)).
height
,
600.0
);
});
testWidgets
(
'Contents are between opaque bars'
,
(
WidgetTester
tester
)
async
{
const
Center
page1Center
=
Center
();
...
...
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