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
48690d7c
Commit
48690d7c
authored
Oct 17, 2016
by
Adam Barth
Committed by
GitHub
Oct 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for persistent footer buttons (#6345)
Fixes #616
parent
c77798a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
1 deletion
+76
-1
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+44
-1
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+32
-0
No files found.
packages/flutter/lib/src/material/scaffold.dart
View file @
48690d7c
...
...
@@ -10,6 +10,8 @@ import 'package:flutter/widgets.dart';
import
'app_bar.dart'
;
import
'bottom_sheet.dart'
;
import
'button_bar.dart'
;
import
'button.dart'
;
import
'drawer.dart'
;
import
'icon.dart'
;
import
'icon_button.dart'
;
...
...
@@ -53,6 +55,7 @@ enum _ScaffoldSlot {
appBar
,
bottomSheet
,
snackBar
,
persistentFooter
,
bottomNavigationBar
,
floatingActionButton
,
drawer
,
...
...
@@ -97,6 +100,12 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
positionChild
(
_ScaffoldSlot
.
bottomNavigationBar
,
new
Offset
(
0.0
,
contentBottom
));
}
if
(
hasChild
(
_ScaffoldSlot
.
persistentFooter
))
{
final
double
persistentFooterHeight
=
layoutChild
(
_ScaffoldSlot
.
persistentFooter
,
fullWidthConstraints
.
copyWith
(
maxHeight:
contentBottom
-
contentTop
)).
height
;
contentBottom
-=
persistentFooterHeight
;
positionChild
(
_ScaffoldSlot
.
persistentFooter
,
new
Offset
(
0.0
,
contentBottom
));
}
if
(
hasChild
(
_ScaffoldSlot
.
body
))
{
final
double
bodyHeight
=
contentBottom
-
contentTop
;
final
BoxConstraints
bodyConstraints
=
fullWidthConstraints
.
tighten
(
height:
bodyHeight
);
...
...
@@ -299,6 +308,7 @@ class Scaffold extends StatefulWidget {
this
.
appBar
,
this
.
body
,
this
.
floatingActionButton
,
this
.
persistentFooterButtons
,
this
.
drawer
,
this
.
bottomNavigationBar
,
this
.
scrollableKey
,
...
...
@@ -321,6 +331,18 @@ class Scaffold extends StatefulWidget {
/// Typically a [FloatingActionButton].
final
Widget
floatingActionButton
;
/// A set of buttons that are displayed at the bottom of the scaffold.
///
/// Typically this is a list of [FlatButton] widgets. These buttons are
/// persistently visible, even of the [body] of the scaffold scrolls.
///
/// These widgets will be wrapped in a [ButtonBar].
///
/// See also:
///
/// * <https://material.google.com/components/buttons.html#buttons-persistent-footer-buttons>
final
List
<
Widget
>
persistentFooterButtons
;
/// A panel displayed to the side of the body, often hidden on mobile devices.
///
/// Typically a [Drawer].
...
...
@@ -761,6 +783,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
@override
Widget
build
(
BuildContext
context
)
{
EdgeInsets
padding
=
MediaQuery
.
of
(
context
).
padding
;
ThemeData
themeData
=
Theme
.
of
(
context
);
if
(!
config
.
resizeToAvoidBottomPadding
)
padding
=
new
EdgeInsets
.
fromLTRB
(
padding
.
left
,
padding
.
top
,
padding
.
right
,
0.0
);
...
...
@@ -804,6 +827,26 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
if
(
_snackBars
.
isNotEmpty
)
_addIfNonNull
(
children
,
_snackBars
.
first
.
_widget
,
_ScaffoldSlot
.
snackBar
);
if
(
config
.
persistentFooterButtons
!=
null
)
{
children
.
add
(
new
LayoutId
(
id:
_ScaffoldSlot
.
persistentFooter
,
child:
new
Container
(
decoration:
new
BoxDecoration
(
border:
new
Border
(
top:
new
BorderSide
(
color:
themeData
.
dividerColor
),
),
),
child:
new
ButtonTheme
.
bar
(
child:
new
ButtonBar
(
children:
config
.
persistentFooterButtons
),
),
),
));
}
if
(
config
.
bottomNavigationBar
!=
null
)
{
children
.
add
(
new
LayoutId
(
id:
_ScaffoldSlot
.
bottomNavigationBar
,
...
...
@@ -831,7 +874,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin {
)
));
if
(
Theme
.
of
(
context
)
.
platform
==
TargetPlatform
.
iOS
)
{
if
(
themeData
.
platform
==
TargetPlatform
.
iOS
)
{
children
.
add
(
new
LayoutId
(
id:
_ScaffoldSlot
.
statusBar
,
child:
new
GestureDetector
(
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
48690d7c
...
...
@@ -239,6 +239,38 @@ void main() {
expect
(
appBarBottomRight
,
equals
(
sheetTopRight
));
});
testWidgets
(
'Persistent bottom buttons are persistent'
,
(
WidgetTester
tester
)
async
{
bool
didPressButton
=
false
;
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Scaffold
(
body:
new
ScrollableViewport
(
child:
new
Container
(
decoration:
new
BoxDecoration
(
backgroundColor:
Colors
.
amber
[
500
],
),
height:
5000.0
,
child:
new
Text
(
'body'
),
),
),
persistentFooterButtons:
<
Widget
>[
new
FlatButton
(
onPressed:
()
{
didPressButton
=
true
;
},
child:
new
Text
(
'X'
),
)
],
),
),
);
await
tester
.
scroll
(
find
.
text
(
'body'
),
const
Offset
(
0.0
,
-
1000.0
));
expect
(
didPressButton
,
isFalse
);
await
tester
.
tap
(
find
.
text
(
'X'
));
expect
(
didPressButton
,
isTrue
);
});
group
(
'back arrow'
,
()
{
Future
<
Null
>
expectBackIcon
(
WidgetTester
tester
,
TargetPlatform
platform
,
IconData
expectedIcon
)
async
{
GlobalKey
rootKey
=
new
GlobalKey
();
...
...
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