From f2d96b895f1d29efa0eb3d2504c17f53c952ef7e Mon Sep 17 00:00:00 2001 From: fufesou Date: Wed, 23 Aug 2023 23:57:09 +0800 Subject: [PATCH] hide empty waiting layer after images are reached Signed-off-by: fufesou --- flutter/lib/desktop/pages/remote_page.dart | 11 +++++++---- flutter/lib/models/model.dart | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 8084b230d..339ecb3f2 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -234,6 +234,8 @@ class _RemotePageState extends State bind.sessionInputOsPassword(sessionId: sessionId, value: ''); }, child: BlockableOverlay( + /// the Overlay key will be set with _blockableOverlayState in BlockableOverlay + /// see override build() in [BlockableOverlay] state: _blockableOverlayState, underlying: Container( color: Colors.transparent, @@ -244,9 +246,6 @@ class _RemotePageState extends State Widget buildBody(BuildContext context) { return Scaffold( backgroundColor: Theme.of(context).colorScheme.background, - - /// the Overlay key will be set with _blockableOverlayState in BlockableOverlay - /// see override build() in [BlockableOverlay] body: Stack( children: [ Container( @@ -273,7 +272,11 @@ class _RemotePageState extends State }, inputModel: _ffi.inputModel, child: getBodyForDesktop(context))), - emptyOverlay(), + Obx( + () => _ffi.ffiModel.waitForFirstImage.isTrue + ? emptyOverlay() + : Offstage(), + ), RemoteToolbar( id: widget.id, ffi: _ffi, diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 202216b59..25ba22c70 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -38,8 +38,6 @@ import 'platform_model.dart'; typedef HandleMsgBox = Function(Map evt, String id); typedef ReconnectHandle = Function(OverlayDialogManager, SessionID, bool); -final _waitForImageDialogShow = {}; -final _waitForFirstImage = {}; final _constSessionId = Uuid().v4obj(); class CachedPeerData { @@ -100,6 +98,9 @@ class FfiModel with ChangeNotifier { WeakReference parent; late final SessionID sessionId; + RxBool waitForImageDialogShow = true.obs; + RxBool waitForFirstImage = true.obs; + Map get permissions => _permissions; Display get display => _display; @@ -498,7 +499,7 @@ class FfiModel with ChangeNotifier { closeConnection(); } - if (_waitForFirstImage[sessionId] == false) return; + if (waitForFirstImage.isFalse) return; dialogManager.show( (setState, close, context) => CustomAlertDialog( title: null, @@ -509,7 +510,7 @@ class FfiModel with ChangeNotifier { onCancel: onClose), tag: '$sessionId-waiting-for-image', ); - _waitForImageDialogShow[sessionId] = true; + waitForImageDialogShow.value = true; bind.sessionOnWaitingForImageDialogShow(sessionId: sessionId); } @@ -578,7 +579,7 @@ class FfiModel with ChangeNotifier { } if (displays.isNotEmpty) { _reconnects = 1; - _waitForFirstImage[sessionId] = true; + waitForFirstImage.value = true; } Map features = json.decode(evt['features']); _pi.features.privacyMode = features['privacy_mode'] == 1; @@ -1814,12 +1815,12 @@ class FFI { } void onEvent2UIRgba() async { - if (_waitForImageDialogShow[sessionId] == true) { - _waitForImageDialogShow[sessionId] = false; + if (ffiModel.waitForImageDialogShow.isTrue) { + ffiModel.waitForImageDialogShow.value = false; clearWaitingForImage(dialogManager, sessionId); } - if (_waitForFirstImage[sessionId] == true) { - _waitForFirstImage[sessionId] = false; + if (ffiModel.waitForFirstImage.value == true) { + ffiModel.waitForFirstImage.value = false; dialogManager.dismissAll(); await canvasModel.updateViewStyle(); await canvasModel.updateScrollStyle();