Showing
3 changed files
with
15 additions
and
1 deletions
@@ -392,6 +392,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -392,6 +392,7 @@ extension ExtensionSnackbar on GetInterface { | ||
392 | Gradient? backgroundGradient, | 392 | Gradient? backgroundGradient, |
393 | TextButton? mainButton, | 393 | TextButton? mainButton, |
394 | OnTap? onTap, | 394 | OnTap? onTap, |
395 | + OnHover? onHover, | ||
395 | bool? isDismissible, | 396 | bool? isDismissible, |
396 | bool? showProgressIndicator, | 397 | bool? showProgressIndicator, |
397 | DismissDirection? dismissDirection, | 398 | DismissDirection? dismissDirection, |
@@ -445,6 +446,7 @@ extension ExtensionSnackbar on GetInterface { | @@ -445,6 +446,7 @@ extension ExtensionSnackbar on GetInterface { | ||
445 | backgroundGradient: backgroundGradient, | 446 | backgroundGradient: backgroundGradient, |
446 | mainButton: mainButton, | 447 | mainButton: mainButton, |
447 | onTap: onTap, | 448 | onTap: onTap, |
449 | + onHover: onHover, | ||
448 | isDismissible: isDismissible ?? true, | 450 | isDismissible: isDismissible ?? true, |
449 | dismissDirection: dismissDirection, | 451 | dismissDirection: dismissDirection, |
450 | showProgressIndicator: showProgressIndicator ?? false, | 452 | showProgressIndicator: showProgressIndicator ?? false, |
@@ -7,6 +7,7 @@ import '../../../get_core/get_core.dart'; | @@ -7,6 +7,7 @@ import '../../../get_core/get_core.dart'; | ||
7 | import '../../get_navigation.dart'; | 7 | import '../../get_navigation.dart'; |
8 | 8 | ||
9 | typedef OnTap = void Function(GetSnackBar snack); | 9 | typedef OnTap = void Function(GetSnackBar snack); |
10 | +typedef OnHover = void Function(GetSnackBar snack, SnackHoverState snackHoverState); | ||
10 | 11 | ||
11 | typedef SnackbarStatusCallback = void Function(SnackbarStatus? status); | 12 | typedef SnackbarStatusCallback = void Function(SnackbarStatus? status); |
12 | 13 | ||
@@ -150,6 +151,9 @@ class GetSnackBar extends StatefulWidget { | @@ -150,6 +151,9 @@ class GetSnackBar extends StatefulWidget { | ||
150 | /// An alternative to [mainButton] | 151 | /// An alternative to [mainButton] |
151 | final OnTap? onTap; | 152 | final OnTap? onTap; |
152 | 153 | ||
154 | + /// A callback that registers the user's hover anywhere over the Snackbar. | ||
155 | + final OnHover? onHover; | ||
156 | + | ||
153 | /// How long until Snack will hide itself (be dismissed). | 157 | /// How long until Snack will hide itself (be dismissed). |
154 | /// To make it indefinite, leave it null. | 158 | /// To make it indefinite, leave it null. |
155 | final Duration? duration; | 159 | final Duration? duration; |
@@ -259,6 +263,7 @@ class GetSnackBar extends StatefulWidget { | @@ -259,6 +263,7 @@ class GetSnackBar extends StatefulWidget { | ||
259 | this.backgroundGradient, | 263 | this.backgroundGradient, |
260 | this.mainButton, | 264 | this.mainButton, |
261 | this.onTap, | 265 | this.onTap, |
266 | + this.onHover, | ||
262 | this.duration, | 267 | this.duration, |
263 | this.isDismissible = true, | 268 | this.isDismissible = true, |
264 | this.dismissDirection, | 269 | this.dismissDirection, |
@@ -657,3 +662,6 @@ enum SnackPosition { top, bottom } | @@ -657,3 +662,6 @@ enum SnackPosition { top, bottom } | ||
657 | 662 | ||
658 | /// Indicates if snack will be attached to the edge of the screen or not | 663 | /// Indicates if snack will be attached to the edge of the screen or not |
659 | enum SnackStyle { floating, grounded } | 664 | enum SnackStyle { floating, grounded } |
665 | + | ||
666 | +/// Indicates if the mouse entered or exited | ||
667 | +enum SnackHoverState { entered, exited } |
@@ -238,11 +238,15 @@ class SnackbarController { | @@ -238,11 +238,15 @@ class SnackbarController { | ||
238 | 238 | ||
239 | Widget _getBodyWidget() { | 239 | Widget _getBodyWidget() { |
240 | return Builder(builder: (_) { | 240 | return Builder(builder: (_) { |
241 | - return GestureDetector( | 241 | + return MouseRegion( |
242 | + onEnter: (_) => snackbar.onHover?.call(snackbar, SnackHoverState.entered), | ||
243 | + onExit: (_) => snackbar.onHover?.call(snackbar, SnackHoverState.exited), | ||
244 | + child: GestureDetector( | ||
242 | child: snackbar, | 245 | child: snackbar, |
243 | onTap: snackbar.onTap != null | 246 | onTap: snackbar.onTap != null |
244 | ? () => snackbar.onTap?.call(snackbar) | 247 | ? () => snackbar.onTap?.call(snackbar) |
245 | : null, | 248 | : null, |
249 | + ), | ||
246 | ); | 250 | ); |
247 | }); | 251 | }); |
248 | } | 252 | } |
-
Please register or login to post a comment