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
310a9819
Commit
310a9819
authored
Aug 23, 2016
by
Hans Muller
Committed by
GitHub
Aug 23, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle dragging a bottom sheet past the bottom (#5541)
parent
81d67268
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
13 deletions
+46
-13
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+4
-2
scaffold.dart
packages/flutter/lib/src/material/scaffold.dart
+13
-11
bottom_sheet_test.dart
packages/flutter/test/widget/bottom_sheet_test.dart
+29
-0
No files found.
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
310a9819
...
...
@@ -108,11 +108,13 @@ class _BottomSheetState extends State<BottomSheet> {
return
;
if
(
details
.
velocity
.
pixelsPerSecond
.
dy
>
_kMinFlingVelocity
)
{
double
flingVelocity
=
-
details
.
velocity
.
pixelsPerSecond
.
dy
/
_childHeight
;
config
.
animationController
.
fling
(
velocity:
flingVelocity
);
if
(
config
.
animationController
.
value
>
0.0
)
config
.
animationController
.
fling
(
velocity:
flingVelocity
);
if
(
flingVelocity
<
0.0
)
config
.
onClosing
();
}
else
if
(
config
.
animationController
.
value
<
_kCloseProgressThreshold
)
{
config
.
animationController
.
fling
(
velocity:
-
1.0
);
if
(
config
.
animationController
.
value
>
0.0
)
config
.
animationController
.
fling
(
velocity:
-
1.0
);
config
.
onClosing
();
}
else
{
config
.
animationController
.
forward
();
...
...
packages/flutter/lib/src/material/scaffold.dart
View file @
310a9819
...
...
@@ -454,7 +454,7 @@ class ScaffoldState extends State<Scaffold> {
// PERSISTENT BOTTOM SHEET API
List
<
Widget
>
_dismissedBottomSheets
;
final
List
<
Widget
>
_dismissedBottomSheets
=
<
Widget
>[]
;
PersistentBottomSheetController
<
dynamic
>
_currentBottomSheet
;
/// Shows a persistent material design bottom sheet.
...
...
@@ -491,9 +491,11 @@ class ScaffoldState extends State<Scaffold> {
assert
(
_currentBottomSheet
.
_widget
==
bottomSheet
);
assert
(
bottomSheetKey
.
currentState
!=
null
);
bottomSheetKey
.
currentState
.
close
();
_dismissedBottomSheets
??=
<
Widget
>[];
_dismissedBottomSheets
.
add
(
bottomSheet
);
_currentBottomSheet
=
null
;
if
(
controller
.
status
!=
AnimationStatus
.
dismissed
)
_dismissedBottomSheets
.
add
(
bottomSheet
);
setState
(()
{
_currentBottomSheet
=
null
;
});
completer
.
complete
();
}
);
...
...
@@ -505,10 +507,11 @@ class ScaffoldState extends State<Scaffold> {
entry
.
remove
();
},
onDismissed:
()
{
assert
(
_dismissedBottomSheets
!=
null
);
setState
(()
{
_dismissedBottomSheets
.
remove
(
bottomSheet
);
});
if
(
_dismissedBottomSheets
.
contains
(
bottomSheet
))
{
setState
(()
{
_dismissedBottomSheets
.
remove
(
bottomSheet
);
});
}
},
builder:
builder
);
...
...
@@ -728,10 +731,9 @@ class ScaffoldState extends State<Scaffold> {
}
// Otherwise the AppBar will be part of a [app bar, body] Stack. See AppBarBehavior.scroll below.
if
(
_currentBottomSheet
!=
null
||
(
_dismissedBottomSheets
!=
null
&&
_dismissedBottomSheets
.
isNotEmpty
))
{
if
(
_currentBottomSheet
!=
null
||
_dismissedBottomSheets
.
isNotEmpty
)
{
final
List
<
Widget
>
bottomSheets
=
<
Widget
>[];
if
(
_dismissedBottomSheets
!=
null
&&
_dismissedBottomSheets
.
isNotEmpty
)
if
(
_dismissedBottomSheets
.
isNotEmpty
)
bottomSheets
.
addAll
(
_dismissedBottomSheets
);
if
(
_currentBottomSheet
!=
null
)
bottomSheets
.
add
(
_currentBottomSheet
.
_widget
);
...
...
packages/flutter/test/widget/bottom_sheet_test.dart
View file @
310a9819
...
...
@@ -110,4 +110,33 @@ void main() {
expect
(
find
.
text
(
'BottomSheet'
),
findsNothing
);
});
testWidgets
(
'Verify that dragging past the bottom dismisses a persistent BottomSheet'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/5528
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
new
GlobalKey
<
ScaffoldState
>();
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Scaffold
(
key:
scaffoldKey
,
body:
new
Center
(
child:
new
Text
(
'body'
))
)
));
scaffoldKey
.
currentState
.
showBottomSheet
((
BuildContext
context
)
{
return
new
Container
(
margin:
new
EdgeInsets
.
all
(
40.0
),
child:
new
Text
(
'BottomSheet'
)
);
});
await
tester
.
pump
();
// bottom sheet show animation starts
await
tester
.
pump
(
new
Duration
(
seconds:
1
));
// animation done
expect
(
find
.
text
(
'BottomSheet'
),
findsOneWidget
);
await
tester
.
fling
(
find
.
text
(
'BottomSheet'
),
const
Offset
(
0.0
,
400.0
),
1000.0
);
await
tester
.
pump
();
// drain the microtask queue (Future completion callback)
await
tester
.
pump
();
// bottom sheet dismiss animation starts
await
tester
.
pump
(
new
Duration
(
seconds:
1
));
// animation done
expect
(
find
.
text
(
'BottomSheet'
),
findsNothing
);
});
}
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