1. mobile ab login.

2. typos
3. del rename dialog body padding
This commit is contained in:
csf 2022-09-22 17:38:18 +08:00
parent 00077676f4
commit 51b02353c9
27 changed files with 64 additions and 53 deletions

View File

@ -7,6 +7,7 @@ import 'package:provider/provider.dart';
import '../../common.dart'; import '../../common.dart';
import '../../desktop/pages/desktop_home_page.dart'; import '../../desktop/pages/desktop_home_page.dart';
import '../../mobile/pages/settings_page.dart';
import '../../models/platform_model.dart'; import '../../models/platform_model.dart';
class AddressBook extends StatefulWidget { class AddressBook extends StatefulWidget {
@ -37,11 +38,16 @@ class _AddressBookState extends State<AddressBook> {
}); });
handleLogin() { handleLogin() {
loginDialog().then((success) { // TODO refactor login dialog for desktop and mobile
if (success) { if (isDesktop) {
setState(() {}); loginDialog().then((success) {
} if (success) {
}); setState(() {});
}
});
} else {
showLogin(gFFI.dialogManager);
}
} }
Future<Widget> buildAddressBook(BuildContext context) async { Future<Widget> buildAddressBook(BuildContext context) async {

View File

@ -590,8 +590,6 @@ abstract class BasePeerCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Container( Container(
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Form( child: Form(
child: TextFormField( child: TextFormField(
controller: controller, controller: controller,

View File

@ -331,7 +331,7 @@ Future<bool> loginDialog() async {
var userNameMsg = ""; var userNameMsg = "";
String pass = ""; String pass = "";
var passMsg = ""; var passMsg = "";
var userContontroller = TextEditingController(text: userName); var userController = TextEditingController(text: userName);
var pwdController = TextEditingController(text: pass); var pwdController = TextEditingController(text: pass);
var isInProgress = false; var isInProgress = false;
@ -349,7 +349,7 @@ Future<bool> loginDialog() async {
}); });
} }
userName = userContontroller.text; userName = userController.text;
pass = pwdController.text; pass = pwdController.text;
if (userName.isEmpty) { if (userName.isEmpty) {
userNameMsg = translate("Username missed"); userNameMsg = translate("Username missed");
@ -385,6 +385,7 @@ Future<bool> loginDialog() async {
close(); close();
} }
// dialog
return CustomAlertDialog( return CustomAlertDialog(
title: Text(translate("Login")), title: Text(translate("Login")),
content: ConstrainedBox( content: ConstrainedBox(
@ -411,7 +412,7 @@ Future<bool> loginDialog() async {
decoration: InputDecoration( decoration: InputDecoration(
border: const OutlineInputBorder(), border: const OutlineInputBorder(),
errorText: userNameMsg.isNotEmpty ? userNameMsg : null), errorText: userNameMsg.isNotEmpty ? userNameMsg : null),
controller: userContontroller, controller: userController,
focusNode: FocusNode()..requestFocus(), focusNode: FocusNode()..requestFocus(),
), ),
), ),

View File

@ -48,7 +48,7 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
_TabInfo('Security', Icons.enhanced_encryption_outlined, _TabInfo('Security', Icons.enhanced_encryption_outlined,
Icons.enhanced_encryption), Icons.enhanced_encryption),
_TabInfo('Network', Icons.link_outlined, Icons.link), _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) _TabInfo('About', Icons.info_outline, Icons.info)
]; ];
@ -92,7 +92,7 @@ class _DesktopSettingPageState extends State<DesktopSettingPage>
_General(), _General(),
_Safety(), _Safety(),
_Network(), _Network(),
_Acount(), _Account(),
_About(), _About(),
], ],
)), )),
@ -641,14 +641,14 @@ class _NetworkState extends State<_Network> with AutomaticKeepAliveClientMixin {
} }
} }
class _Acount extends StatefulWidget { class _Account extends StatefulWidget {
const _Acount({Key? key}) : super(key: key); const _Account({Key? key}) : super(key: key);
@override @override
State<_Acount> createState() => _AcountState(); State<_Account> createState() => _AccountState();
} }
class _AcountState extends State<_Acount> { class _AccountState extends State<_Account> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final scrollController = ScrollController(); final scrollController = ScrollController();
@ -658,12 +658,12 @@ class _AcountState extends State<_Acount> {
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
controller: scrollController, controller: scrollController,
children: [ children: [
_Card(title: 'Acount', children: [login()]), _Card(title: 'Account', children: [accountAction()]),
], ],
).marginOnly(bottom: _kListViewBottomMargin)); ).marginOnly(bottom: _kListViewBottomMargin));
} }
Widget login() { Widget accountAction() {
return _futureBuilder(future: () async { return _futureBuilder(future: () async {
return await gFFI.userModel.getUserName(); return await gFFI.userModel.getUserName();
}(), hasData: (data) { }(), hasData: (data) {
@ -671,12 +671,14 @@ class _AcountState extends State<_Acount> {
return _Button( return _Button(
username.isEmpty ? 'Login' : 'Logout', username.isEmpty ? 'Login' : 'Logout',
() => { () => {
loginDialog().then((success) { username.isEmpty
if (success) { ? loginDialog().then((success) {
// refresh frame if (success) {
setState(() {}); // refresh frame
} setState(() {});
}) }
})
: gFFI.userModel.logOut()
}); });
}); });
} }

View File

