mohak852

added persistent bottom sheet

#Mon Sep 14 00:47:46 IST 2020
gradle.version=5.6.2
... ...
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true
... ...
... ... @@ -44,6 +44,23 @@ class HomeView extends GetView<HomeController> {
fontSize: 30,
),
),
RaisedButton(
child: Text("data"),
onPressed: (){
Get.bottomSheet(
BottomSheet(
onClosing: (){},
backgroundColor: Colors.amber,
builder: (context) {
return Container(
height: 50,
color: Colors.amber,
);
},
),
persistent: false
);
}),
Text(
'${controller.cases.value.global.totalConfirmed}',
style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
... ...
... ... @@ -6,6 +6,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
this.theme,
this.barrierLabel,
this.backgroundColor,
this.isPersistent,
this.elevation,
this.shape,
this.removeTop = true,
... ... @@ -20,7 +21,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
assert(isDismissible != null),
assert(enableDrag != null),
super(settings: settings);
final bool isPersistent;
final WidgetBuilder builder;
final ThemeData theme;
final bool isScrollControlled;
... ... @@ -79,6 +80,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
elevation:
elevation ?? sheetTheme?.modalElevation ?? sheetTheme?.elevation,
shape: shape,
clipBehavior: clipBehavior,
isScrollControlled: isScrollControlled,
enableDrag: enableDrag,
... ... @@ -100,10 +102,11 @@ class _GetModalBottomSheet<T> extends StatefulWidget {
this.clipBehavior,
this.isScrollControlled = false,
this.enableDrag = true,
this.isPersistent = false,
}) : assert(isScrollControlled != null),
assert(enableDrag != null),
super(key: key);
final bool isPersistent;
final GetModalBottomSheetRoute<T> route;
final bool isScrollControlled;
final Color backgroundColor;
... ... @@ -142,7 +145,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
final animationValue = mediaQuery.accessibleNavigation
? 1.0
: widget.route.animation.value;
return Semantics(
return Semantics(
scopesRoute: true,
namesRoute: true,
label: routeLabel,
... ... @@ -151,7 +154,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
child: CustomSingleChildLayout(
delegate: _GetModalBottomSheetLayout(
animationValue, widget.isScrollControlled),
child: BottomSheet(
child: widget.isPersistent == false ? BottomSheet(
animationController: widget.route._animationController,
onClosing: () {
if (widget.route.isCurrent) {
... ... @@ -164,7 +167,22 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
shape: widget.shape,
clipBehavior: widget.clipBehavior,
enableDrag: widget.enableDrag,
),
) : Scaffold(
bottomSheet: BottomSheet(
animationController: widget.route._animationController,
onClosing: () {
// if (widget.route.isCurrent) {
// Navigator.pop(context);
// }
},
builder: widget.route.builder,
backgroundColor: widget.backgroundColor,
elevation: widget.elevation,
shape: widget.shape,
clipBehavior: widget.clipBehavior,
enableDrag: widget.enableDrag,
),
)
),
),
);
... ... @@ -177,6 +195,7 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget {
const _GetPerModalBottomSheet({
Key key,
this.route,
this.isPersistent,
this.backgroundColor,
this.elevation,
this.shape,
... ... @@ -186,7 +205,7 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget {
}) : assert(isScrollControlled != null),
assert(enableDrag != null),
super(key: key);
final bool isPersistent;
final GetModalBottomSheetRoute<T> route;
final bool isScrollControlled;
final Color backgroundColor;
... ... @@ -238,10 +257,26 @@ class _GetPerModalBottomSheetState<T>
child: CustomSingleChildLayout(
delegate: _GetModalBottomSheetLayout(
animationValue, widget.isScrollControlled),
child: BottomSheet(
child: widget.isPersistent == false ? BottomSheet(
animationController: widget.route._animationController,
onClosing: () {
if (widget.route.isCurrent) {
Navigator.pop(context);
}
},
builder: widget.route.builder,
backgroundColor: widget.backgroundColor,
elevation: widget.elevation,
shape: widget.shape,
clipBehavior: widget.clipBehavior,
enableDrag: widget.enableDrag,
) : Scaffold(
bottomSheet: BottomSheet(
animationController: widget.route._animationController,
onClosing: () {
if (widget.route.isCurrent) {}
// if (widget.route.isCurrent) {
// Navigator.pop(context);
// }
},
builder: widget.route.builder,
backgroundColor: widget.backgroundColor,
... ... @@ -249,7 +284,8 @@ class _GetPerModalBottomSheetState<T>
shape: widget.shape,
clipBehavior: widget.clipBehavior,
enableDrag: widget.enableDrag,
),
),
)
),
),
);
... ...
... ... @@ -627,6 +627,7 @@ extension GetNavigation on GetInterface {
Widget bottomsheet, {
Color backgroundColor,
double elevation,
bool persistent = true,
ShapeBorder shape,
Clip clipBehavior,
Color barrierColor,
... ... @@ -637,6 +638,7 @@ extension GetNavigation on GetInterface {
bool enableDrag = true,
}) {
assert(bottomsheet != null);
assert(persistent != null);
assert(isScrollControlled != null);
assert(useRootNavigator != null);
assert(isDismissible != null);
... ... @@ -645,6 +647,7 @@ extension GetNavigation on GetInterface {
return Navigator.of(overlayContext, rootNavigator: useRootNavigator)
.push(GetModalBottomSheetRoute<T>(
builder: (_) => bottomsheet,
isPersistent: persistent,
theme: Theme.of(key.currentContext, shadowThemeOnly: true),
isScrollControlled: isScrollControlled,
barrierLabel:
... ...