|
@@ -53,6 +53,40 @@ Future<ButtonAction?> showGenericErrorDialog({
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+DialogWidget choiceDialog({
|
|
|
+ required String title,
|
|
|
+ String? body,
|
|
|
+ required String firstButtonLabel,
|
|
|
+ String secondButtonLabel = "Cancel",
|
|
|
+ ButtonType firstButtonType = ButtonType.neutral,
|
|
|
+ ButtonType secondButtonType = ButtonType.secondary,
|
|
|
+ ButtonAction firstButtonAction = ButtonAction.first,
|
|
|
+ ButtonAction secondButtonAction = ButtonAction.cancel,
|
|
|
+ FutureVoidCallback? firstButtonOnTap,
|
|
|
+ FutureVoidCallback? secondButtonOnTap,
|
|
|
+ bool isCritical = false,
|
|
|
+ IconData? icon,
|
|
|
+}) {
|
|
|
+ final buttons = [
|
|
|
+ ButtonWidget(
|
|
|
+ buttonType: isCritical ? ButtonType.critical : firstButtonType,
|
|
|
+ labelText: firstButtonLabel,
|
|
|
+ isInAlert: true,
|
|
|
+ onTap: firstButtonOnTap,
|
|
|
+ buttonAction: firstButtonAction,
|
|
|
+ ),
|
|
|
+ ButtonWidget(
|
|
|
+ buttonType: secondButtonType,
|
|
|
+ labelText: secondButtonLabel,
|
|
|
+ isInAlert: true,
|
|
|
+ onTap: secondButtonOnTap,
|
|
|
+ buttonAction: secondButtonAction,
|
|
|
+ ),
|
|
|
+ ];
|
|
|
+
|
|
|
+ return DialogWidget(title: title, body: body, buttons: buttons, icon: icon);
|
|
|
+}
|
|
|
+
|
|
|
///Will return null if dismissed by tapping outside
|
|
|
Future<ButtonAction?> showNewChoiceDialog({
|
|
|
required BuildContext context,
|
|
@@ -120,7 +154,6 @@ Future<ButtonAction?> showDialogWidget({
|
|
|
title: title,
|
|
|
body: body,
|
|
|
buttons: buttons,
|
|
|
- isMobileSmall: isMobileSmall,
|
|
|
icon: icon,
|
|
|
),
|
|
|
),
|
|
@@ -134,12 +167,10 @@ class DialogWidget extends StatelessWidget {
|
|
|
final String? body;
|
|
|
final List<ButtonWidget> buttons;
|
|
|
final IconData? icon;
|
|
|
- final bool isMobileSmall;
|
|
|
const DialogWidget({
|
|
|
required this.title,
|
|
|
this.body,
|
|
|
required this.buttons,
|
|
|
- required this.isMobileSmall,
|
|
|
this.icon,
|
|
|
super.key,
|
|
|
});
|
|
@@ -147,6 +178,7 @@ class DialogWidget extends StatelessWidget {
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
final widthOfScreen = MediaQuery.of(context).size.width;
|
|
|
+ final isMobileSmall = widthOfScreen <= mobileSmallThreshold;
|
|
|
final colorScheme = getEnteColorScheme(context);
|
|
|
return Container(
|
|
|
width: min(widthOfScreen, 320),
|