From 4e2083de258d9ce4f6c29e7ccce9ed2f94c039dc Mon Sep 17 00:00:00 2001 From: Sailesh Dahal Date: Fri, 22 Mar 2024 12:07:34 +0545 Subject: [PATCH 1/3] feat: mutate bottom sheet and dialog builders --- lib/src/bottom_sheet/bottom_sheet_service.dart | 2 +- lib/src/dialog/dialog_service.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/bottom_sheet/bottom_sheet_service.dart b/lib/src/bottom_sheet/bottom_sheet_service.dart index 759bcc6..940cd13 100644 --- a/lib/src/bottom_sheet/bottom_sheet_service.dart +++ b/lib/src/bottom_sheet/bottom_sheet_service.dart @@ -20,7 +20,7 @@ class BottomSheetService { Map? _sheetBuilders; void setCustomSheetBuilders(Map builders) { - _sheetBuilders = builders; + _sheetBuilders = {...?_sheetBuilders, ...builders}; } Future showBottomSheet({ diff --git a/lib/src/dialog/dialog_service.dart b/lib/src/dialog/dialog_service.dart index 39bfb13..6e1cdbc 100644 --- a/lib/src/dialog/dialog_service.dart +++ b/lib/src/dialog/dialog_service.dart @@ -23,7 +23,7 @@ class DialogService { Map? _dialogBuilders; void registerCustomDialogBuilders(Map builders) { - _dialogBuilders = builders; + _dialogBuilders = {...?_dialogBuilders, ...builders}; } Map _customDialogBuilders = From 2d37fb6325b9f0409eb9dd200d733b9f1ddc71e5 Mon Sep 17 00:00:00 2001 From: Sailesh Dahal Date: Mon, 9 Dec 2024 15:54:40 +0545 Subject: [PATCH 2/3] feat: adds `transitionDuration` to the dialog service --- lib/src/dialog/dialog_service.dart | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/src/dialog/dialog_service.dart b/lib/src/dialog/dialog_service.dart index cb3a63e..c9f6953 100644 --- a/lib/src/dialog/dialog_service.dart +++ b/lib/src/dialog/dialog_service.dart @@ -26,9 +26,11 @@ class DialogService { _dialogBuilders = {...?_dialogBuilders, ...builders}; } - Map _customDialogBuilders = Map(); + Map _customDialogBuilders = + Map(); - @Deprecated('Prefer to use the StackedServices.navigatorKey instead of using this key. This will be removed in the next major version update for stacked.') + @Deprecated( + 'Prefer to use the StackedServices.navigatorKey instead of using this key. This will be removed in the next major version update for stacked.') get navigatorKey { return Get.key; } @@ -45,7 +47,9 @@ class DialogService { ) void registerCustomDialogBuilder({ required dynamic variant, - required Widget Function(BuildContext, DialogRequest, Function(DialogResponse)) builder, + required Widget Function( + BuildContext, DialogRequest, Function(DialogResponse)) + builder, }) { _customDialogBuilders[variant] = builder; } @@ -86,7 +90,9 @@ class DialogService { navigatorKey: navigatorKey, ); } else { - var _dialogType = GetPlatform.isAndroid ? DialogPlatform.Material : DialogPlatform.Cupertino; + var _dialogType = GetPlatform.isAndroid + ? DialogPlatform.Material + : DialogPlatform.Cupertino; return _showDialog( title: title, description: description, @@ -192,7 +198,10 @@ class DialogService { RouteSettings? routeSettings, GlobalKey? navigatorKey, RouteTransitionsBuilder? transitionBuilder, - @Deprecated('Prefer to use `data` and pass in a generic type. customData doesn\'t work anymore') dynamic customData, + Duration? transitionDuration, + @Deprecated( + 'Prefer to use `data` and pass in a generic type. customData doesn\'t work anymore') + dynamic customData, R? data, }) { assert( @@ -209,7 +218,8 @@ class DialogService { return Get.generalDialog>( barrierColor: barrierColor, - transitionDuration: const Duration(milliseconds: 200), + transitionDuration: + transitionDuration ?? const Duration(milliseconds: 200), barrierDismissible: barrierDismissible, barrierLabel: barrierLabel, routeSettings: routeSettings, From 0070af0bf1a6f5960ca2a0b6bd96f51ddbf1c7af Mon Sep 17 00:00:00 2001 From: Sailesh Dahal Date: Mon, 9 Dec 2024 17:52:19 +0545 Subject: [PATCH 3/3] fix lint --- example/lib/ui/views/dialog_view.dart | 28 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/example/lib/ui/views/dialog_view.dart b/example/lib/ui/views/dialog_view.dart index c89a6db..1c0d6eb 100644 --- a/example/lib/ui/views/dialog_view.dart +++ b/example/lib/ui/views/dialog_view.dart @@ -93,12 +93,16 @@ class DialogView extends StatelessWidget { await _dialogService.showCustomDialog( variant: DialogType.Basic, title: 'This is a custom UI with Text as main button', - description: 'Sheck out the builder in the dialog_ui_register.dart file', + description: + 'Sheck out the builder in the dialog_ui_register.dart file', mainButtonTitle: 'Ok', showIconInMainButton: false, barrierDismissible: true, - routeSettings: RouteSettings(name: '/customDialogWithTransition'), - transitionBuilder: (context, animation, secondaryAnimation, child) => SlideTransition( + routeSettings: + RouteSettings(name: '/customDialogWithTransition'), + transitionBuilder: + (context, animation, secondaryAnimation, child) => + SlideTransition( position: animation.drive( Tween( begin: const Offset(1.0, 0.0), @@ -122,10 +126,13 @@ class DialogView extends StatelessWidget { ), OutlinedButton( onPressed: () async { - final response = await _dialogService.showCustomDialog( + final response = await _dialogService.showCustomDialog< + GenericDialogResponse, GenericDialogRequest>( variant: DialogType.Generic, - title: 'This is a custom Generic UI with Text as main button', - description: 'Sheck out the builder in the dialog_ui_register.dart file', + title: + 'This is a custom Generic UI with Text as main button', + description: + 'Sheck out the builder in the dialog_ui_register.dart file', mainButtonTitle: 'Ok', showIconInMainButton: false, barrierDismissible: true, @@ -144,7 +151,8 @@ class DialogView extends StatelessWidget { await _dialogService.showCustomDialog( variant: DialogType.Basic, title: 'This is a custom UI with icon', - description: 'Sheck out the builder in the dialog_ui_register.dart file', + description: + 'Sheck out the builder in the dialog_ui_register.dart file', showIconInMainButton: true, routeSettings: RouteSettings(name: '/customDialog'), ); @@ -166,7 +174,8 @@ class DialogView extends StatelessWidget { title: 'Test Confirmation Dialog Title', description: 'Test Confirmation Dialog Description', barrierDismissible: true, - routeSettings: RouteSettings(name: '/materialConfirmationDialog'), + routeSettings: + RouteSettings(name: '/materialConfirmationDialog'), ); }, child: Text( @@ -210,7 +219,8 @@ class DialogView extends StatelessWidget { title: 'Test Confirmation Dialog Title', description: 'Test Confirmation Dialog Description', barrierDismissible: true, - routeSettings: RouteSettings(name: '/materialConfirmationDialog'), + routeSettings: + RouteSettings(name: '/materialConfirmationDialog'), ); }, child: Text(