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
Naik
2020-06-28 03:38:53 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2c0b5b28e579f9e54ff83da32ccc657c737b8037
2c0b5b28
1 parent
b82a0c53
Support reverse lists inside
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
6 deletions
example/lib/main.dart
example/lib/modals/modal_inside_modal.dart
example/pubspec.lock
lib/src/bottom_sheet.dart
example/lib/main.dart
View file @
2c0b5b2
...
...
@@ -139,6 +139,16 @@ class _MyHomePageState extends State<MyHomePage> {
scrollController:
scrollController
),
)),
ListTile
(
title:
Text
(
'Bar Modal reverse list'
),
onTap:
()
=>
showBarModalBottomSheet
(
expand:
true
,
context:
context
,
backgroundColor:
Colors
.
transparent
,
builder:
(
context
,
scrollController
)
=>
ModalInsideModal
(
scrollController:
scrollController
,
reverse:
true
),
)),
ListTile
(
title:
Text
(
'Avatar Modal'
),
onTap:
()
=>
showAvatarModalBottomSheet
(
expand:
true
,
...
...
example/lib/modals/modal_inside_modal.dart
View file @
2c0b5b2
...
...
@@ -4,8 +4,10 @@ import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
class
ModalInsideModal
extends
StatelessWidget
{
final
ScrollController
scrollController
;
final
bool
reverse
;
const
ModalInsideModal
({
Key
key
,
this
.
scrollController
})
:
super
(
key:
key
);
const
ModalInsideModal
({
Key
key
,
this
.
scrollController
,
this
.
reverse
=
false
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -16,6 +18,7 @@ class ModalInsideModal extends StatelessWidget {
child:
SafeArea
(
bottom:
false
,
child:
ListView
(
reverse:
reverse
,
shrinkWrap:
true
,
controller:
scrollController
,
physics:
BouncingScrollPhysics
(),
...
...
@@ -24,7 +27,7 @@ class ModalInsideModal extends StatelessWidget {
tiles:
List
.
generate
(
100
,
(
index
)
=>
ListTile
(
title:
Text
(
'Item'
),
title:
Text
(
'Item
$index
'
),
onTap:
()
=>
showCupertinoModalBottomSheet
(
expand:
true
,
isDismissible:
false
,
...
...
@@ -32,7 +35,7 @@ class ModalInsideModal extends StatelessWidget {
backgroundColor:
Colors
.
transparent
,
builder:
(
context
,
scrollController
)
=>
ModalInsideModal
(
scrollController:
scrollController
),
scrollController:
scrollController
,
reverse:
reverse
),
)),
)).
toList
(),
),
...
...
example/pubspec.lock
View file @
2c0b5b2
...
...
@@ -106,7 +106,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.
5
"
version: "0.1.
6
"
path:
dependency: transitive
description:
...
...
lib/src/bottom_sheet.dart
View file @
2c0b5b2
...
...
@@ -242,7 +242,11 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
DateTime
_startTime
;
void
_handleScrollUpdate
(
ScrollNotification
notification
)
{
if
(
notification
.
metrics
.
pixels
<=
notification
.
metrics
.
minScrollExtent
)
{
double
diff
=
_scrollController
.
position
.
axisDirection
==
AxisDirection
.
down
?
_scrollController
.
position
.
pixels
:
_scrollController
.
position
.
maxScrollExtent
-
_scrollController
.
position
.
pixels
;
if
(
diff
<=
0
)
{
//Check if listener is same from scrollController
if
(!
_scrollController
.
hasClients
)
return
;
...
...
@@ -262,7 +266,7 @@ class _ModalBottomSheetState extends State<ModalBottomSheet>
}
if
(
dragDetails
!=
null
)
{
final
duration
=
_startTime
.
difference
(
DateTime
.
now
());
final
offset
=
Offset
(
0
,
_scrollController
.
offset
);
final
offset
=
Offset
(
0
,
diff
);
_velocityTracker
.
addPosition
(
duration
,
offset
);
_handleDragUpdate
(
dragDetails
.
primaryDelta
);
}
else
if
(
isDragging
)
{
...
...
Please
register
or
login
to post a comment