Jonny Borges
Committed by GitHub

Merge pull request #604 from mohak852/master

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),
... ...
... ... @@ -7,42 +7,42 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety"
version: "2.4.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
version: "2.0.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.2"
version: "1.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
version: "1.1.3"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.0.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.2"
version: "1.14.13"
dio:
dependency: "direct main"
description:
... ... @@ -56,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
... ... @@ -87,21 +87,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety"
version: "0.12.8"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
version: "1.1.8"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
version: "1.7.0"
sky_engine:
dependency: transitive
description: flutter
... ... @@ -113,55 +113,55 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.0.5"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety"
version: "0.2.17"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
version: "1.2.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.2"
version: "2.0.8"
sdks:
dart: ">=2.10.0-0.0.dev <2.10.0"
dart: ">=2.9.0-14.0.dev <3.0.0"
... ...
... ... @@ -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,6 +145,109 @@ class _GetModalBottomSheetState<T> extends State<_GetModalBottomSheet<T>> {
final animationValue = mediaQuery.accessibleNavigation
? 1.0
: widget.route.animation.value;
return Semantics(
scopesRoute: true,
namesRoute: true,
label: routeLabel,
explicitChildNodes: true,
child: ClipRect(
child: CustomSingleChildLayout(
delegate: _GetModalBottomSheetLayout(
animationValue, widget.isScrollControlled),
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) {
// Navigator.pop(context);
// }
},
builder: widget.route.builder,
backgroundColor: widget.backgroundColor,
elevation: widget.elevation,
shape: widget.shape,
clipBehavior: widget.clipBehavior,
enableDrag: widget.enableDrag,
),
)
),
),
);
},
);
}
}
class _GetPerModalBottomSheet<T> extends StatefulWidget {
const _GetPerModalBottomSheet({
Key key,
this.route,
this.isPersistent,
this.backgroundColor,
this.elevation,
this.shape,
this.clipBehavior,
this.isScrollControlled = false,
this.enableDrag = true,
}) : assert(isScrollControlled != null),
assert(enableDrag != null),
super(key: key);
final bool isPersistent;
final GetModalBottomSheetRoute<T> route;
final bool isScrollControlled;
final Color backgroundColor;
final double elevation;
final ShapeBorder shape;
final Clip clipBehavior;
final bool enableDrag;
@override
// ignore: lines_longer_than_80_chars
_GetPerModalBottomSheetState<T> createState() =>
_GetPerModalBottomSheetState<T>();
}
// ignore: lines_longer_than_80_chars
class _GetPerModalBottomSheetState<T>
extends State<_GetPerModalBottomSheet<T>> {
String _getRouteLabel(MaterialLocalizations localizations) {
if ((Theme.of(context).platform == TargetPlatform.android) ||
(Theme.of(context).platform == TargetPlatform.fuchsia)) {
return localizations.dialogLabel;
} else {
return '';
}
}
@override
Widget build(BuildContext context) {
assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasMaterialLocalizations(context));
final mediaQuery = MediaQuery.of(context);
final localizations = MaterialLocalizations.of(context);
final routeLabel = _getRouteLabel(localizations);
return AnimatedBuilder(
animation: widget.route.animation,
builder: (context, child) {
// Disable the initial animation when accessible navigation is on so
// that the semantics are added to the tree at the correct time.
final animationValue = mediaQuery.accessibleNavigation
? 1.0
: widget.route.animation.value;
return Semantics(
scopesRoute: true,
namesRoute: true,
... ... @@ -151,7 +257,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 +270,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,
),
)
),
),
);
... ...
... ... @@ -631,6 +631,7 @@ extension GetNavigation on GetInterface {
Widget bottomsheet, {
Color backgroundColor,
double elevation,
bool persistent = true,
ShapeBorder shape,
Clip clipBehavior,
Color barrierColor,
... ... @@ -641,6 +642,7 @@ extension GetNavigation on GetInterface {
bool enableDrag = true,
}) {
assert(bottomsheet != null);
assert(persistent != null);
assert(isScrollControlled != null);
assert(useRootNavigator != null);
assert(isDismissible != null);
... ... @@ -649,6 +651,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:
... ...
... ... @@ -589,4 +589,4 @@ class RxInt extends _BaseRxNum<int> {
/// Returns `this.toDouble()`.
double truncateToDouble() => _value.truncateToDouble();
}
\ No newline at end of file
}
... ...
... ... @@ -7,42 +7,42 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety"
version: "2.4.2"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
version: "2.0.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.2"
version: "1.0.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
version: "1.1.3"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.0.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.2"
version: "1.14.13"
effective_dart:
dependency: "direct dev"
description:
... ... @@ -56,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
... ... @@ -73,21 +73,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety"
version: "0.12.8"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
version: "1.1.8"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
version: "1.7.0"
sky_engine:
dependency: transitive
description: flutter
... ... @@ -99,55 +99,55 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety"
version: "1.7.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety"
version: "1.9.5"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety"
version: "2.0.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety"
version: "1.0.5"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety"
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety"
version: "0.2.17"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.2"
version: "1.2.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.2"
version: "2.0.8"
sdks:
dart: ">=2.10.0-0.0.dev <2.10.0"
dart: ">=2.9.0-14.0.dev <3.0.0"
... ...