From a3c0ceaf9d538168831acb5de2c9d3519913cbc3 Mon Sep 17 00:00:00 2001 From: christo pb Date: Thu, 29 Feb 2024 20:59:22 +0530 Subject: [PATCH 1/4] Added model class for params in Position widget --- lib/src/position_model.dart | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lib/src/position_model.dart diff --git a/lib/src/position_model.dart b/lib/src/position_model.dart new file mode 100644 index 0000000..d12e9fd --- /dev/null +++ b/lib/src/position_model.dart @@ -0,0 +1,17 @@ +class OverlayPosition { + final double? left; + final double? top; + final double? right; + final double? bottom; + final double? width; + final double? height; + + const OverlayPosition({ + this.left, + this.top, + this.right, + this.bottom, + this.width, + this.height, + }); +} From d7dacc8f25e170e6601aa9bf56e4e7ac228e4280 Mon Sep 17 00:00:00 2001 From: christo pb Date: Thu, 29 Feb 2024 21:09:35 +0530 Subject: [PATCH 2/4] Added Positioned widget so that the overlay wont take up the entire space, and the buttons near the toast are clickable --- lib/src/styled_toast.dart | 60 +++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/lib/src/styled_toast.dart b/lib/src/styled_toast.dart index c1f6340..92cd368 100644 --- a/lib/src/styled_toast.dart +++ b/lib/src/styled_toast.dart @@ -7,6 +7,7 @@ import 'custom_size_transition.dart'; import 'styled_toast_enum.dart'; import 'styled_toast_manage.dart'; import 'styled_toast_theme.dart'; +import 'position_model.dart'; /// Current context of the page which uses the toast. BuildContext? currentContext; @@ -164,6 +165,7 @@ ToastFuture showToastWidget( CustomAnimationBuilder? reverseAnimBuilder, bool? isIgnoring, OnInitStateCallback? onInitState, + OverlayPosition? overlayPosition, }) { OverlayEntry entry; ToastFuture future; @@ -227,31 +229,39 @@ ToastFuture showToastWidget( GlobalKey key = GlobalKey(); entry = OverlayEntry(builder: (ctx) { - return IgnorePointer( - ignoring: isIgnoring!, - child: _StyledToastWidget( - duration: duration!, - animDuration: animDuration!, - position: position, - animation: animation, - reverseAnimation: reverseAnimation, - alignment: alignment, - axis: axis, - startOffset: startOffset, - endOffset: endOffset, - reverseStartOffset: reverseStartOffset, - reverseEndOffset: reverseEndOffset, - curve: curve!, - reverseCurve: reverseCurve!, - key: key, - animationBuilder: animationBuilder, - reverseAnimBuilder: reverseAnimBuilder, - onInitState: onInitState, - child: Directionality( - textDirection: textDirection!, - child: Material( - child: widget, - color: Colors.transparent, + return Positioned( + top: overlayPosition?.top, + bottom: overlayPosition?.bottom, + left: overlayPosition?.left, + right: overlayPosition?.right, + height: overlayPosition?.height, + width: overlayPosition?.width, + child: IgnorePointer( + ignoring: isIgnoring!, + child: _StyledToastWidget( + duration: duration!, + animDuration: animDuration!, + position: position, + animation: animation, + reverseAnimation: reverseAnimation, + alignment: alignment, + axis: axis, + startOffset: startOffset, + endOffset: endOffset, + reverseStartOffset: reverseStartOffset, + reverseEndOffset: reverseEndOffset, + curve: curve!, + reverseCurve: reverseCurve!, + key: key, + animationBuilder: animationBuilder, + reverseAnimBuilder: reverseAnimBuilder, + onInitState: onInitState, + child: Directionality( + textDirection: textDirection!, + child: Material( + child: widget, + color: Colors.transparent, + ), ), ), ), From 144533e53cbe3b04a38e4982bdd5ba7b632bfcdc Mon Sep 17 00:00:00 2001 From: christo pb Date: Thu, 29 Feb 2024 21:10:17 +0530 Subject: [PATCH 3/4] exposed OverlayPosition model --- lib/flutter_styled_toast.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/flutter_styled_toast.dart b/lib/flutter_styled_toast.dart index 8c233e2..50f1f1f 100644 --- a/lib/flutter_styled_toast.dart +++ b/lib/flutter_styled_toast.dart @@ -6,3 +6,4 @@ export 'src/styled_toast_manage.dart'; export 'src/custom_size_transition.dart'; export 'src/custom_animation.dart'; export 'src/styled_toast_theme.dart'; +export 'src/position_model.dart'; From 01c184abfe1c37ce9b5ace0428e91f8d639776e0 Mon Sep 17 00:00:00 2001 From: christo pb Date: Sun, 14 Jul 2024 10:35:46 -0400 Subject: [PATCH 4/4] Update: fixed lints --- example/lib/custom_toast_content_widget.dart | 40 +++++--------------- 1 file changed, 9 insertions(+), 31 deletions(-) diff --git a/example/lib/custom_toast_content_widget.dart b/example/lib/custom_toast_content_widget.dart index 461aeaa..3cae6c8 100644 --- a/example/lib/custom_toast_content_widget.dart +++ b/example/lib/custom_toast_content_widget.dart @@ -27,7 +27,7 @@ class IconToastWidget extends StatelessWidget { this.message, this.height, this.width, - @required this.assetName, + required this.assetName, this.padding, }); @@ -47,8 +47,7 @@ class IconToastWidget extends StatelessWidget { color: Colors.transparent, child: Container( margin: EdgeInsets.symmetric(horizontal: 50.0), - padding: - padding ?? EdgeInsets.symmetric(vertical: 20.0, horizontal: 17.0), + padding: padding ?? EdgeInsets.symmetric(vertical: 20.0, horizontal: 17.0), decoration: ShapeDecoration( color: backgroundColor ?? const Color(0x9F000000), shape: RoundedRectangleBorder( @@ -73,10 +72,7 @@ class IconToastWidget extends StatelessWidget { child: textWidget ?? Text( message ?? '', - style: TextStyle( - fontSize: - Theme.of(context).textTheme.titleLarge!.fontSize, - color: Colors.white), + style: TextStyle(fontSize: Theme.of(context).textTheme.titleLarge!.fontSize, color: Colors.white), softWrap: true, maxLines: 200, ), @@ -89,14 +85,6 @@ class IconToastWidget extends StatelessWidget { } } -/// -///created time: 2019-06-17 16:22 -///author linzhiliang -///version 1.5.0 -///since -///file name: styled_toast.dart -///description: Banner type toast widget, example of custom toast content widget when you use [showToastWidget] -/// class BannerToastWidget extends StatelessWidget { final Color? backgroundColor; final String? message; @@ -115,22 +103,14 @@ class BannerToastWidget extends StatelessWidget { final double? offset, }) : this.offset = (offset == null ? 10.0 : offset); - factory BannerToastWidget.success( - {String? msg, Widget? text, BuildContext? context}) => - BannerToastWidget( - backgroundColor: context != null - ? Theme.of(context).toggleButtonsTheme.fillColor - : Colors.green, + factory BannerToastWidget.success({String? msg, Widget? text, BuildContext? context}) => BannerToastWidget( + backgroundColor: context != null ? Theme.of(context).toggleButtonsTheme.fillColor : Colors.green, message: msg, textWidget: text, ); - factory BannerToastWidget.fail( - {String? msg, Widget? text, BuildContext? context}) => - BannerToastWidget( - backgroundColor: context != null - ? Theme.of(context).colorScheme.error - : const Color(0xEFCC2E2E), + factory BannerToastWidget.fail({String? msg, Widget? text, BuildContext? context}) => BannerToastWidget( + backgroundColor: context != null ? Theme.of(context).colorScheme.error : const Color(0xEFCC2E2E), message: msg, textWidget: text, ); @@ -142,13 +122,11 @@ class BannerToastWidget extends StatelessWidget { padding: EdgeInsets.all(17.0), height: 60.0, alignment: Alignment.center, - color: backgroundColor ?? Theme.of(context).colorScheme.background, + color: backgroundColor ?? Theme.of(context).colorScheme.surface, child: textWidget ?? Text( message ?? '', - style: TextStyle( - fontSize: Theme.of(context).textTheme.titleLarge!.fontSize, - color: Colors.white), + style: TextStyle(fontSize: Theme.of(context).textTheme.titleLarge!.fontSize, color: Colors.white), ), );