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
2020-05-28 13:47:15 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d7728be0ae094ccf8ac150ca0ca1e6812a259026
d7728be0
1 parent
06296fba
Fix scroll handling for physics that not overflow as ClampingScrollPhysics
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
19 deletions
example/ios/Runner.xcodeproj/project.pbxproj
example/lib/main.dart
example/lib/modals/modal_inside_modal.dart
lib/src/bottom_sheet.dart
example/ios/Runner.xcodeproj/project.pbxproj
View file @
d7728be
...
...
@@ -10,11 +10,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
212D1E304840672EFB9BFFA7 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D52A2E75CF34C7E6DC549F4 /* Pods_Runner.framework */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
...
...
@@ -27,8 +23,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
...
...
@@ -40,14 +34,12 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
248080BB287D735D5E630360 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
8D52A2E75CF34C7E6DC549F4 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
...
...
@@ -62,8 +54,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
212D1E304840672EFB9BFFA7 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
...
...
@@ -85,9 +75,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
...
...
@@ -252,7 +240,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\"
embed_and_
thin";
};
87338F8232AE1406F5B9308C /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
...
...
example/lib/main.dart
View file @
d7728be
...
...
@@ -179,7 +179,6 @@ class _MyHomePageState extends State<MyHomePage> {
expand:
true
,
context:
context
,
backgroundColor:
Colors
.
transparent
,
animationCurve:
Curves
.
easeInExpo
,
builder:
(
context
,
scrollController
)
=>
ModalInsideModal
(
scrollController:
scrollController
),
...
...
example/lib/modals/modal_inside_modal.dart
View file @
d7728be
...
...
@@ -18,7 +18,7 @@ class ModalInsideModal extends StatelessWidget {
child:
ListView
(
shrinkWrap:
true
,
controller:
scrollController
,
physics:
Bounc
ingScrollPhysics
(),
physics:
Clamp
ingScrollPhysics
(),
children:
ListTile
.
divideTiles
(
context:
context
,
tiles:
List
.
generate
(
...
...
lib/src/bottom_sheet.dart
View file @
d7728be
...
...
@@ -240,14 +240,30 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
void
_handleScrollUpdate
(
ScrollNotification
notification
)
{
if
(
notification
.
metrics
.
pixels
<=
notification
.
metrics
.
minScrollExtent
)
{
//Check if listener is same from scrollController
if
(!
_scrollController
.
hasClients
)
return
;
if
(
_scrollController
.
position
.
pixels
!=
notification
.
metrics
.
pixels
)
{
// Check if listener is same from scrollController.
// TODO: Improve the way it checks if it the same view controller
// Use PrimaryScrollController
if
(
_scrollController
.
position
.
pixels
!=
notification
.
metrics
.
pixels
&&
!(
_scrollController
.
position
.
pixels
==
0
&&
notification
.
metrics
.
pixels
>=
0
))
{
return
;
}
// Clamping Scroll Physics end with a ScrollEndNotification with a DragEndDetail class
// while Bouncing Scroll Physics or other physics that Overflow don't return a drag end info
// We use the velocity from DragEndDetail in case it is available
if
(
notification
is
ScrollEndNotification
&&
notification
.
dragDetails
!=
null
)
{
_handleDragEnd
(
notification
.
dragDetails
.
primaryVelocity
);
_velocityTracker
=
null
;
_startTime
=
null
;
return
;
}
// Otherwise the calculate the velocity with a VelocityTracker
DragUpdateDetails
dragDetails
;
if
(
notification
is
ScrollStartNotification
)
{
if
(
_velocityTracker
==
null
)
{
_velocityTracker
=
VelocityTracker
();
_startTime
=
DateTime
.
now
();
}
...
...
@@ -259,11 +275,13 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
}
if
(
dragDetails
!=
null
)
{
final
duration
=
_startTime
.
difference
(
DateTime
.
now
());
final
offset
=
Offset
(
0
,
_scrollController
.
offset
);
final
offset
=
Offset
(
0
,
notification
.
metrics
.
pixels
);
_velocityTracker
.
addPosition
(
duration
,
offset
);
_handleDragUpdate
(
dragDetails
.
primaryDelta
);
}
else
if
(
isDragging
)
{
final
velocity
=
_velocityTracker
.
getVelocity
().
pixelsPerSecond
.
dy
;
_velocityTracker
=
null
;
_startTime
=
null
;
_handleDragEnd
(
velocity
);
}
}
...
...
Please
register
or
login
to post a comment