From 42d4f94fecfc3f5222e6f79b2fb715cf98f54ab1 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 26 May 2023 15:49:26 +0400 Subject: [PATCH] mobile: always show chat list search (#2517) --- .../app/views/chatlist/ChatListView.kt | 2 +- .../Shared/Views/ChatList/ChatListView.swift | 40 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListView.kt index 6104f7e6b0..07c859e508 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chatlist/ChatListView.kt @@ -176,7 +176,7 @@ private fun ChatListToolbar(chatModel: ChatModel, drawerState: DrawerState, user BackHandler(onBack = hideSearchOnBack) } val barButtons = arrayListOf<@Composable RowScope.() -> Unit>() - if (chatModel.chats.size >= 8) { + if (chatModel.chats.size > 0) { barButtons.add { IconButton({ showSearch = true }) { Icon(painterResource(R.drawable.ic_search_500), stringResource(android.R.string.search_go).capitalize(Locale.current), tint = MaterialTheme.colors.primary) diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 296bcced21..c372acdd24 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -29,11 +29,7 @@ struct ChatListView: View { if chatModel.chats.isEmpty { onboardingButtons() } - if chatModel.chats.count > 8 { - chatList.searchable(text: $searchText) - } else { - chatList - } + chatListView } } if userPickerVisible { @@ -47,18 +43,12 @@ struct ChatListView: View { } } - var chatList: some View { - List { - ForEach(filteredChats(), id: \.viewId) { chat in - ChatListNavLink(chat: chat) - .padding(.trailing, -16) - .disabled(chatModel.chatRunning != true) - } - } - .onChange(of: chatModel.chatId) { _ in - if chatModel.chatId == nil, let chatId = chatModel.chatToTop { - chatModel.chatToTop = nil - chatModel.popChat(chatId) + private var chatListView: some View { + VStack { + if chatModel.chats.count > 0 { + chatList.searchable(text: $searchText) + } else { + chatList } } .onChange(of: chatModel.appOpenUrl) { _ in connectViaUrl() } @@ -116,6 +106,22 @@ struct ChatListView: View { } } + private var chatList: some View { + List { + ForEach(filteredChats(), id: \.viewId) { chat in + ChatListNavLink(chat: chat) + .padding(.trailing, -16) + .disabled(chatModel.chatRunning != true) + } + } + .onChange(of: chatModel.chatId) { _ in + if chatModel.chatId == nil, let chatId = chatModel.chatToTop { + chatModel.chatToTop = nil + chatModel.popChat(chatId) + } + } + } + private func unreadBadge(_ text: Text? = Text(" "), size: CGFloat = 18) -> some View { Circle() .frame(width: size, height: size)