mohak852

added persistent bottom sheet

  1 +#Mon Sep 14 00:47:46 IST 2020
  2 +gradle.version=5.6.2
1 org.gradle.jvmargs=-Xmx1536M 1 org.gradle.jvmargs=-Xmx1536M
2 android.useAndroidX=true 2 android.useAndroidX=true
3 android.enableJetifier=true 3 android.enableJetifier=true
  4 +android.enableR8=true
@@ -44,6 +44,23 @@ class HomeView extends GetView<HomeController> { @@ -44,6 +44,23 @@ class HomeView extends GetView<HomeController> {
44 fontSize: 30, 44 fontSize: 30,
45 ), 45 ),
46 ), 46 ),
  47 + RaisedButton(
  48 + child: Text("data"),
  49 + onPressed: (){
  50 + Get.bottomSheet(
  51 + BottomSheet(
  52 + onClosing: (){},
  53 + backgroundColor: Colors.amber,
  54 + builder: (context) {
  55 + return Container(
  56 + height: 50,
  57 + color: Colors.amber,
  58 + );
  59 + },
  60 + ),
  61 + persistent: false
  62 + );
  63 + }),
47 Text( 64 Text(
48 '${controller.cases.value.global.totalConfirmed}', 65 '${controller.cases.value.global.totalConfirmed}',
49 style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold), 66 style: TextStyle(fontSize: 45, fontWeight: FontWeight.bold),
@@ -6,6 +6,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -6,6 +6,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
6 this.theme, 6 this.theme,
7 this.barrierLabel, 7 this.barrierLabel,
8 this.backgroundColor, 8 this.backgroundColor,
  9 + this.isPersistent,
9 this.elevation, 10 this.elevation,
10 this.shape, 11 this.shape,
11 this.removeTop = true, 12 this.removeTop = true,
@@ -20,7 +21,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -20,7 +21,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
20 assert(isDismissible != null), 21 assert(isDismissible != null),
21 assert(enableDrag != null), 22 assert(enableDrag != null),
22 super(settings: settings); 23 super(settings: settings);
23 - 24 + final bool isPersistent;
24 final WidgetBuilder builder; 25 final WidgetBuilder builder;
25 final ThemeData theme; 26 final ThemeData theme;
26 final bool isScrollControlled; 27 final bool isScrollControlled;
@@ -79,6 +80,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> { @@ -79,6 +80,7 @@ class GetModalBottomSheetRoute<T> extends PopupRoute<T> {
79 elevation: 80 elevation:
80 elevation ?? sheetTheme?.modalElevation ?? sheetTheme?.elevation, 81 elevation ?? sheetTheme?.modalElevation ?? sheetTheme?.elevation,
81 shape: shape, 82 shape: shape,
  83 +
82 clipBehavior: clipBehavior, 84 clipBehavior: clipBehavior,
83 isScrollControlled: isScrollControlled, 85 isScrollControlled: isScrollControlled,
84 enableDrag: enableDrag, 86 enableDrag: enableDrag,
@@ -100,10 +102,11 @@ class _GetModalBottomSheet<T> extends StatefulWidget { @@ -100,10 +102,11 @@ class _GetModalBottomSheet<T> extends StatefulWidget {
100 this.clipBehavior, 102 this.clipBehavior,
101 this.isScrollControlled = false, 103 this.isScrollControlled = false,
102 this.enableDrag = true, 104 this.enableDrag = true,
  105 + this.isPersistent = false,
103 }) : assert(isScrollControlled != null), 106 }) : assert(isScrollControlled != null),
104 assert(enableDrag != null), 107 assert(enableDrag != null),
105 super(key: key); 108 super(key: key);
106 - 109 + final bool isPersistent;
107 final GetModalBottomSheetRoute<T> route; 110 final GetModalBottomSheetRoute<T> route;
108 final bool isScrollControlled; 111 final bool isScrollControlled;
109 final Color backgroundColor; 112 final Color backgroundColor;
@@ -142,7 +145,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { @@ -142,7 +145,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
142 final animationValue = mediaQuery.accessibleNavigation 145 final animationValue = mediaQuery.accessibleNavigation
143 ? 1.0 146 ? 1.0
144 : widget.route.animation.value; 147 : widget.route.animation.value;
145 - return Semantics( 148 + return Semantics(
146 scopesRoute: true, 149 scopesRoute: true,
147 namesRoute: true, 150 namesRoute: true,
148 label: routeLabel, 151 label: routeLabel,
@@ -151,7 +154,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { @@ -151,7 +154,7 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
151 child: CustomSingleChildLayout( 154 child: CustomSingleChildLayout(
152 delegate: _GetModalBottomSheetLayout( 155 delegate: _GetModalBottomSheetLayout(
153 animationValue, widget.isScrollControlled), 156 animationValue, widget.isScrollControlled),
154 - child: BottomSheet( 157 + child: widget.isPersistent == false ? BottomSheet(
155 animationController: widget.route._animationController, 158 animationController: widget.route._animationController,
156 onClosing: () { 159 onClosing: () {
157 if (widget.route.isCurrent) { 160 if (widget.route.isCurrent) {
@@ -164,7 +167,22 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> { @@ -164,7 +167,22 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
164 shape: widget.shape, 167 shape: widget.shape,
165 clipBehavior: widget.clipBehavior, 168 clipBehavior: widget.clipBehavior,
166 enableDrag: widget.enableDrag, 169 enableDrag: widget.enableDrag,
167 - ), 170 + ) : Scaffold(
  171 + bottomSheet: BottomSheet(
  172 + animationController: widget.route._animationController,
  173 + onClosing: () {
  174 + // if (widget.route.isCurrent) {
  175 + // Navigator.pop(context);
  176 + // }
  177 + },
  178 + builder: widget.route.builder,
  179 + backgroundColor: widget.backgroundColor,
  180 + elevation: widget.elevation,
  181 + shape: widget.shape,
  182 + clipBehavior: widget.clipBehavior,
  183 + enableDrag: widget.enableDrag,
  184 + ),
  185 + )
168 ), 186 ),
169 ), 187 ),
170 ); 188 );
@@ -177,6 +195,7 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget { @@ -177,6 +195,7 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget {
177 const _GetPerModalBottomSheet({ 195 const _GetPerModalBottomSheet({
178 Key key, 196 Key key,
179 this.route, 197 this.route,
  198 + this.isPersistent,
180 this.backgroundColor, 199 this.backgroundColor,
181 this.elevation, 200 this.elevation,
182 this.shape, 201 this.shape,
@@ -186,7 +205,7 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget { @@ -186,7 +205,7 @@ class _GetPerModalBottomSheet<T> extends StatefulWidget {
186 }) : assert(isScrollControlled != null), 205 }) : assert(isScrollControlled != null),
187 assert(enableDrag != null), 206 assert(enableDrag != null),
188 super(key: key); 207 super(key: key);
189 - 208 + final bool isPersistent;
190 final GetModalBottomSheetRoute<T> route; 209 final GetModalBottomSheetRoute<T> route;
191 final bool isScrollControlled; 210 final bool isScrollControlled;
192 final Color backgroundColor; 211 final Color backgroundColor;
@@ -238,10 +257,26 @@ class _GetPerModalBottomSheetState<T> @@ -238,10 +257,26 @@ class _GetPerModalBottomSheetState<T>
238 child: CustomSingleChildLayout( 257 child: CustomSingleChildLayout(
239 delegate: _GetModalBottomSheetLayout( 258 delegate: _GetModalBottomSheetLayout(
240 animationValue, widget.isScrollControlled), 259 animationValue, widget.isScrollControlled),
241 - child: BottomSheet( 260 + child: widget.isPersistent == false ? BottomSheet(
  261 + animationController: widget.route._animationController,
  262 + onClosing: () {
  263 + if (widget.route.isCurrent) {
  264 + Navigator.pop(context);
  265 + }
  266 + },
  267 + builder: widget.route.builder,
  268 + backgroundColor: widget.backgroundColor,
  269 + elevation: widget.elevation,
  270 + shape: widget.shape,
  271 + clipBehavior: widget.clipBehavior,
  272 + enableDrag: widget.enableDrag,
  273 + ) : Scaffold(
  274 + bottomSheet: BottomSheet(
242 animationController: widget.route._animationController, 275 animationController: widget.route._animationController,
243 onClosing: () { 276 onClosing: () {
244 - if (widget.route.isCurrent) {} 277 + // if (widget.route.isCurrent) {
  278 + // Navigator.pop(context);
  279 + // }
245 }, 280 },
246 builder: widget.route.builder, 281 builder: widget.route.builder,
247 backgroundColor: widget.backgroundColor, 282 backgroundColor: widget.backgroundColor,
@@ -249,7 +284,8 @@ class _GetPerModalBottomSheetState<T> @@ -249,7 +284,8 @@ class _GetPerModalBottomSheetState<T>
249 shape: widget.shape, 284 shape: widget.shape,
250 clipBehavior: widget.clipBehavior, 285 clipBehavior: widget.clipBehavior,
251 enableDrag: widget.enableDrag, 286 enableDrag: widget.enableDrag,
252 - ), 287 + ),
  288 + )
253 ), 289 ),
254 ), 290 ),
255 ); 291 );
@@ -627,6 +627,7 @@ extension GetNavigation on GetInterface { @@ -627,6 +627,7 @@ extension GetNavigation on GetInterface {
627 Widget bottomsheet, { 627 Widget bottomsheet, {
628 Color backgroundColor, 628 Color backgroundColor,
629 double elevation, 629 double elevation,
  630 + bool persistent = true,
630 ShapeBorder shape, 631 ShapeBorder shape,
631 Clip clipBehavior, 632 Clip clipBehavior,
632 Color barrierColor, 633 Color barrierColor,
@@ -637,6 +638,7 @@ extension GetNavigation on GetInterface { @@ -637,6 +638,7 @@ extension GetNavigation on GetInterface {
637 bool enableDrag = true, 638 bool enableDrag = true,
638 }) { 639 }) {
639 assert(bottomsheet != null); 640 assert(bottomsheet != null);
  641 + assert(persistent != null);
640 assert(isScrollControlled != null); 642 assert(isScrollControlled != null);
641 assert(useRootNavigator != null); 643 assert(useRootNavigator != null);
642 assert(isDismissible != null); 644 assert(isDismissible != null);
@@ -645,6 +647,7 @@ extension GetNavigation on GetInterface { @@ -645,6 +647,7 @@ extension GetNavigation on GetInterface {
645 return Navigator.of(overlayContext, rootNavigator: useRootNavigator) 647 return Navigator.of(overlayContext, rootNavigator: useRootNavigator)
646 .push(GetModalBottomSheetRoute<T>( 648 .push(GetModalBottomSheetRoute<T>(
647 builder: (_) => bottomsheet, 649 builder: (_) => bottomsheet,
  650 + isPersistent: persistent,
648 theme: Theme.of(key.currentContext, shadowThemeOnly: true), 651 theme: Theme.of(key.currentContext, shadowThemeOnly: true),
649 isScrollControlled: isScrollControlled, 652 isScrollControlled: isScrollControlled,
650 barrierLabel: 653 barrierLabel: