close msgbox if loading

This commit is contained in:
open-trade 2020-11-26 21:41:25 +08:00
parent b311ce8692
commit 43452f48d9
3 changed files with 13 additions and 8 deletions

View File

@ -13,7 +13,10 @@ class MyTheme {
static const Color border = Color(0xFFCCCCCC); static const Color border = Color(0xFFCCCCCC);
} }
void showLoading(String text) { void showLoading(String text, BuildContext context) {
if (_hasDialog) {
Navigator.pop(context);
}
dismissLoading(); dismissLoading();
EasyLoading.show(status: text); EasyLoading.show(status: text);
} }

View File

@ -86,7 +86,7 @@ class FfiModel with ChangeNotifier {
if (name == 'msgbox') { if (name == 'msgbox') {
handleMsgbox(evt, id, context); handleMsgbox(evt, id, context);
} else if (name == 'peer_info') { } else if (name == 'peer_info') {
handlePeerInfo(evt); handlePeerInfo(evt, context);
} else if (name == 'switch_display') { } else if (name == 'switch_display') {
handleSwitchDisplay(evt); handleSwitchDisplay(evt);
} else if (name == 'cursor_data') { } else if (name == 'cursor_data') {
@ -155,7 +155,7 @@ class FfiModel with ChangeNotifier {
notifyListeners(); notifyListeners();
} }
void handlePeerInfo(Map<String, dynamic> evt) { void handlePeerInfo(Map<String, dynamic> evt, BuildContext context) {
dismissLoading(); dismissLoading();
_pi.username = evt['username']; _pi.username = evt['username'];
_pi.hostname = evt['hostname']; _pi.hostname = evt['hostname'];
@ -178,7 +178,7 @@ class FfiModel with ChangeNotifier {
FFI.cursorModel.updateDisplayOrigin(_display.x, _display.y); FFI.cursorModel.updateDisplayOrigin(_display.x, _display.y);
} }
if (displays.length > 0) { if (displays.length > 0) {
showLoading('Waiting for image...'); showLoading('Waiting for image...', context);
_waitForImage = true; _waitForImage = true;
} }
} }
@ -578,8 +578,10 @@ class FFI {
_dir = (await getApplicationDocumentsDirectory()).path; _dir = (await getApplicationDocumentsDirectory()).path;
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin(); DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo; AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
print( final name = '${androidInfo.brand}-${androidInfo.model}';
'${androidInfo.product} ${androidInfo.brand} ${androidInfo.device} ${androidInfo.model} ${androidInfo.brand} ${androidInfo.manufacturer}'); final id = androidInfo.id;
setByName('info1', id);
setByName('info2', name);
setByName('init', _dir); setByName('init', _dir);
} }
} }

View File

@ -41,7 +41,7 @@ class _RemotePageState extends State<RemotePage> {
FFI.connect(widget.id); FFI.connect(widget.id);
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
SystemChrome.setEnabledSystemUIOverlays([]); SystemChrome.setEnabledSystemUIOverlays([]);
showLoading('Connecting...'); showLoading('Connecting...', context);
_interval = _interval =
Timer.periodic(Duration(milliseconds: 30), (timer) => interval()); Timer.periodic(Duration(milliseconds: 30), (timer) => interval());
}); });
@ -530,7 +530,7 @@ void enterPasswordDialog(String id, BuildContext context) {
var text = controller.text.trim(); var text = controller.text.trim();
if (text == '') return; if (text == '') return;
FFI.login(text, remember); FFI.login(text, remember);
showLoading('Logging in...'); showLoading('Logging in...', context);
Navigator.pop(context); Navigator.pop(context);
}, },
child: Text('OK'), child: Text('OK'),