dialog backDismiss

This commit is contained in:
csf 2022-04-21 10:02:47 +08:00
parent 8386e0f20e
commit 9f6254cc82
4 changed files with 13 additions and 22 deletions

View File

@ -96,6 +96,7 @@ class DialogManager {
static Future<T?> show<T>(DialogBuilder builder, static Future<T?> show<T>(DialogBuilder builder,
{bool clickMaskDismiss = false, {bool clickMaskDismiss = false,
bool backDismiss = false,
String? tag, String? tag,
bool useAnimation = true}) async { bool useAnimation = true}) async {
final t; final t;
@ -113,6 +114,7 @@ class DialogManager {
final res = await SmartDialog.show<T>( final res = await SmartDialog.show<T>(
tag: t, tag: t,
clickMaskDismiss: clickMaskDismiss, clickMaskDismiss: clickMaskDismiss,
backDismiss: backDismiss,
useAnimation: useAnimation, useAnimation: useAnimation,
builder: (_) => StatefulBuilder( builder: (_) => StatefulBuilder(
builder: (_, setState) => builder(setState, close))); builder: (_, setState) => builder(setState, close)));
@ -125,27 +127,23 @@ class CustomAlertDialog extends StatelessWidget {
{required this.title, {required this.title,
required this.content, required this.content,
required this.actions, required this.actions,
this.onWillPop,
this.contentPadding}); this.contentPadding});
final Widget title; final Widget title;
final Widget content; final Widget content;
final List<Widget> actions; final List<Widget> actions;
final WillPopCallback? onWillPop;
final double? contentPadding; final double? contentPadding;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return WillPopScope( return AlertDialog(
onWillPop: onWillPop ?? () async => false, scrollable: true,
child: AlertDialog( title: title,
scrollable: true, contentPadding:
title: title, EdgeInsets.symmetric(horizontal: contentPadding ?? 25, vertical: 10),
contentPadding: EdgeInsets.symmetric( content: content,
horizontal: contentPadding ?? 25, vertical: 10), actions: actions,
content: content, );
actions: actions,
));
} }
} }

View File

@ -877,10 +877,9 @@ void showOptions() {
] + ] +
more), more),
actions: [], actions: [],
onWillPop: () async => true,
contentPadding: 0, contentPadding: 0,
); );
}, clickMaskDismiss: true); }, clickMaskDismiss: true, backDismiss: true);
} }
void showSetOSPassword(bool login) { void showSetOSPassword(bool login) {

View File

@ -244,11 +244,8 @@ void showServerSettingsWithValue(
child: Text(translate('OK')), child: Text(translate('OK')),
), ),
], ],
onWillPop: () async {
return true;
},
); );
}, clickMaskDismiss: true); });
} }
String? validate(value) { String? validate(value) {

View File

@ -118,11 +118,8 @@ void showAbout() {
)), )),
]), ]),
actions: [], actions: [],
onWillPop: () async {
return true;
},
); );
}, clickMaskDismiss: true); }, clickMaskDismiss: true, backDismiss: true);
} }
Future<String> login(String name, String pass) async { Future<String> login(String name, String pass) async {