From 64ce49f7db5c4eba85ea570b14f572714c6d915a Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:44:53 +0700 Subject: [PATCH] chatList and newChatSheet search fields --- .../common/views/chatlist/ChatListView.kt | 11 ++-- .../simplex/common/views/helpers/ModalView.kt | 4 +- .../common/views/newchat/NewChatSheet.kt | 66 ++++++++++++++----- 3 files changed, 58 insertions(+), 23 deletions(-) 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 e632e5a13b..80655b5b5d 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 @@ -166,7 +166,7 @@ fun ChatListView(chatModel: ChatModel, userPickerState: MutableStateFlow Unit, showClose: Boolean = true, enableClose: Boolean = true, - background: Color = MaterialTheme.colors.background, + background: Color = Color.Unspecified, modifier: Modifier = Modifier, closeOnTop: Boolean = true, endButtons: @Composable RowScope.() -> Unit = {}, @@ -32,7 +32,7 @@ fun ModalView( BackHandler(enabled = enableClose, onBack = close) } Surface(Modifier.fillMaxSize(), contentColor = LocalContentColor.current) { - Column(if (background != MaterialTheme.colors.background) Modifier.background(background) else Modifier.themedBackground()) { + Column(if (background != Color.Unspecified) Modifier.background(background) else Modifier.themedBackground()) { if (closeOnTop) { CloseSheetBar(if (enableClose) close else null, showClose, endButtons = endButtons) } diff --git a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt index f0d48fa67c..13d99e479d 100644 --- a/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt +++ b/apps/multiplatform/common/src/commonMain/kotlin/chat/simplex/common/views/newchat/NewChatSheet.kt @@ -43,9 +43,10 @@ fun ModalData.NewChatSheet(rh: RemoteHostInfo?, close: () -> Unit) { val oneHandUI = remember { appPrefs.oneHandUI.state } Scaffold( + backgroundColor = Color.Unspecified, bottomBar = { if (oneHandUI.value) { - Column(Modifier.imePadding()) { + Column { Divider() CloseSheetBar( close = close, @@ -201,6 +202,7 @@ private fun ModalData.NewChatSheetLayout( } } stickyHeader { + val scrolledSomething by remember { derivedStateOf { listState.firstVisibleItemScrollOffset > 0 } } Column( Modifier .offset { @@ -226,18 +228,36 @@ private fun ModalData.NewChatSheetLayout( } IntOffset(0, y) } - .background(MaterialTheme.colors.background) + // show background when something is scrolled because otherwise the bar is transparent. + // not using background always because of gradient in SimpleX theme + .background(if (scrolledSomething && keyboardState == KeyboardState.Opened) { + MaterialTheme.colors.background + } else { + Color.Unspecified + } + ) ) { Divider() - ContactsSearchBar( - listState = listState, - searchText = searchText, - searchShowingSimplexLink = searchShowingSimplexLink, - searchChatFilteredBySimplexLink = searchChatFilteredBySimplexLink, - close = close, - ) if (!oneHandUI.value) { + ContactsSearchBar( + listState = listState, + searchText = searchText, + searchShowingSimplexLink = searchShowingSimplexLink, + searchChatFilteredBySimplexLink = searchChatFilteredBySimplexLink, + close = close, + ) Divider() + } else { + Column(Modifier.consumeWindowInsets(WindowInsets.navigationBars).consumeWindowInsets(PaddingValues(bottom = AppBarHeight))) { + ContactsSearchBar( + listState = listState, + searchText = searchText, + searchShowingSimplexLink = searchShowingSimplexLink, + searchChatFilteredBySimplexLink = searchChatFilteredBySimplexLink, + close = close, + ) + Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.ime)) + } } } } @@ -562,9 +582,10 @@ private fun contactTypesSearchTargets(baseContactTypes: List, searc private fun ModalData.DeletedContactsView(rh: RemoteHostInfo?, closeDeletedChats: () -> Unit, close: () -> Unit) { val oneHandUI = remember { appPrefs.oneHandUI.state } Scaffold( + backgroundColor = Color.Unspecified, bottomBar = { if (oneHandUI.value) { - Column(Modifier.imePadding()) { + Column { Divider() CloseSheetBar( close = closeDeletedChats, @@ -615,14 +636,25 @@ private fun ModalData.DeletedContactsView(rh: RemoteHostInfo?, closeDeletedChats item { if (!oneHandUI.value) { Divider() + ContactsSearchBar( + listState = listState, + searchText = searchText, + searchShowingSimplexLink = searchShowingSimplexLink, + searchChatFilteredBySimplexLink = searchChatFilteredBySimplexLink, + close = close, + ) + } else { + Column(Modifier.consumeWindowInsets(WindowInsets.navigationBars).consumeWindowInsets(PaddingValues(bottom = AppBarHeight))) { + ContactsSearchBar( + listState = listState, + searchText = searchText, + searchShowingSimplexLink = searchShowingSimplexLink, + searchChatFilteredBySimplexLink = searchChatFilteredBySimplexLink, + close = close, + ) + Spacer(Modifier.windowInsetsBottomHeight(WindowInsets.ime)) + } } - ContactsSearchBar( - listState = listState, - searchText = searchText, - searchShowingSimplexLink = searchShowingSimplexLink, - searchChatFilteredBySimplexLink = searchChatFilteredBySimplexLink, - close = close, - ) Divider() }