diff --git a/flutter/lib/common/widgets/address_book.dart b/flutter/lib/common/widgets/address_book.dart index ca5e85f56..9fac81723 100644 --- a/flutter/lib/common/widgets/address_book.dart +++ b/flutter/lib/common/widgets/address_book.dart @@ -7,6 +7,7 @@ import 'package:provider/provider.dart'; import '../../common.dart'; import '../../desktop/pages/desktop_home_page.dart'; +import '../../mobile/pages/settings_page.dart'; import '../../models/platform_model.dart'; class AddressBook extends StatefulWidget { @@ -37,11 +38,16 @@ class _AddressBookState extends State { }); handleLogin() { - loginDialog().then((success) { - if (success) { - setState(() {}); - } - }); + // TODO refactor login dialog for desktop and mobile + if (isDesktop) { + loginDialog().then((success) { + if (success) { + setState(() {}); + } + }); + } else { + showLogin(gFFI.dialogManager); + } } Future buildAddressBook(BuildContext context) async { diff --git a/flutter/lib/common/widgets/peer_card.dart b/flutter/lib/common/widgets/peer_card.dart index 7eae2aa5f..9c0c997bc 100644 --- a/flutter/lib/common/widgets/peer_card.dart +++ b/flutter/lib/common/widgets/peer_card.dart @@ -590,8 +590,6 @@ abstract class BasePeerCard extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( - padding: - const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), child: Form( child: TextFormField( controller: controller, diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index edae7deeb..833a914cd 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -331,7 +331,7 @@ Future loginDialog() async { var userNameMsg = ""; String pass = ""; var passMsg = ""; - var userContontroller = TextEditingController(text: userName); + var userController = TextEditingController(text: userName); var pwdController = TextEditingController(text: pass); var isInProgress = false; @@ -349,7 +349,7 @@ Future loginDialog() async { }); } - userName = userContontroller.text; + userName = userController.text; pass = pwdController.text; if (userName.isEmpty) { userNameMsg = translate("Username missed"); @@ -385,6 +385,7 @@ Future loginDialog() async { close(); } + // 登录dialog return CustomAlertDialog( title: Text(translate("Login")), content: ConstrainedBox( @@ -411,7 +412,7 @@ Future loginDialog() async { decoration: InputDecoration( border: const OutlineInputBorder(), errorText: userNameMsg.isNotEmpty ? userNameMsg : null), - controller: userContontroller, + controller: userController, focusNode: FocusNode()..requestFocus(), ), ), diff --git a/flutter/lib/desktop/pages/desktop_setting_page.dart b/flutter/lib/desktop/pages/desktop_setting_page.dart index 60bc96b47..0918fc59b 100644 --- a/flutter/lib/desktop/pages/desktop_setting_page.dart +++ b/flutter/lib/desktop/pages/desktop_setting_page.dart @@ -48,7 +48,7 @@ class _DesktopSettingPageState extends State _TabInfo('Security', Icons.enhanced_encryption_outlined, Icons.enhanced_encryption), _TabInfo('Network', Icons.link_outlined, Icons.link), - _TabInfo('Acount', Icons.person_outline, Icons.person), + _TabInfo('Account', Icons.person_outline, Icons.person), _TabInfo('About', Icons.info_outline, Icons.info) ]; @@ -92,7 +92,7 @@ class _DesktopSettingPageState extends State _General(), _Safety(), _Network(), - _Acount(), + _Account(), _About(), ], )), @@ -641,14 +641,14 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin { } } -class _Acount extends StatefulWidget { - const _Acount({Key? key}) : super(key: key); +class _Account extends StatefulWidget { + const _Account({Key? key}) : super(key: key); @override - State<_Acount> createState() => _AcountState(); + State<_Account> createState() => _AccountState(); } -class _AcountState extends State<_Acount> { +class _AccountState extends State<_Account> { @override Widget build(BuildContext context) { final scrollController = ScrollController(); @@ -658,12 +658,12 @@ class _AcountState extends State<_Acount> { physics: NeverScrollableScrollPhysics(), controller: scrollController, children: [ - _Card(title: 'Acount', children: [login()]), + _Card(title: 'Account', children: [accountAction()]), ], ).marginOnly(bottom: _kListViewBottomMargin)); } - Widget login() { + Widget accountAction() { return _futureBuilder(future: () async { return await gFFI.userModel.getUserName(); }(), hasData: (data) { @@ -671,12 +671,14 @@ class _AcountState extends State<_Acount> { return _Button( username.isEmpty ? 'Login' : 'Logout', () => { - loginDialog().then((success) { - if (success) { - // refresh frame - setState(() {}); - } - }) + username.isEmpty + ? loginDialog().then((success) { + if (success) { + // refresh frame + setState(() {}); + } + }) + : gFFI.userModel.logOut() }); }); } diff --git a/flutter/lib/mobile/pages/settings_page.dart b/flutter/lib/mobile/pages/settings_page.dart index 93120427a..985fe2df0 100644 --- a/flutter/lib/mobile/pages/settings_page.dart +++ b/flutter/lib/mobile/pages/settings_page.dart @@ -451,7 +451,7 @@ void showLogin(OverlayDialogManager dialogManager) { ), controller: nameController, ), - PasswordWidget(controller: passwordController), + PasswordWidget(controller: passwordController, autoFocus: false), ]), actions: (loading ? [CircularProgressIndicator()] diff --git a/flutter/lib/mobile/widgets/dialog.dart b/flutter/lib/mobile/widgets/dialog.dart index 503b82c50..c17045236 100644 --- a/flutter/lib/mobile/widgets/dialog.dart +++ b/flutter/lib/mobile/widgets/dialog.dart @@ -6,8 +6,7 @@ import '../../models/model.dart'; import '../../models/platform_model.dart'; void clientClose(OverlayDialogManager dialogManager) { - msgBox('', 'Close', 'Are you sure to close the connection?', - dialogManager); + msgBox('', 'Close', 'Are you sure to close the connection?', dialogManager); } void showSuccess() { @@ -131,7 +130,7 @@ void setTemporaryPasswordLengthDialog( if (index < 0) index = 0; length = lengths[index]; dialogManager.show((setState, close) { - final setLength = (newValue) { + setLength(newValue) { final oldValue = length; if (oldValue == newValue) return; setState(() { @@ -143,7 +142,8 @@ void setTemporaryPasswordLengthDialog( close(); showSuccess(); }); - }; + } + return CustomAlertDialog( title: Text(translate("Set temporary password length")), content: Column( @@ -230,12 +230,14 @@ void wrongPasswordDialog(String id, OverlayDialogManager dialogManager) { } class PasswordWidget extends StatefulWidget { - PasswordWidget({Key? key, required this.controller}) : super(key: key); + PasswordWidget({Key? key, required this.controller, this.autoFocus = true}) + : super(key: key); final TextEditingController controller; + final bool autoFocus; @override - _PasswordWidgetState createState() => _PasswordWidgetState(); + State createState() => _PasswordWidgetState(); } class _PasswordWidgetState extends State { @@ -245,7 +247,9 @@ class _PasswordWidgetState extends State { @override void initState() { super.initState(); - Timer(Duration(milliseconds: 50), () => _focusNode.requestFocus()); + if (widget.autoFocus) { + Timer(Duration(milliseconds: 50), () => _focusNode.requestFocus()); + } } @override diff --git a/src/lang/cn.rs b/src/lang/cn.rs index 664d6f05b..47f3c0870 100644 --- a/src/lang/cn.rs +++ b/src/lang/cn.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "适应窗口"), ("General", "常规"), ("Security", "安全"), - ("Acount", "账户"), + ("Account", "账户"), ("Theme", "主题"), ("Dark Theme", "暗黑主题"), ("Enable hardware codec", "使用硬件编解码"), diff --git a/src/lang/cs.rs b/src/lang/cs.rs index ace56788f..9d203f9ce 100644 --- a/src/lang/cs.rs +++ b/src/lang/cs.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Měřítko adaptivní"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/da.rs b/src/lang/da.rs index 27724f7b3..a07539719 100644 --- a/src/lang/da.rs +++ b/src/lang/da.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Skala adaptiv"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/de.rs b/src/lang/de.rs index 8d90be381..fa589a564 100644 --- a/src/lang/de.rs +++ b/src/lang/de.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Adaptiv skalieren"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/eo.rs b/src/lang/eo.rs index 6c7bb5aa8..cc28525e5 100644 --- a/src/lang/eo.rs +++ b/src/lang/eo.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Skalo adapta"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/es.rs b/src/lang/es.rs index c8296ced5..9704a3f84 100644 --- a/src/lang/es.rs +++ b/src/lang/es.rs @@ -337,7 +337,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Adaptable a escala"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/fr.rs b/src/lang/fr.rs index d9a42e934..8276a54f2 100644 --- a/src/lang/fr.rs +++ b/src/lang/fr.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Échelle adaptative"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/hu.rs b/src/lang/hu.rs index b35224c03..e322053ac 100644 --- a/src/lang/hu.rs +++ b/src/lang/hu.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Skála adaptív"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/id.rs b/src/lang/id.rs index 657014141..a285e15de 100644 --- a/src/lang/id.rs +++ b/src/lang/id.rs @@ -337,7 +337,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Skala adaptif"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/it.rs b/src/lang/it.rs index 8f6dfb3d9..917d5e9b2 100644 --- a/src/lang/it.rs +++ b/src/lang/it.rs @@ -323,7 +323,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Translate mode", ""), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/ja.rs b/src/lang/ja.rs index 6d0a2a2f7..446bbc944 100644 --- a/src/lang/ja.rs +++ b/src/lang/ja.rs @@ -321,7 +321,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "フィットウィンドウ"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/ko.rs b/src/lang/ko.rs index ca939e2b8..cb223f77d 100644 --- a/src/lang/ko.rs +++ b/src/lang/ko.rs @@ -318,7 +318,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "맞는 창"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/pl.rs b/src/lang/pl.rs index fe45ddf3e..e6696fed5 100644 --- a/src/lang/pl.rs +++ b/src/lang/pl.rs @@ -322,7 +322,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Skala adaptacyjna"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/pt_PT.rs b/src/lang/pt_PT.rs index 858afd8a1..783d93635 100644 --- a/src/lang/pt_PT.rs +++ b/src/lang/pt_PT.rs @@ -318,7 +318,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Escala adaptável"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/ptbr.rs b/src/lang/ptbr.rs index af4f0b52e..ac1688d13 100644 --- a/src/lang/ptbr.rs +++ b/src/lang/ptbr.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", ""), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/ru.rs b/src/lang/ru.rs index 04cfed485..a005dc6ad 100644 --- a/src/lang/ru.rs +++ b/src/lang/ru.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Масштаб адаптивный"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/sk.rs b/src/lang/sk.rs index 8ae17b1ad..837e491ce 100644 --- a/src/lang/sk.rs +++ b/src/lang/sk.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Prispôsobivá mierka"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/template.rs b/src/lang/template.rs index 914b103df..5c68cef37 100644 --- a/src/lang/template.rs +++ b/src/lang/template.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", ""), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/tr.rs b/src/lang/tr.rs index b1b029b39..a0cd3ed8d 100644 --- a/src/lang/tr.rs +++ b/src/lang/tr.rs @@ -337,7 +337,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Ölçek uyarlanabilir"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""), diff --git a/src/lang/tw.rs b/src/lang/tw.rs index 764f666e7..c3c0849f0 100644 --- a/src/lang/tw.rs +++ b/src/lang/tw.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "適應窗口"), ("General", "常規"), ("Security", "安全"), - ("Acount", "賬戶"), + ("Account", "賬戶"), ("Theme", "主題"), ("Dark Theme", "暗黑主題"), ("Enable hardware codec", "使用硬件編解碼"), diff --git a/src/lang/vn.rs b/src/lang/vn.rs index f177581f9..88aa79dbf 100644 --- a/src/lang/vn.rs +++ b/src/lang/vn.rs @@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> = ("Scale adaptive", "Quy mô thích ứng"), ("General", ""), ("Security", ""), - ("Acount", ""), + ("Account", ""), ("Theme", ""), ("Dark Theme", ""), ("Enable hardware codec", ""),