From f6ee6338c4423bbecabe4a730690fd5d978d361f Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Wed, 7 Aug 2024 00:12:30 +0900 Subject: [PATCH] android: status bar color fix in non-oneHandUI (#4603) --- .../kotlin/chat/simplex/common/App.kt | 4 ++- .../common/views/chatlist/ChatListView.kt | 25 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt index b24c05937d..0df2633610 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/App.kt @@ -276,7 +276,9 @@ fun AndroidScreen(settingsState: SettingsViewState) { snapshotFlow { ModalManager.center.modalCount.value > 0 } .filter { chatModel.chatId.value == null } .collect { modalBackground -> - if (modalBackground && !chatModel.newChatSheetVisible.value) { + if (chatModel.newChatSheetVisible.value) { + platform.androidSetStatusAndNavBarColors(CurrentColors.value.colors.isLight, CurrentColors.value.colors.background, false, appPrefs.oneHandUI.get()) + } else if (modalBackground) { platform.androidSetStatusAndNavBarColors(CurrentColors.value.colors.isLight, CurrentColors.value.colors.background, false, false) } else { platform.androidSetStatusAndNavBarColors(CurrentColors.value.colors.isLight, CurrentColors.value.colors.background, !appPrefs.oneHandUI.get(), appPrefs.oneHandUI.get()) diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt index 7b7c07bef5..310d4d163d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/chatlist/ChatListView.kt @@ -47,13 +47,24 @@ private fun showNewChatSheet(oneHandUI: State) { ModalManager.start.closeModals() ModalManager.end.closeModals() chatModel.newChatSheetVisible.value = true - ModalManager.start.showModalCloseable( - closeOnTop = !oneHandUI.value, - ) { close -> - NewChatSheet(rh = chatModel.currentRemoteHost.value, close) - DisposableEffect(Unit) { - onDispose { - chatModel.newChatSheetVisible.value = false + ModalManager.start.showCustomModal { close -> + val close = { + // It will set it faster than in onDispose. It's important to catch the actual state before + // closing modal for reacting with status bar changes in [App] + chatModel.newChatSheetVisible.value = false + close() + } + ModalView(close, closeOnTop = !oneHandUI.value) { + if (appPlatform.isAndroid) { + BackHandler { + close() + } + } + NewChatSheet(rh = chatModel.currentRemoteHost.value, close) + DisposableEffect(Unit) { + onDispose { + chatModel.newChatSheetVisible.value = false + } } } }