mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-06-11 20:53:13 +08:00
fix loginDialog focus conflict
This commit is contained in:
parent
a8536118c0
commit
87f203db4a
@ -300,8 +300,10 @@ class LoginWidgetUserPass extends StatelessWidget {
|
|||||||
final RxString curOP;
|
final RxString curOP;
|
||||||
final RxBool autoLogin;
|
final RxBool autoLogin;
|
||||||
final Function() onLogin;
|
final Function() onLogin;
|
||||||
|
final FocusNode? userFocusNode;
|
||||||
const LoginWidgetUserPass({
|
const LoginWidgetUserPass({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
this.userFocusNode,
|
||||||
required this.username,
|
required this.username,
|
||||||
required this.pass,
|
required this.pass,
|
||||||
required this.usernameMsg,
|
required this.usernameMsg,
|
||||||
@ -323,7 +325,7 @@ class LoginWidgetUserPass extends StatelessWidget {
|
|||||||
DialogTextField(
|
DialogTextField(
|
||||||
title: '${translate("Username")}:',
|
title: '${translate("Username")}:',
|
||||||
controller: username,
|
controller: username,
|
||||||
autoFocus: true,
|
focusNode: userFocusNode,
|
||||||
prefixIcon: Icon(Icons.account_circle_outlined),
|
prefixIcon: Icon(Icons.account_circle_outlined),
|
||||||
errorText: usernameMsg),
|
errorText: usernameMsg),
|
||||||
DialogTextField(
|
DialogTextField(
|
||||||
@ -376,29 +378,23 @@ class LoginWidgetUserPass extends StatelessWidget {
|
|||||||
|
|
||||||
class DialogTextField extends StatelessWidget {
|
class DialogTextField extends StatelessWidget {
|
||||||
final String title;
|
final String title;
|
||||||
final bool autoFocus;
|
|
||||||
final bool obscureText;
|
final bool obscureText;
|
||||||
final String? errorText;
|
final String? errorText;
|
||||||
final String? helperText;
|
final String? helperText;
|
||||||
final Widget? prefixIcon;
|
final Widget? prefixIcon;
|
||||||
final TextEditingController controller;
|
final TextEditingController controller;
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode? focusNode;
|
||||||
|
|
||||||
DialogTextField(
|
DialogTextField(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
this.autoFocus = false,
|
this.focusNode,
|
||||||
this.obscureText = false,
|
this.obscureText = false,
|
||||||
this.errorText,
|
this.errorText,
|
||||||
this.helperText,
|
this.helperText,
|
||||||
this.prefixIcon,
|
this.prefixIcon,
|
||||||
required this.title,
|
required this.title,
|
||||||
required this.controller})
|
required this.controller})
|
||||||
: super(key: key) {
|
: super(key: key);
|
||||||
// todo mobile requestFocus, on mobile, widget will reload every time the text changes
|
|
||||||
if (autoFocus && isDesktop) {
|
|
||||||
Timer(Duration(milliseconds: 200), () => focusNode.requestFocus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -429,6 +425,8 @@ class DialogTextField extends StatelessWidget {
|
|||||||
Future<bool?> loginDialog() async {
|
Future<bool?> loginDialog() async {
|
||||||
var username = TextEditingController();
|
var username = TextEditingController();
|
||||||
var password = TextEditingController();
|
var password = TextEditingController();
|
||||||
|
final userFocusNode = FocusNode()..requestFocus();
|
||||||
|
Timer(Duration(milliseconds: 100), () => userFocusNode..requestFocus());
|
||||||
|
|
||||||
String? usernameMsg;
|
String? usernameMsg;
|
||||||
String? passwordMsg;
|
String? passwordMsg;
|
||||||
@ -525,6 +523,7 @@ Future<bool?> loginDialog() async {
|
|||||||
curOP: curOP,
|
curOP: curOP,
|
||||||
autoLogin: autoLogin,
|
autoLogin: autoLogin,
|
||||||
onLogin: onLogin,
|
onLogin: onLogin,
|
||||||
|
userFocusNode: userFocusNode,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 8.0,
|
height: 8.0,
|
||||||
@ -571,6 +570,8 @@ Future<bool?> verificationCodeDialog(UserPayload? user) async {
|
|||||||
String? errorText;
|
String? errorText;
|
||||||
|
|
||||||
final code = TextEditingController();
|
final code = TextEditingController();
|
||||||
|
final focusNode = FocusNode()..requestFocus();
|
||||||
|
Timer(Duration(milliseconds: 100), () => focusNode..requestFocus());
|
||||||
|
|
||||||
final res = await gFFI.dialogManager.show<bool>((setState, close) {
|
final res = await gFFI.dialogManager.show<bool>((setState, close) {
|
||||||
bool validate() {
|
bool validate() {
|
||||||
@ -643,8 +644,8 @@ Future<bool?> verificationCodeDialog(UserPayload? user) async {
|
|||||||
DialogTextField(
|
DialogTextField(
|
||||||
title: '${translate("Verification code")}:',
|
title: '${translate("Verification code")}:',
|
||||||
controller: code,
|
controller: code,
|
||||||
autoFocus: true,
|
|
||||||
errorText: errorText,
|
errorText: errorText,
|
||||||
|
focusNode: focusNode,
|
||||||
helperText: translate('verification_tip'),
|
helperText: translate('verification_tip'),
|
||||||
),
|
),
|
||||||
CheckboxListTile(
|
CheckboxListTile(
|
||||||
|
Loading…
Reference in New Issue
Block a user