fix input password dialog bug

This commit is contained in:
open-trade 2021-08-18 02:01:03 +08:00
parent b20bf7d1cb
commit 6c18645561
2 changed files with 8 additions and 2 deletions

View File

@ -29,6 +29,7 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom(
), ),
); );
void Function() loadingCancelCallback = null;
void showLoading(String text, BuildContext context) { void showLoading(String text, BuildContext context) {
if (_hasDialog && context != null) { if (_hasDialog && context != null) {
Navigator.pop(context); Navigator.pop(context);
@ -52,7 +53,10 @@ void showLoading(String text, BuildContext context) {
child: TextButton( child: TextButton(
style: flatButtonStyle, style: flatButtonStyle,
onPressed: () { onPressed: () {
dismissLoading(); // with out loadingCancelCallback, we can see unexpected input password
// dialog shown in home, no clue why, so use this as workaround
// why no such issue on android?
if (loadingCancelCallback != null) loadingCancelCallback();
Navigator.pop(context); Navigator.pop(context);
}, },
child: Text(Translator.call('Cancel'), child: Text(Translator.call('Cancel'),

View File

@ -52,18 +52,20 @@ class _RemotePageState extends State<RemotePage> {
Timer.periodic(Duration(milliseconds: 30), (timer) => interval()); Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
}); });
Wakelock.enable(); Wakelock.enable();
loadingCancelCallback = () => _interval.cancel();
} }
@override @override
void dispose() { void dispose() {
_focusNode.dispose(); _focusNode.dispose();
super.dispose();
FFI.close(); FFI.close();
loadingCancelCallback = null;
_interval.cancel(); _interval.cancel();
_timer?.cancel(); _timer?.cancel();
dismissLoading(); dismissLoading();
SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values);
Wakelock.disable(); Wakelock.disable();
super.dispose();
} }
void resetTool() { void resetTool() {