Showing
6 changed files
with
52 additions
and
38 deletions
| 1 | +## [3.8.0] | ||
| 2 | +- Added: Snackbar Status: Open, Opening, Closing and Closed | ||
| 3 | +example: | ||
| 4 | +```dart | ||
| 5 | + Get.snackbar('title', 'message', snackbarStatus: (status) { | ||
| 6 | + if (status == SnackbarStatus.CLOSED) { | ||
| 7 | + // made anything | ||
| 8 | + } | ||
| 9 | + }); | ||
| 10 | +``` | ||
| 11 | + | ||
| 1 | ## [3.7.0] | 12 | ## [3.7.0] |
| 2 | - Added: RxSet. Sets can now also be reactive. | 13 | - Added: RxSet. Sets can now also be reactive. |
| 3 | - Added isDesktop/isMobile (@roipeker) | 14 | - Added isDesktop/isMobile (@roipeker) |
| @@ -73,7 +73,7 @@ packages: | @@ -73,7 +73,7 @@ packages: | ||
| 73 | path: ".." | 73 | path: ".." |
| 74 | relative: true | 74 | relative: true |
| 75 | source: path | 75 | source: path |
| 76 | - version: "3.7.0" | 76 | + version: "3.8.0" |
| 77 | http_parser: | 77 | http_parser: |
| 78 | dependency: transitive | 78 | dependency: transitive |
| 79 | description: | 79 | description: |
| @@ -253,7 +253,7 @@ extension GetNavigation on GetInterface { | @@ -253,7 +253,7 @@ extension GetNavigation on GetInterface { | ||
| 253 | arguments: arguments); | 253 | arguments: arguments); |
| 254 | } | 254 | } |
| 255 | 255 | ||
| 256 | - /// Returns true if a Snackbar, Dialog or BottomSheet is currently showing | 256 | + /// Returns true if a Snackbar, Dialog or BottomSheet is currently OPEN |
| 257 | bool get isOverlaysOpen => | 257 | bool get isOverlaysOpen => |
| 258 | (isSnackbarOpen || isDialogOpen || isBottomSheetOpen); | 258 | (isSnackbarOpen || isDialogOpen || isBottomSheetOpen); |
| 259 | 259 | ||
| @@ -664,12 +664,13 @@ extension GetNavigation on GetInterface { | @@ -664,12 +664,13 @@ extension GetNavigation on GetInterface { | ||
| 664 | Curve forwardAnimationCurve = Curves.easeOutCirc, | 664 | Curve forwardAnimationCurve = Curves.easeOutCirc, |
| 665 | Curve reverseAnimationCurve = Curves.easeOutCirc, | 665 | Curve reverseAnimationCurve = Curves.easeOutCirc, |
| 666 | Duration animationDuration = const Duration(seconds: 1), | 666 | Duration animationDuration = const Duration(seconds: 1), |
| 667 | - SnackStatusCallback onStatusChanged, | 667 | + SnackbarStatusCallback snackbarStatus, |
| 668 | double barBlur = 0.0, | 668 | double barBlur = 0.0, |
| 669 | double overlayBlur = 0.0, | 669 | double overlayBlur = 0.0, |
| 670 | - Color overlayColor = Colors.transparent, | ||
| 671 | - Form userInputForm}) { | 670 | + Color overlayColor, |
| 671 | + Form userInputForm}) async { | ||
| 672 | GetBar getBar = GetBar( | 672 | GetBar getBar = GetBar( |
| 673 | + snackbarStatus: snackbarStatus, | ||
| 673 | title: title, | 674 | title: title, |
| 674 | message: message, | 675 | message: message, |
| 675 | titleText: titleText, | 676 | titleText: titleText, |
| @@ -749,9 +750,11 @@ extension GetNavigation on GetInterface { | @@ -749,9 +750,11 @@ extension GetNavigation on GetInterface { | ||
| 749 | Duration animationDuration, | 750 | Duration animationDuration, |
| 750 | double barBlur, | 751 | double barBlur, |
| 751 | double overlayBlur, | 752 | double overlayBlur, |
| 753 | + SnackbarStatusCallback snackbarStatus, | ||
| 752 | Color overlayColor, | 754 | Color overlayColor, |
| 753 | - Form userInputForm}) { | 755 | + Form userInputForm}) async { |
| 754 | GetBar getBar = GetBar( | 756 | GetBar getBar = GetBar( |
| 757 | + snackbarStatus: snackbarStatus, | ||
| 755 | titleText: (title == null) | 758 | titleText: (title == null) |
| 756 | ? null | 759 | ? null |
| 757 | : titleText ?? | 760 | : titleText ?? |
| @@ -3,9 +3,9 @@ import 'dart:ui'; | @@ -3,9 +3,9 @@ import 'dart:ui'; | ||
| 3 | import 'package:flutter/material.dart'; | 3 | import 'package:flutter/material.dart'; |
| 4 | import 'package:flutter/scheduler.dart'; | 4 | import 'package:flutter/scheduler.dart'; |
| 5 | import 'package:get/get.dart'; | 5 | import 'package:get/get.dart'; |
| 6 | -import 'snack_route.dart' as route; | 6 | +import 'snack_route.dart'; |
| 7 | 7 | ||
| 8 | -typedef void SnackStatusCallback(SnackStatus status); | 8 | +typedef void SnackbarStatusCallback(SnackbarStatus status); |
| 9 | typedef void OnTap(GetBar snack); | 9 | typedef void OnTap(GetBar snack); |
| 10 | 10 | ||
| 11 | // ignore: must_be_immutable | 11 | // ignore: must_be_immutable |
| @@ -42,7 +42,7 @@ class GetBar<T extends Object> extends StatefulWidget { | @@ -42,7 +42,7 @@ class GetBar<T extends Object> extends StatefulWidget { | ||
| 42 | Curve forwardAnimationCurve = Curves.easeOutCirc, | 42 | Curve forwardAnimationCurve = Curves.easeOutCirc, |
| 43 | Curve reverseAnimationCurve = Curves.easeOutCirc, | 43 | Curve reverseAnimationCurve = Curves.easeOutCirc, |
| 44 | Duration animationDuration = const Duration(seconds: 1), | 44 | Duration animationDuration = const Duration(seconds: 1), |
| 45 | - SnackStatusCallback onStatusChanged, | 45 | + SnackbarStatusCallback snackbarStatus, |
| 46 | double barBlur = 0.0, | 46 | double barBlur = 0.0, |
| 47 | double overlayBlur = 0.0, | 47 | double overlayBlur = 0.0, |
| 48 | Color overlayColor = Colors.transparent, | 48 | Color overlayColor = Colors.transparent, |
| @@ -83,11 +83,11 @@ class GetBar<T extends Object> extends StatefulWidget { | @@ -83,11 +83,11 @@ class GetBar<T extends Object> extends StatefulWidget { | ||
| 83 | this.overlayColor = overlayColor, | 83 | this.overlayColor = overlayColor, |
| 84 | this.userInputForm = userInputForm, | 84 | this.userInputForm = userInputForm, |
| 85 | super(key: key) { | 85 | super(key: key) { |
| 86 | - this.onStatusChanged = onStatusChanged ?? (status) {}; | 86 | + this.snackbarStatus = snackbarStatus ?? (status) {}; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | /// A callback for you to listen to the different Snack status | 89 | /// A callback for you to listen to the different Snack status |
| 90 | - SnackStatusCallback onStatusChanged; | 90 | + SnackbarStatusCallback snackbarStatus; |
| 91 | 91 | ||
| 92 | /// The title displayed to the user | 92 | /// The title displayed to the user |
| 93 | final String title; | 93 | final String title; |
| @@ -209,11 +209,11 @@ class GetBar<T extends Object> extends StatefulWidget { | @@ -209,11 +209,11 @@ class GetBar<T extends Object> extends StatefulWidget { | ||
| 209 | /// A [TextFormField] in case you want a simple user input. Every other widget is ignored if this is not null. | 209 | /// A [TextFormField] in case you want a simple user input. Every other widget is ignored if this is not null. |
| 210 | final Form userInputForm; | 210 | final Form userInputForm; |
| 211 | 211 | ||
| 212 | - route.SnackRoute<T> _snackRoute; | 212 | + SnackRoute<T> _snackRoute; |
| 213 | 213 | ||
| 214 | - /// Show the snack. Kicks in [SnackStatus.IS_APPEARING] state followed by [SnackStatus.SHOWING] | 214 | + /// Show the snack. Kicks in [SnackbarStatus.OPENING] state followed by [SnackbarStatus.OPEN] |
| 215 | Future<T> show() async { | 215 | Future<T> show() async { |
| 216 | - _snackRoute = route.showSnack<T>( | 216 | + _snackRoute = showSnack<T>( |
| 217 | snack: this, | 217 | snack: this, |
| 218 | ) as SnackRoute<T>; | 218 | ) as SnackRoute<T>; |
| 219 | return await Get.key.currentState.push(_snackRoute); | 219 | return await Get.key.currentState.push(_snackRoute); |
| @@ -232,7 +232,7 @@ class GetBar<T extends Object> extends StatefulWidget { | @@ -232,7 +232,7 @@ class GetBar<T extends Object> extends StatefulWidget { | ||
| 232 | return _snackRoute.completed; | 232 | return _snackRoute.completed; |
| 233 | } else if (_snackRoute.isActive) { | 233 | } else if (_snackRoute.isActive) { |
| 234 | // removeRoute is called every time you dismiss a Snack that is not the top route. | 234 | // removeRoute is called every time you dismiss a Snack that is not the top route. |
| 235 | - // It will not animate back and listeners will not detect SnackStatus.IS_HIDING or SnackStatus.DISMISSED | 235 | + // It will not animate back and listeners will not detect SnackbarStatus.CLOSING or SnackbarStatus.CLOSED |
| 236 | // To avoid this, always make sure that Snack is the top route when it is being dismissed | 236 | // To avoid this, always make sure that Snack is the top route when it is being dismissed |
| 237 | _snackRoute.navigator.removeRoute(_snackRoute); | 237 | _snackRoute.navigator.removeRoute(_snackRoute); |
| 238 | } | 238 | } |
| @@ -242,12 +242,12 @@ class GetBar<T extends Object> extends StatefulWidget { | @@ -242,12 +242,12 @@ class GetBar<T extends Object> extends StatefulWidget { | ||
| 242 | 242 | ||
| 243 | /// Checks if the snack is visible | 243 | /// Checks if the snack is visible |
| 244 | bool isShowing() { | 244 | bool isShowing() { |
| 245 | - return _snackRoute?.currentStatus == SnackStatus.SHOWING; | 245 | + return _snackRoute?.currentStatus == SnackbarStatus.OPEN; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | /// Checks if the snack is dismissed | 248 | /// Checks if the snack is dismissed |
| 249 | bool isDismissed() { | 249 | bool isDismissed() { |
| 250 | - return _snackRoute?.currentStatus == SnackStatus.DISMISSED; | 250 | + return _snackRoute?.currentStatus == SnackbarStatus.CLOSED; |
| 251 | } | 251 | } |
| 252 | 252 | ||
| 253 | @override | 253 | @override |
| @@ -258,7 +258,7 @@ class GetBar<T extends Object> extends StatefulWidget { | @@ -258,7 +258,7 @@ class GetBar<T extends Object> extends StatefulWidget { | ||
| 258 | 258 | ||
| 259 | class _GetBarState<K extends Object> extends State<GetBar> | 259 | class _GetBarState<K extends Object> extends State<GetBar> |
| 260 | with TickerProviderStateMixin { | 260 | with TickerProviderStateMixin { |
| 261 | - SnackStatus currentStatus; | 261 | + SnackbarStatus currentStatus; |
| 262 | 262 | ||
| 263 | AnimationController _fadeController; | 263 | AnimationController _fadeController; |
| 264 | Animation<double> _fadeAnimation; | 264 | Animation<double> _fadeAnimation; |
| @@ -732,9 +732,9 @@ enum SnackStyle { FLOATING, GROUNDED } | @@ -732,9 +732,9 @@ enum SnackStyle { FLOATING, GROUNDED } | ||
| 732 | /// If vertical, dismiss down will be allowed if [SnackPosition.BOTTOM] | 732 | /// If vertical, dismiss down will be allowed if [SnackPosition.BOTTOM] |
| 733 | enum SnackDismissDirection { HORIZONTAL, VERTICAL } | 733 | enum SnackDismissDirection { HORIZONTAL, VERTICAL } |
| 734 | 734 | ||
| 735 | -/// Indicates the animation status | ||
| 736 | -/// [SnackStatus.SHOWING] Snack has stopped and the user can see it | ||
| 737 | -/// [SnackStatus.DISMISSED] Snack has finished its mission and returned any pending values | ||
| 738 | -/// [SnackStatus.IS_APPEARING] Snack is moving towards [SnackStatus.SHOWING] | ||
| 739 | -/// [SnackStatus.IS_HIDING] Snack is moving towards [] [SnackStatus.DISMISSED] | ||
| 740 | -enum SnackStatus { SHOWING, DISMISSED, IS_APPEARING, IS_HIDING } | 735 | +/// Indicates Status of snackbar |
| 736 | +/// [SnackbarStatus.OPEN] Snack is fully open, [SnackbarStatus.CLOSED] Snackbar has closed, | ||
| 737 | +/// [SnackbarStatus.OPENING] Starts with the opening animation and ends with the full | ||
| 738 | +/// snackbar display, [SnackbarStatus.CLOSING] Starts with the closing animation and ends | ||
| 739 | +/// with the full snackbar dispose | ||
| 740 | +enum SnackbarStatus { OPEN, CLOSED, OPENING, CLOSING } |
| @@ -19,7 +19,7 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -19,7 +19,7 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 19 | }); | 19 | }); |
| 20 | 20 | ||
| 21 | _configureAlignment(this.snack.snackPosition); | 21 | _configureAlignment(this.snack.snackPosition); |
| 22 | - _onStatusChanged = snack.onStatusChanged; | 22 | + _snackbarStatus = snack.snackbarStatus; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | _configureAlignment(SnackPosition snackPosition) { | 25 | _configureAlignment(SnackPosition snackPosition) { |
| @@ -45,7 +45,7 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -45,7 +45,7 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 45 | Future<T> get completed => _transitionCompleter.future; | 45 | Future<T> get completed => _transitionCompleter.future; |
| 46 | final Completer<T> _transitionCompleter = Completer<T>(); | 46 | final Completer<T> _transitionCompleter = Completer<T>(); |
| 47 | 47 | ||
| 48 | - SnackStatusCallback _onStatusChanged; | 48 | + SnackbarStatusCallback _snackbarStatus; |
| 49 | Alignment _initialAlignment; | 49 | Alignment _initialAlignment; |
| 50 | Alignment _endAlignment; | 50 | Alignment _endAlignment; |
| 51 | bool _wasDismissedBySwipe = false; | 51 | bool _wasDismissedBySwipe = false; |
| @@ -115,8 +115,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -115,8 +115,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 115 | direction: _getDismissDirection(), | 115 | direction: _getDismissDirection(), |
| 116 | resizeDuration: null, | 116 | resizeDuration: null, |
| 117 | confirmDismiss: (_) { | 117 | confirmDismiss: (_) { |
| 118 | - if (currentStatus == SnackStatus.IS_APPEARING || | ||
| 119 | - currentStatus == SnackStatus.IS_HIDING) { | 118 | + if (currentStatus == SnackbarStatus.OPENING || |
| 119 | + currentStatus == SnackbarStatus.CLOSING) { | ||
| 120 | return Future.value(false); | 120 | return Future.value(false); |
| 121 | } | 121 | } |
| 122 | return Future.value(true); | 122 | return Future.value(true); |
| @@ -231,24 +231,24 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -231,24 +231,24 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | T _result; | 233 | T _result; |
| 234 | - SnackStatus currentStatus; | 234 | + SnackbarStatus currentStatus; |
| 235 | 235 | ||
| 236 | //copy of `routes.dart` | 236 | //copy of `routes.dart` |
| 237 | void _handleStatusChanged(AnimationStatus status) { | 237 | void _handleStatusChanged(AnimationStatus status) { |
| 238 | switch (status) { | 238 | switch (status) { |
| 239 | case AnimationStatus.completed: | 239 | case AnimationStatus.completed: |
| 240 | - currentStatus = SnackStatus.SHOWING; | ||
| 241 | - _onStatusChanged(currentStatus); | 240 | + currentStatus = SnackbarStatus.OPEN; |
| 241 | + _snackbarStatus(currentStatus); | ||
| 242 | if (overlayEntries.isNotEmpty) overlayEntries.first.opaque = opaque; | 242 | if (overlayEntries.isNotEmpty) overlayEntries.first.opaque = opaque; |
| 243 | 243 | ||
| 244 | break; | 244 | break; |
| 245 | case AnimationStatus.forward: | 245 | case AnimationStatus.forward: |
| 246 | - currentStatus = SnackStatus.IS_APPEARING; | ||
| 247 | - _onStatusChanged(currentStatus); | 246 | + currentStatus = SnackbarStatus.OPENING; |
| 247 | + _snackbarStatus(currentStatus); | ||
| 248 | break; | 248 | break; |
| 249 | case AnimationStatus.reverse: | 249 | case AnimationStatus.reverse: |
| 250 | - currentStatus = SnackStatus.IS_HIDING; | ||
| 251 | - _onStatusChanged(currentStatus); | 250 | + currentStatus = SnackbarStatus.CLOSING; |
| 251 | + _snackbarStatus(currentStatus); | ||
| 252 | if (overlayEntries.isNotEmpty) overlayEntries.first.opaque = false; | 252 | if (overlayEntries.isNotEmpty) overlayEntries.first.opaque = false; |
| 253 | break; | 253 | break; |
| 254 | case AnimationStatus.dismissed: | 254 | case AnimationStatus.dismissed: |
| @@ -257,8 +257,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | @@ -257,8 +257,8 @@ class SnackRoute<T> extends OverlayRoute<T> { | ||
| 257 | // the transition and hits the dismissed status. For example, the iOS | 257 | // the transition and hits the dismissed status. For example, the iOS |
| 258 | // back gesture drives this animation to the dismissed status before | 258 | // back gesture drives this animation to the dismissed status before |
| 259 | // popping the navigator. | 259 | // popping the navigator. |
| 260 | - currentStatus = SnackStatus.DISMISSED; | ||
| 261 | - _onStatusChanged(currentStatus); | 260 | + currentStatus = SnackbarStatus.CLOSED; |
| 261 | + _snackbarStatus(currentStatus); | ||
| 262 | 262 | ||
| 263 | if (!isCurrent) { | 263 | if (!isCurrent) { |
| 264 | navigator.finalizeRoute(this); | 264 | navigator.finalizeRoute(this); |
| 1 | name: get | 1 | name: get |
| 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. | 2 | description: Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with GetX. |
| 3 | -version: 3.7.0 | 3 | +version: 3.8.0 |
| 4 | homepage: https://github.com/jonataslaw/get | 4 | homepage: https://github.com/jonataslaw/get |
| 5 | 5 | ||
| 6 | environment: | 6 | environment: |
-
Please register or login to post a comment