mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 00:13:01 +08:00
request focus again when android account password obtain focus (#6744)
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
9a652e789d
commit
26cebd2aeb
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -411,12 +412,14 @@ class PasswordWidget extends StatefulWidget {
|
||||
Key? key,
|
||||
required this.controller,
|
||||
this.autoFocus = true,
|
||||
this.reRequestFocus = false,
|
||||
this.hintText,
|
||||
this.errorText,
|
||||
}) : super(key: key);
|
||||
|
||||
final TextEditingController controller;
|
||||
final bool autoFocus;
|
||||
final bool reRequestFocus;
|
||||
final String? hintText;
|
||||
final String? errorText;
|
||||
|
||||
@ -428,6 +431,7 @@ class _PasswordWidgetState extends State<PasswordWidget> {
|
||||
bool _passwordVisible = false;
|
||||
final _focusNode = FocusNode();
|
||||
Timer? _timer;
|
||||
Timer? _timerReRequestFocus;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -436,11 +440,23 @@ class _PasswordWidgetState extends State<PasswordWidget> {
|
||||
_timer =
|
||||
Timer(Duration(milliseconds: 50), () => _focusNode.requestFocus());
|
||||
}
|
||||
// software secure keyboard will take the focus since flutter 3.13
|
||||
// request focus again when android account password obtain focus
|
||||
if (Platform.isAndroid && widget.reRequestFocus) {
|
||||
_focusNode.addListener(() {
|
||||
if (_focusNode.hasFocus) {
|
||||
_timerReRequestFocus?.cancel();
|
||||
_timerReRequestFocus = Timer(
|
||||
Duration(milliseconds: 100), () => _focusNode.requestFocus());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_timer?.cancel();
|
||||
_timerReRequestFocus?.cancel();
|
||||
_focusNode.unfocus();
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
|
@ -357,6 +357,7 @@ class LoginWidgetUserPass extends StatelessWidget {
|
||||
PasswordWidget(
|
||||
controller: pass,
|
||||
autoFocus: false,
|
||||
reRequestFocus: true,
|
||||
errorText: passMsg,
|
||||
),
|
||||
// NOT use Offstage to wrap LinearProgressIndicator
|
||||
|
Loading…
Reference in New Issue
Block a user