feat_account: update ui

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-11-07 17:43:22 +08:00
parent a84ee7a6ec
commit dbd3df370a
26 changed files with 112 additions and 191 deletions

View File

@ -470,141 +470,6 @@ class _DesktopHomePageState extends State<DesktopHomePage>
}
}
/// common login dialog for desktop
/// call this directly
Future<bool> loginDialog2() async {
String userName = "";
var userNameMsg = "";
String pass = "";
var passMsg = "";
var userController = TextEditingController(text: userName);
var pwdController = TextEditingController(text: pass);
var isInProgress = false;
var completer = Completer<bool>();
gFFI.dialogManager.show((setState, close) {
submit() async {
setState(() {
userNameMsg = "";
passMsg = "";
isInProgress = true;
});
cancel() {
setState(() {
isInProgress = false;
});
}
userName = userController.text;
pass = pwdController.text;
if (userName.isEmpty) {
userNameMsg = translate("Username missed");
cancel();
return;
}
if (pass.isEmpty) {
passMsg = translate("Password missed");
cancel();
return;
}
try {
final resp = await gFFI.userModel.login(userName, pass);
if (resp.containsKey('error')) {
passMsg = resp['error'];
cancel();
return;
}
// {access_token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJndWlkIjoiMDFkZjQ2ZjgtZjg3OS00MDE0LTk5Y2QtMGMwYzM2MmViZGJlIiwiZXhwIjoxNjYxNDg2NzYwfQ.GZpe1oI8TfM5yTYNrpcwbI599P4Z_-b2GmnwNl2Lr-w,
// token_type: Bearer, user: {id: , name: admin, email: null, note: null, status: null, grp: null, is_admin: true}}
debugPrint("$resp");
completer.complete(true);
} catch (err) {
debugPrint(err.toString());
cancel();
return;
}
close();
}
cancel() {
completer.complete(false);
close();
}
return CustomAlertDialog(
title: Text(translate("Login")),
content: ConstrainedBox(
constraints: const BoxConstraints(minWidth: 500),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(
height: 8.0,
),
Row(
children: [
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child: Text(
"${translate('Username')}:",
textAlign: TextAlign.start,
).marginOnly(bottom: 16.0)),
const SizedBox(
width: 24.0,
),
Expanded(
child: TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
errorText: userNameMsg.isNotEmpty ? userNameMsg : null),
controller: userController,
focusNode: FocusNode()..requestFocus(),
),
),
],
),
const SizedBox(
height: 8.0,
),
Row(
children: [
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child: Text("${translate('Password')}:")
.marginOnly(bottom: 16.0)),
const SizedBox(
width: 24.0,
),
Expanded(
child: TextField(
obscureText: true,
decoration: InputDecoration(
border: const OutlineInputBorder(),
errorText: passMsg.isNotEmpty ? passMsg : null),
controller: pwdController,
),
),
],
),
const SizedBox(
height: 4.0,
),
Offstage(
offstage: !isInProgress, child: const LinearProgressIndicator())
],
),
),
actions: [
TextButton(onPressed: cancel, child: Text(translate("Cancel"))),
TextButton(onPressed: submit, child: Text(translate("OK"))),
],
onSubmit: submit,
onCancel: cancel,
);
});
return completer.future;
}
void setPasswordDialog() async {
final pw = await bind.mainGetPermanentPassword();
final p0 = TextEditingController(text: pw);

View File

@ -9,6 +9,8 @@ import 'package:url_launcher/url_launcher.dart';
import '../../common.dart';
final kMidButtonPadding = const EdgeInsets.fromLTRB(15, 0, 15, 0);
class _IconOP extends StatelessWidget {
final String icon;
final double iconWidth;
@ -51,7 +53,7 @@ class ButtonOP extends StatelessWidget {
Expanded(
child: Container(
height: height,
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
padding: kMidButtonPadding,
child: Obx(() => ElevatedButton(
style: ElevatedButton.styleFrom(
primary: curOP.value.isEmpty || curOP.value == op
@ -61,8 +63,7 @@ class ButtonOP extends StatelessWidget {
onPressed:
curOP.value.isEmpty || curOP.value == op ? onTap : null,
child: Stack(children: [
// to-do: translate
Center(child: Text('Continue with $op')),
Center(child: Text('${translate("Continue with")} $op')),
Align(
alignment: Alignment.centerLeft,
child: SizedBox(
@ -178,7 +179,7 @@ class _WidgetOPState extends State<WidgetOP> {
curOP: widget.curOP,
iconWidth: widget.config.iconWidth,
primaryColor: str2color(widget.config.op, 0x7f),
height: 40,
height: 36,
onTap: () async {
_resetState();
widget.curOP.value = widget.config.op;
@ -265,7 +266,10 @@ class LoginWidgetOP extends StatelessWidget {
curOP: curOP,
cbLogin: cbLogin,
),
const Divider()
const Divider(
indent: 5,
endIndent: 5,
)
])
.expand((i) => i)
.toList();
@ -310,50 +314,56 @@ class LoginWidgetUserPass extends StatelessWidget {
const SizedBox(
height: 8.0,
),
Row(
children: [
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child: Text(
'${translate("Username")}:',
textAlign: TextAlign.start,
).marginOnly(bottom: 16.0)),
const SizedBox(
width: 24.0,
),
Expanded(
child: TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
errorText: usernameMsg.isNotEmpty ? usernameMsg : null),
controller: userController,
focusNode: FocusNode()..requestFocus(),
Container(
padding: kMidButtonPadding,
child: Row(
children: [
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child: Text(
'${translate("Username")}:',
textAlign: TextAlign.start,
).marginOnly(bottom: 16.0)),
const SizedBox(
width: 24.0,
),
),
],
Expanded(
child: TextField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
errorText: usernameMsg.isNotEmpty ? usernameMsg : null),
controller: userController,
focusNode: FocusNode()..requestFocus(),
),
),
],
),
),
const SizedBox(
height: 8.0,
),
Row(
children: [
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child:
Text('${translate("Password")}:').marginOnly(bottom: 16.0)),
const SizedBox(
width: 24.0,
),
Expanded(
child: TextField(
obscureText: true,
decoration: InputDecoration(
border: const OutlineInputBorder(),
errorText: passMsg.isNotEmpty ? passMsg : null),
controller: pwdController,
Container(
padding: kMidButtonPadding,
child: Row(
children: [
ConstrainedBox(
constraints: const BoxConstraints(minWidth: 100),
child: Text('${translate("Password")}:')
.marginOnly(bottom: 16.0)),
const SizedBox(
width: 24.0,
),
),
],
Expanded(
child: TextField(
obscureText: true,
decoration: InputDecoration(
border: const OutlineInputBorder(),
errorText: passMsg.isNotEmpty ? passMsg : null),
controller: pwdController,
),
),
],
),
),
const SizedBox(
height: 4.0,
@ -366,17 +376,17 @@ class LoginWidgetUserPass extends StatelessWidget {
Row(children: [
Expanded(
child: Container(
height: 50,
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
height: 38,
padding: kMidButtonPadding,
child: Obx(() => ElevatedButton(
style: curOP.value.isEmpty || curOP.value == 'rustdesk'
? null
: ElevatedButton.styleFrom(
primary: Colors.grey,
),
child: const Text(
'Login',
style: TextStyle(fontSize: 18),
child: Text(
translate('Login'),
style: TextStyle(fontSize: 16),
),
onPressed: curOP.value.isEmpty || curOP.value == 'rustdesk'
? () {
@ -479,9 +489,9 @@ Future<bool> loginDialog() async {
const SizedBox(
height: 8.0,
),
const Center(
Center(
child: Text(
'or',
translate('or'),
style: TextStyle(fontSize: 16),
)),
const SizedBox(
@ -489,9 +499,9 @@ Future<bool> loginDialog() async {
),
LoginWidgetOP(
ops: [
ConfigOP(op: 'Github', iconWidth: 24),
ConfigOP(op: 'Google', iconWidth: 24),
ConfigOP(op: 'Okta', iconWidth: 46),
ConfigOP(op: 'Github', iconWidth: 20),
ConfigOP(op: 'Google', iconWidth: 20),
ConfigOP(op: 'Okta', iconWidth: 38),
],
curOP: curOP,
cbLogin: (String username) {
@ -503,9 +513,7 @@ Future<bool> loginDialog() async {
],
),
),
actions: [
TextButton(onPressed: cancel, child: Text(translate('Cancel'))),
],
actions: [msgBoxButton(translate('Close'), cancel)],
onCancel: cancel,
);
});

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "请选择要分享的画面(对端操作)。"),
("Show RustDesk", "显示rustdesk"),
("This PC", "此电脑"),
("or", ""),
("Continue with", "使用"),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Vyberte prosím obrazovku, kterou chcete sdílet (Ovládejte na straně protějšku)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Vælg venligst den skærm, der skal deles (Betjen på peer-siden)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Bitte wählen Sie den Bildschirm aus, der freigegeben werden soll (auf der Peer-Seite arbeiten)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -35,5 +35,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("elevated_foreground_window_warning", "Temporarily unable to use the mouse and keyboard, because the current window of the remote desktop requires higher privilege to operate, you can request the remote user to minimize the current window. To avoid this problem, it is recommended to install the software on the remote device or run it with administrator privileges."),
("JumpLink", "View"),
("Stop service", "Stop Service"),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Bonvolu Elekti la ekranon por esti dividita (Funkciu ĉe la sama flanko)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Seleccione la pantalla que se compartirá (Operar en el lado del par)."),
("Show RustDesk", "Mostrar RustDesk"),
("This PC", "Este PC"),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Veuillez sélectionner l'écran à partager (opérer du côté pair)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Kérjük, válassza ki a megosztani kívánt képernyőt (a társoldalon működjön)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Silakan Pilih layar yang akan dibagikan (Operasi di sisi rekan)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Seleziona lo schermo da condividere (opera sul lato peer)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "共有する画面を選択してください(ピア側で操作)。"),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "공유할 화면을 선택하십시오(피어 측에서 작동)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Бөлісетін экранды таңдаңыз (бірдей жағынан жұмыс жасаңыз)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Wybierz ekran do udostępnienia (działaj po stronie równorzędnej)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Por favor, selecione a tela a ser compartilhada (operar no lado do peer)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", ""),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Пожалуйста, выберите экран для совместного использования (работайте на одноранговой стороне)."),
("Show RustDesk", "Показать RustDesk"),
("This PC", "Этот компьютер"),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Vyberte obrazovku, ktorú chcete zdieľať (Ovládajte na strane partnera)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", ""),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Lütfen paylaşılacak ekranı seçiniz (Ekran tarafında çalıştırın)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "請選擇要分享的畫面(在對端操作)。"),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Будь ласка, виберіть екран, до якого потрібно надати доступ (працюйте на стороні однорангового пристрою)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}

View File

@ -387,5 +387,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
("Please Select the screen to be shared(Operate on the peer side).", "Vui lòng Chọn màn hình để chia sẻ (Hoạt động ở phía ngang hàng)."),
("Show RustDesk", ""),
("This PC", ""),
("or", ""),
("Continue with", ""),
].iter().cloned().collect();
}