@ -451,7 +451,7 @@ void showLogin(OverlayDialogManager dialogManager) {
), ),
controller: nameController, controller: nameController,
), ),
PasswordWidget(controller: passwordController), PasswordWidget(controller: passwordController, autoFocus: false),
]), ]),
actions: (loading actions: (loading
? <Widget>[CircularProgressIndicator()] ? <Widget>[CircularProgressIndicator()]

View File

@ -6,8 +6,7 @@ import '../../models/model.dart';
import '../../models/platform_model.dart'; import '../../models/platform_model.dart';
void clientClose(OverlayDialogManager dialogManager) { void clientClose(OverlayDialogManager dialogManager) {
msgBox('', 'Close', 'Are you sure to close the connection?', msgBox('', 'Close', 'Are you sure to close the connection?', dialogManager);
dialogManager);
} }
void showSuccess() { void showSuccess() {
@ -131,7 +130,7 @@ void setTemporaryPasswordLengthDialog(
if (index < 0) index = 0; if (index < 0) index = 0;
length = lengths[index]; length = lengths[index];
dialogManager.show((setState, close) { dialogManager.show((setState, close) {
final setLength = (newValue) { setLength(newValue) {
final oldValue = length; final oldValue = length;
if (oldValue == newValue) return; if (oldValue == newValue) return;
setState(() { setState(() {
@ -143,7 +142,8 @@ void setTemporaryPasswordLengthDialog(
close(); close();
showSuccess(); showSuccess();
}); });
}; }
return CustomAlertDialog( return CustomAlertDialog(
title: Text(translate("Set temporary password length")), title: Text(translate("Set temporary password length")),
content: Column( content: Column(
@ -230,12 +230,14 @@ void wrongPasswordDialog(String id, OverlayDialogManager dialogManager) {
} }
class PasswordWidget extends StatefulWidget { 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 TextEditingController controller;
final bool autoFocus;
@override @override
_PasswordWidgetState createState() => _PasswordWidgetState(); State<PasswordWidget> createState() => _PasswordWidgetState();
} }
class _PasswordWidgetState extends State<PasswordWidget> { class _PasswordWidgetState extends State<PasswordWidget> {
@ -245,7 +247,9 @@ class _PasswordWidgetState extends State<PasswordWidget> {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
Timer(Duration(milliseconds: 50), () => _focusNode.requestFocus()); if (widget.autoFocus) {
Timer(Duration(milliseconds: 50), () => _focusNode.requestFocus());
}
} }
@override @override

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "适应窗口"), ("Scale adaptive", "适应窗口"),
("General", "常规"), ("General", "常规"),
("Security", "安全"), ("Security", "安全"),
("Acount", "账户"), ("Account", "账户"),
("Theme", "主题"), ("Theme", "主题"),
("Dark Theme", "暗黑主题"), ("Dark Theme", "暗黑主题"),
("Enable hardware codec", "使用硬件编解码"), ("Enable hardware codec", "使用硬件编解码"),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Měřítko adaptivní"), ("Scale adaptive", "Měřítko adaptivní"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Skala adaptiv"), ("Scale adaptive", "Skala adaptiv"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Adaptiv skalieren"), ("Scale adaptive", "Adaptiv skalieren"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Skalo adapta"), ("Scale adaptive", "Skalo adapta"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -337,7 +337,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Adaptable a escala"), ("Scale adaptive", "Adaptable a escala"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Échelle adaptative"), ("Scale adaptive", "Échelle adaptative"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Skála adaptív"), ("Scale adaptive", "Skála adaptív"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -337,7 +337,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Skala adaptif"), ("Scale adaptive", "Skala adaptif"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -323,7 +323,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Translate mode", ""), ("Translate mode", ""),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -321,7 +321,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "フィットウィンドウ"), ("Scale adaptive", "フィットウィンドウ"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -318,7 +318,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "맞는 창"), ("Scale adaptive", "맞는 창"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -322,7 +322,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Skala adaptacyjna"), ("Scale adaptive", "Skala adaptacyjna"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -318,7 +318,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Escala adaptável"), ("Scale adaptive", "Escala adaptável"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", ""), ("Scale adaptive", ""),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Масштаб адаптивный"), ("Scale adaptive", "Масштаб адаптивный"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Prispôsobivá mierka"), ("Scale adaptive", "Prispôsobivá mierka"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", ""), ("Scale adaptive", ""),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -337,7 +337,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Ölçek uyarlanabilir"), ("Scale adaptive", "Ölçek uyarlanabilir"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "適應窗口"), ("Scale adaptive", "適應窗口"),
("General", "常規"), ("General", "常規"),
("Security", "安全"), ("Security", "安全"),
("Acount", "賬戶"), ("Account", "賬戶"),
("Theme", "主題"), ("Theme", "主題"),
("Dark Theme", "暗黑主題"), ("Dark Theme", "暗黑主題"),
("Enable hardware codec", "使用硬件編解碼"), ("Enable hardware codec", "使用硬件編解碼"),

View File

@ -324,7 +324,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Scale adaptive", "Quy mô thích ứng"), ("Scale adaptive", "Quy mô thích ứng"),
("General", ""), ("General", ""),
("Security", ""), ("Security", ""),
("Acount", ""), ("Account", ""),
("Theme", ""), ("Theme", ""),
("Dark Theme", ""), ("Dark Theme", ""),
("Enable hardware codec", ""), ("Enable hardware codec", ""),