From 172091602a0c1d3ccca329270bdebe10a6bbd2e1 Mon Sep 17 00:00:00 2001 From: 21pages Date: Thu, 29 Sep 2022 10:48:27 +0800 Subject: [PATCH] opt: adjust msgbox text width, passwordDialog support enter && esc Signed-off-by: 21pages --- flutter/lib/common.dart | 4 +++- flutter/lib/mobile/widgets/dialog.dart | 30 +++++++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/flutter/lib/common.dart b/flutter/lib/common.dart index 348973720..97b1a3596 100644 --- a/flutter/lib/common.dart +++ b/flutter/lib/common.dart @@ -642,7 +642,9 @@ void msgBox( } dialogManager.show((setState, close) => CustomAlertDialog( title: _msgBoxTitle(title), - content: Text(translate(text), style: const TextStyle(fontSize: 15)), + content: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 500), + child: Text(translate(text), style: const TextStyle(fontSize: 15))), actions: buttons, onSubmit: hasOk ? submit : null, onCancel: hasCancel == true ? cancel : null, diff --git a/flutter/lib/mobile/widgets/dialog.dart b/flutter/lib/mobile/widgets/dialog.dart index c17045236..455922e34 100644 --- a/flutter/lib/mobile/widgets/dialog.dart +++ b/flutter/lib/mobile/widgets/dialog.dart @@ -161,6 +161,20 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async { var remember = await bind.sessionGetRemember(id: id) ?? false; dialogManager.dismissAll(); dialogManager.show((setState, close) { + cancel() { + close(); + closeConnection(); + } + + submit() { + var text = controller.text.trim(); + if (text == '') return; + gFFI.login(id, text, remember); + close(); + dialogManager.showLoading(translate('Logging in...'), + onCancel: closeConnection); + } + return CustomAlertDialog( title: Text(translate('Password Required')), content: Column(mainAxisSize: MainAxisSize.min, children: [ @@ -183,25 +197,17 @@ void enterPasswordDialog(String id, OverlayDialogManager dialogManager) async { actions: [ TextButton( style: flatButtonStyle, - onPressed: () { - close(); - closeConnection(); - }, + onPressed: cancel, child: Text(translate('Cancel')), ), TextButton( style: flatButtonStyle, - onPressed: () { - var text = controller.text.trim(); - if (text == '') return; - gFFI.login(id, text, remember); - close(); - dialogManager.showLoading(translate('Logging in...'), - onCancel: closeConnection); - }, + onPressed: submit, child: Text(translate('OK')), ), ], + onSubmit: submit, + onCancel: cancel, ); }); }