Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
modal_bottom_sheet
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Dendos
2020-08-08 14:42:58 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
29252fe1c8a0fc82cdbf837a668167fec0660656
29252fe1
1 parent
2035d7c7
allow to pass closeProgressThreshold double to showModat methods
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
3 deletions
lib/src/bottom_sheet.dart
lib/src/bottom_sheet_route.dart
lib/src/bottom_sheets/bar_bottom_sheet.dart
lib/src/bottom_sheets/material_bottom_sheet.dart
lib/src/bottom_sheet.dart
View file @
29252fe
...
...
@@ -18,8 +18,8 @@ const Curve _decelerateEasing = Cubic(0.0, 0.0, 0.2, 1.0);
const
Curve
_modalBottomSheetCurve
=
_decelerateEasing
;
const
Duration
_bottomSheetDuration
=
Duration
(
milliseconds:
400
);
const
double
_minFlingVelocity
=
500.0
;
const
double
_closeProgressThreshold
=
0.6
;
const
double
_willPopThreshold
=
2
;
const
double
_closeProgressThreshold
=
0.8
;
const
double
_willPopThreshold
=
0.8
;
typedef
ScrollWidgetBuilder
=
Widget
Function
(
BuildContext
context
,
ScrollController
controller
);
...
...
@@ -42,6 +42,7 @@ class ModalBottomSheet extends StatefulWidget {
/// Creates a bottom sheet.
const
ModalBottomSheet
({
Key
key
,
this
.
closeProgressThreshold
=
_closeProgressThreshold
,
this
.
animationController
,
this
.
animationCurve
,
this
.
enableDrag
=
true
,
...
...
@@ -57,6 +58,8 @@ class ModalBottomSheet extends StatefulWidget {
assert
(
builder
!=
null
),
super
(
key:
key
);
final
double
closeProgressThreshold
;
/// The animation controller that controls the bottom sheet's entrance and
/// exit animations.
///
...
...
@@ -152,7 +155,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
widget
.
animationController
.
value
<
_willPopThreshold
;
bool
get
hasReachedCloseThreshold
=>
widget
.
animationController
.
value
<
_
closeProgressThreshold
;
widget
.
animationController
.
value
<
widget
.
closeProgressThreshold
;
void
_close
()
{
isDragging
=
false
;
...
...
lib/src/bottom_sheet_route.dart
View file @
29252fe
...
...
@@ -11,6 +11,7 @@ const Duration _bottomSheetDuration = Duration(milliseconds: 400);
class
_ModalBottomSheet
<
T
>
extends
StatefulWidget
{
const
_ModalBottomSheet
({
Key
key
,
this
.
closeProgressThreshold
,
this
.
route
,
this
.
secondAnimationController
,
this
.
bounce
=
false
,
...
...
@@ -22,6 +23,7 @@ class _ModalBottomSheet<T> extends StatefulWidget {
assert
(
enableDrag
!=
null
),
super
(
key:
key
);
final
double
closeProgressThreshold
;
final
ModalBottomSheetRoute
<
T
>
route
;
final
bool
expanded
;
final
bool
bounce
;
...
...
@@ -85,6 +87,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
label:
_getRouteLabel
(),
explicitChildNodes:
true
,
child:
ModalBottomSheet
(
closeProgressThreshold:
widget
.
closeProgressThreshold
,
expanded:
widget
.
route
.
expanded
,
containerBuilder:
widget
.
route
.
containerBuilder
,
animationController:
widget
.
route
.
_animationController
,
...
...
@@ -113,6 +116,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
class
ModalBottomSheetRoute
<
T
>
extends
PopupRoute
<
T
>
{
ModalBottomSheetRoute
({
this
.
closeProgressThreshold
,
this
.
containerBuilder
,
this
.
builder
,
this
.
scrollController
,
...
...
@@ -131,6 +135,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
assert
(
enableDrag
!=
null
),
super
(
settings:
settings
);
final
double
closeProgressThreshold
;
final
WidgetWithChildBuilder
containerBuilder
;
final
ScrollWidgetBuilder
builder
;
final
bool
expanded
;
...
...
@@ -180,6 +185,7 @@ class ModalBottomSheetRoute<T> extends PopupRoute<T> {
context:
context
,
// removeTop: true,
child:
_ModalBottomSheet
<
T
>(
closeProgressThreshold:
closeProgressThreshold
,
route:
this
,
secondAnimationController:
secondAnimationController
,
expanded:
expanded
,
...
...
lib/src/bottom_sheets/bar_bottom_sheet.dart
View file @
29252fe
...
...
@@ -75,6 +75,7 @@ Future<T> showBarModalBottomSheet<T>({
Color
backgroundColor
,
double
elevation
,
ShapeBorder
shape
,
double
closeProgressThreshold
,
Clip
clipBehavior
,
Color
barrierColor
=
Colors
.
black87
,
bool
bounce
=
true
,
...
...
@@ -99,6 +100,7 @@ Future<T> showBarModalBottomSheet<T>({
.
push
(
ModalBottomSheetRoute
<
T
>(
builder:
builder
,
bounce:
bounce
,
closeProgressThreshold:
closeProgressThreshold
,
containerBuilder:
(
_
,
__
,
child
)
=>
BarBottomSheet
(
child:
child
,
control:
topControl
,
...
...
lib/src/bottom_sheets/material_bottom_sheet.dart
View file @
29252fe
...
...
@@ -6,6 +6,7 @@ import 'dart:async';
Future
<
T
>
showMaterialModalBottomSheet
<
T
>({
@required
BuildContext
context
,
@required
ScrollWidgetBuilder
builder
,
double
closeProgressThreshold
,
Color
backgroundColor
,
double
elevation
,
ShapeBorder
shape
,
...
...
@@ -31,6 +32,7 @@ Future<T> showMaterialModalBottomSheet<T>({
final
result
=
await
Navigator
.
of
(
context
,
rootNavigator:
useRootNavigator
)
.
push
(
ModalBottomSheetRoute
<
T
>(
builder:
builder
,
closeProgressThreshold:
closeProgressThreshold
,
containerBuilder:
_materialContainerBuilder
(
context
,
backgroundColor:
backgroundColor
,
...
...
Please
register
or
login
to post a comment