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
Jaime Blasco
2022-09-05 12:06:22 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
67c5ebf1b1cc5481dc27badacc48b6c81639962b
67c5ebf1
1 parent
40db392c
fix: allow exposing parametes
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
16 deletions
example/ios/Podfile.lock
example/ios/Runner/Info.plist
lib/src/bottom_sheet.dart
lib/src/bottom_sheet_route.dart
lib/src/bottom_sheets/bar_bottom_sheet.dart
lib/src/bottom_sheets/cupertino_bottom_sheet.dart
lib/src/bottom_sheets/material_bottom_sheet.dart
example/ios/Podfile.lock
View file @
67c5ebf
...
...
@@ -19,4 +19,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
COCOAPODS: 1.11.
2
COCOAPODS: 1.11.
3
...
...
example/ios/Runner/Info.plist
View file @
67c5ebf
...
...
@@ -41,5 +41,7 @@
</array>
<key>
UIViewControllerBasedStatusBarAppearance
</key>
<false/>
<key>
CADisableMinimumFrameDurationOnPhone
</key>
<true/>
</dict>
</plist>
...
...
lib/src/bottom_sheet.dart
View file @
67c5ebf
...
...
@@ -10,7 +10,7 @@ import 'package:modal_bottom_sheet/src/utils/scroll_to_top_status_bar.dart';
import
'package:modal_bottom_sheet/src/utils/bottom_sheet_suspended_curve.dart'
;
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
;
...
...
@@ -34,7 +34,6 @@ class ModalBottomSheet extends StatefulWidget {
/// Creates a bottom sheet.
const
ModalBottomSheet
({
Key
?
key
,
this
.
closeProgressThreshold
,
required
this
.
animationController
,
this
.
animationCurve
,
this
.
enableDrag
=
true
,
...
...
@@ -45,11 +44,16 @@ class ModalBottomSheet extends StatefulWidget {
required
this
.
expanded
,
required
this
.
onClosing
,
required
this
.
child
,
})
:
super
(
key:
key
);
this
.
minFlingVelocity
=
_minFlingVelocity
,
double
?
closeProgressThreshold
,
this
.
willPopThreshold
=
_willPopThreshold
,
})
:
closeProgressThreshold
=
closeProgressThreshold
??
_closeProgressThreshold
,
super
(
key:
key
);
/// The closeProgressThreshold parameter
/// specifies when the bottom sheet will be dismissed when user drags it.
final
double
?
closeProgressThreshold
;
final
double
closeProgressThreshold
;
/// The animation controller that controls the bottom sheet's entrance and
/// exit animations.
...
...
@@ -100,6 +104,14 @@ class ModalBottomSheet extends StatefulWidget {
final
ScrollController
scrollController
;
/// The minFlingVelocity parameter
/// Determines how fast the sheet should be flinged before closing.
final
double
minFlingVelocity
;
/// The willPopThreshold parameter
/// Determines how far the sheet should be flinged before closing.
final
double
willPopThreshold
;
@override
ModalBottomSheetState
createState
()
=>
ModalBottomSheetState
();
...
...
@@ -147,8 +159,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
widget
.
animationController
.
value
<
_willPopThreshold
;
bool
get
hasReachedCloseThreshold
=>
widget
.
animationController
.
value
<
(
widget
.
closeProgressThreshold
??
_closeProgressThreshold
);
widget
.
animationController
.
value
<
widget
.
closeProgressThreshold
;
void
_close
()
{
isDragging
=
false
;
...
...
@@ -237,7 +248,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
}
// If speed is bigger than _minFlingVelocity try to close it
if
(
velocity
>
_
minFlingVelocity
)
{
if
(
velocity
>
widget
.
minFlingVelocity
)
{
tryClose
();
}
else
if
(
hasReachedCloseThreshold
)
{
if
(
widget
.
animationController
.
value
>
0.0
)
{
...
...
@@ -327,7 +338,7 @@ class ModalBottomSheetState extends State<ModalBottomSheet>
}
}
Curve
get
_defaultCurve
=>
widget
.
animationCurve
??
_
modalBottomSheetCurve
;
Curve
get
_defaultCurve
=>
widget
.
animationCurve
??
_
decelerateEasing
;
@override
void
initState
()
{
...
...
lib/src/bottom_sheet_route.dart
View file @
67c5ebf
...
...
@@ -136,9 +136,10 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> {
required
this
.
expanded
,
this
.
bounce
=
false
,
this
.
animationCurve
,
this
.
duration
,
Duration
?
duration
,
RouteSettings
?
settings
,
})
:
super
(
settings:
settings
);
})
:
duration
=
duration
??
_bottomSheetDuration
,
super
(
settings:
settings
);
final
double
?
closeProgressThreshold
;
final
WidgetWithChildBuilder
?
containerBuilder
;
...
...
@@ -150,13 +151,13 @@ class ModalBottomSheetRoute<T> extends PageRoute<T> {
final
bool
enableDrag
;
final
ScrollController
?
scrollController
;
final
Duration
?
duration
;
final
Duration
duration
;
final
AnimationController
?
secondAnimationController
;
final
Curve
?
animationCurve
;
@override
Duration
get
transitionDuration
=>
duration
??
_bottomSheetDuration
;
Duration
get
transitionDuration
=>
duration
;
@override
bool
get
barrierDismissible
=>
isDismissible
;
...
...
@@ -244,6 +245,7 @@ Future<T?> showCustomModalBottomSheet<T>({
bool
enableDrag
=
true
,
Duration
?
duration
,
RouteSettings
?
settings
,
double
?
closeProgressThreshold
,
})
async
{
assert
(
debugCheckHasMediaQuery
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
...
...
@@ -268,6 +270,7 @@ Future<T?> showCustomModalBottomSheet<T>({
animationCurve:
animationCurve
,
duration:
duration
,
settings:
settings
,
closeProgressThreshold:
closeProgressThreshold
,
));
return
result
;
}
...
...
lib/src/bottom_sheets/bar_bottom_sheet.dart
View file @
67c5ebf
...
...
@@ -81,7 +81,6 @@ Future<T?> showBarModalBottomSheet<T>({
Color
?
backgroundColor
,
double
?
elevation
,
ShapeBorder
?
shape
,
double
?
closeProgressThreshold
,
Clip
?
clipBehavior
,
Color
barrierColor
=
Colors
.
black87
,
bool
bounce
=
true
,
...
...
@@ -95,6 +94,7 @@ Future<T?> showBarModalBottomSheet<T>({
Duration
?
duration
,
RouteSettings
?
settings
,
SystemUiOverlayStyle
?
overlayStyle
,
double
?
closeProgressThreshold
,
})
async
{
assert
(
debugCheckHasMediaQuery
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
...
...
lib/src/bottom_sheets/cupertino_bottom_sheet.dart
View file @
67c5ebf
...
...
@@ -74,7 +74,6 @@ Future<T?> showCupertinoModalBottomSheet<T>({
required
WidgetBuilder
builder
,
Color
?
backgroundColor
,
double
?
elevation
,
double
?
closeProgressThreshold
,
ShapeBorder
?
shape
,
Clip
?
clipBehavior
,
Color
?
barrierColor
,
...
...
@@ -92,6 +91,7 @@ Future<T?> showCupertinoModalBottomSheet<T>({
Color
?
transitionBackgroundColor
,
BoxShadow
?
shadow
,
SystemUiOverlayStyle
?
overlayStyle
,
double
?
closeProgressThreshold
,
})
async
{
assert
(
debugCheckHasMediaQuery
(
context
));
final
hasMaterialLocalizations
=
...
...
lib/src/bottom_sheets/material_bottom_sheet.dart
View file @
67c5ebf
...
...
@@ -5,7 +5,6 @@ import 'dart:async';
/// Shows a modal material design bottom sheet.
Future
<
T
?>
showMaterialModalBottomSheet
<
T
>({
required
BuildContext
context
,
double
?
closeProgressThreshold
,
required
WidgetBuilder
builder
,
Color
?
backgroundColor
,
double
?
elevation
,
...
...
@@ -21,6 +20,7 @@ Future<T?> showMaterialModalBottomSheet<T>({
bool
enableDrag
=
true
,
Duration
?
duration
,
RouteSettings
?
settings
,
double
?
closeProgressThreshold
,
})
async
{
assert
(
debugCheckHasMediaQuery
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
...
...
Please
register
or
login
to post a comment