From 30d82ed4b09b2bd8ba5a77b73fa7f52acb1b379e Mon Sep 17 00:00:00 2001 From: Juvenal Guzman Date: Thu, 12 Mar 2020 18:10:40 -0600 Subject: [PATCH 1/6] close #31 expose ToastThemeData for toastTheme in OverlaySupport --- lib/overlay_support.dart | 1 + pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/overlay_support.dart b/lib/overlay_support.dart index 715b7b8..f336c2f 100644 --- a/lib/overlay_support.dart +++ b/lib/overlay_support.dart @@ -4,6 +4,7 @@ export 'src/notification/overlay_notification.dart'; export 'src/notification/notification.dart'; export 'src/overlay.dart'; export 'src/toast/toast.dart'; +export 'src/theme.dart'; ///The length of time the notification is fully displayed Duration kNotificationDuration = const Duration(milliseconds: 2000); diff --git a/pubspec.yaml b/pubspec.yaml index ec6f52f..8562dc4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: overlay_support description: proivder support for overlay, easy to build toast and internal notification -version: 1.0.2 +version: 1.0.3 author: YangBin homepage: https://github.com/boyan01/overlay_support From b2bc784f1cbf9fd76463ffb507a9c794aa479742 Mon Sep 17 00:00:00 2001 From: boyan Date: Fri, 13 Mar 2020 10:30:37 +0800 Subject: [PATCH 2/6] add changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82af44c..886b53b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.0.3] - 20202/3/13 +* expose toastTheme. by [juvs](https://github.com/juvs) + ## [1.0.2] - 2019/10/23 * fix Toast hidden behind ime #20 From 34e53a6f4008edd41f4a9635c707785e2df3ab0c Mon Sep 17 00:00:00 2001 From: Giles Correia Morton Date: Fri, 22 May 2020 11:20:33 +0100 Subject: [PATCH 3/6] Mimic SnackBar --- lib/src/notification/notification.dart | 17 +++++++++++++++++ lib/src/notification/overlay_notification.dart | 13 ++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/src/notification/notification.dart b/lib/src/notification/notification.dart index 4953530..0a70285 100644 --- a/lib/src/notification/notification.dart +++ b/lib/src/notification/notification.dart @@ -20,6 +20,23 @@ class TopSlideNotification extends StatelessWidget { } } +class BottomSlideNotification extends StatelessWidget { + ///build notification content + final WidgetBuilder builder; + + final double progress; + + const BottomSlideNotification({Key key, @required this.builder, this.progress}) : super(key: key); + + @override + Widget build(BuildContext context) { + return FractionalTranslation( + translation: Offset.lerp(const Offset(0, 1), const Offset(0, 0), progress), + child: builder(context), + ); + } +} + ///can be dismiss by left or right slide class SlideDismissible extends StatelessWidget { final Widget child; diff --git a/lib/src/notification/overlay_notification.dart b/lib/src/notification/overlay_notification.dart index 2f1c448..31877ab 100644 --- a/lib/src/notification/overlay_notification.dart +++ b/lib/src/notification/overlay_notification.dart @@ -13,14 +13,20 @@ OverlaySupportEntry showOverlayNotification( WidgetBuilder builder, { Duration duration, Key key, + bool showAtBottom = false, }) { if (duration == null) { duration = kNotificationDuration; } return showOverlay((context, t) { + MainAxisAlignment alignment = MainAxisAlignment.start; + if (showAtBottom) alignment = MainAxisAlignment.end; return Column( + mainAxisAlignment: alignment, children: [ - TopSlideNotification(builder: builder, progress: t), + !showAtBottom + ? TopSlideNotification(builder: builder, progress: t) + : BottomSlideNotification(builder: builder, progress: t) ], ); }, duration: duration, key: key); @@ -53,7 +59,8 @@ OverlaySupportEntry showSimpleNotification(Widget content, double elevation = 16, Key key, bool autoDismiss = true, - bool slideDismiss = false}) { + bool slideDismiss = false, + bool isSnackBar = false}) { final entry = showOverlayNotification((context) { return SlideDismissible( enable: slideDismiss, @@ -76,6 +83,6 @@ OverlaySupportEntry showSimpleNotification(Widget content, )), ), ); - }, duration: autoDismiss ? null : Duration.zero, key: key); + }, duration: autoDismiss ? null : Duration.zero, key: key, showAtBottom: isSnackBar); return entry; } From 9df97525ced7c7f2c202d828eabba865b86fae60 Mon Sep 17 00:00:00 2001 From: Giles Correia Morton Date: Fri, 22 May 2020 20:53:29 +0100 Subject: [PATCH 4/6] Added simple comments --- lib/src/notification/notification.dart | 1 + lib/src/notification/overlay_notification.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/src/notification/notification.dart b/lib/src/notification/notification.dart index 0a70285..20b948b 100644 --- a/lib/src/notification/notification.dart +++ b/lib/src/notification/notification.dart @@ -20,6 +20,7 @@ class TopSlideNotification extends StatelessWidget { } } +/// a notification show in front of screen and shown at the bottom class BottomSlideNotification extends StatelessWidget { ///build notification content final WidgetBuilder builder; diff --git a/lib/src/notification/overlay_notification.dart b/lib/src/notification/overlay_notification.dart index 31877ab..4578844 100644 --- a/lib/src/notification/overlay_notification.dart +++ b/lib/src/notification/overlay_notification.dart @@ -48,6 +48,7 @@ OverlaySupportEntry showOverlayNotification( /// [elevation] the elevation of notification, see more [Material.elevation] /// [autoDismiss] true to auto hide after duration [kNotificationDuration] /// [slideDismiss] support left/right to dismiss notification +/// [isSnackBar] support for SnackBar style notification, which displays at bottom of screen /// OverlaySupportEntry showSimpleNotification(Widget content, {Widget leading, From a75204e604da87bc0de2d660062a47b892ac6cb9 Mon Sep 17 00:00:00 2001 From: Giles Correia Morton Date: Sat, 23 May 2020 12:37:08 +0100 Subject: [PATCH 5/6] Additionally comment for new variable --- lib/src/notification/overlay_notification.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/src/notification/overlay_notification.dart b/lib/src/notification/overlay_notification.dart index 4578844..fb8b420 100644 --- a/lib/src/notification/overlay_notification.dart +++ b/lib/src/notification/overlay_notification.dart @@ -9,6 +9,8 @@ import 'package:overlay_support/src/overlay.dart'; ///if null , will be set to [kNotificationDuration] ///if zero , will not auto dismiss in the future /// +/// [showAtBottom] show notification at the bottom of screen like a SnackBar +/// OverlaySupportEntry showOverlayNotification( WidgetBuilder builder, { Duration duration, From d36cb77f154f0c43a3f14c6a5b67c7182a6786c5 Mon Sep 17 00:00:00 2001 From: Giles Correia Morton Date: Sat, 23 May 2020 14:15:32 +0100 Subject: [PATCH 6/6] Align BottomSlideNotification with new TopSlideNotification --- lib/src/notification/notification.dart | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/src/notification/notification.dart b/lib/src/notification/notification.dart index 79be62e..7678fb9 100644 --- a/lib/src/notification/notification.dart +++ b/lib/src/notification/notification.dart @@ -27,14 +27,16 @@ class BottomSlideNotification extends StatelessWidget { ///build notification content final WidgetBuilder builder; - final double progress; + final Animation animation; - const BottomSlideNotification({Key key, @required this.builder, this.progress}) : super(key: key); + const BottomSlideNotification({Key key, @required this.builder, this.animation}) : super(key: key); @override Widget build(BuildContext context) { - return FractionalTranslation( - translation: Offset.lerp(const Offset(0, 1), const Offset(0, 0), progress), + return SlideTransition( + position: Tween(begin: const Offset(0, 1), end: const Offset(0, 0)) + .chain(CurveTween(curve: Curves.ease)) + .animate(animation), child: builder(context), ); }