Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds transitionDuration to the dialog service #38

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions example/lib/ui/views/dialog_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Offset>(
begin: const Offset(1.0, 0.0),
Expand All @@ -122,10 +126,13 @@ class DialogView extends StatelessWidget {
),
OutlinedButton(
onPressed: () async {
final response = await _dialogService.showCustomDialog<GenericDialogResponse, GenericDialogRequest>(
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,
Expand All @@ -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'),
);
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
22 changes: 16 additions & 6 deletions lib/src/dialog/dialog_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ class DialogService {
_dialogBuilders = {...?_dialogBuilders, ...builders};
}

Map<dynamic, DialogBuilder> _customDialogBuilders = Map<dynamic, DialogBuilder>();
Map<dynamic, DialogBuilder> _customDialogBuilders =
Map<dynamic, DialogBuilder>();

@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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -192,7 +198,10 @@ class DialogService {
RouteSettings? routeSettings,
GlobalKey<NavigatorState>? 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(
Expand All @@ -209,7 +218,8 @@ class DialogService {

return Get.generalDialog<DialogResponse<T>>(
barrierColor: barrierColor,
transitionDuration: const Duration(milliseconds: 200),
transitionDuration:
transitionDuration ?? const Duration(milliseconds: 200),
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel,
routeSettings: routeSettings,
Expand Down
Loading