From ceb9406fcfc61f7c35263a6ded03996cd41c13d2 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:53:21 +0400 Subject: [PATCH] further improve search --- .../Shared/Views/ChatList/ChatListView.swift | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 7e1bf6bfb2..4997d14a0f 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -65,7 +65,6 @@ struct ChatListView: View { private var chatListView: some View { VStack { chatList - .navigationBarHidden(searchMode) } .onDisappear() { withAnimation { userPickerVisible = false } } .refreshable { @@ -135,6 +134,7 @@ struct ChatListView: View { } } } + .navigationBarHidden(searchMode) } private func createGroupButton() -> some View { @@ -164,7 +164,7 @@ struct ChatListView: View { List { if !chatModel.chats.isEmpty { ChatListSearchBar(searchMode: $searchMode, searchText: $searchText) - .listRowSeparator(.hidden, edges: .top) + .listRowSeparator(.hidden) .frame(maxWidth: .infinity) } ForEach(cs, id: \.viewId) { chat in @@ -279,46 +279,48 @@ private struct ChatListSearchBar: View { @State private var showScanCodeSheet = false var body: some View { - HStack(spacing: 12) { - HStack(spacing: 4) { - Image(systemName: "magnifyingglass") - TextField("Search or paste link", text: $searchText) - .foregroundColor(.primary) - .frame(maxWidth: .infinity) - .onTapGesture { - searchMode = true + VStack(spacing: 12) { + HStack(spacing: 12) { + HStack(spacing: 4) { + Image(systemName: "magnifyingglass") + TextField("Search or paste link", text: $searchText) + .foregroundColor(.primary) + .frame(maxWidth: .infinity) + .onTapGesture { + searchMode = true + } + + if searchMode { + Image(systemName: "xmark.circle.fill") + .opacity(searchText == "" ? 0 : 1) + .onTapGesture { + searchText = "" + } + } else { + Image(systemName: "qrcode") + .onTapGesture { + showScanCodeSheet = true + } } - + } + .padding(EdgeInsets(top: 7, leading: 7, bottom: 7, trailing: 7)) + .foregroundColor(.secondary) + .background(Color(.tertiarySystemFill)) + .cornerRadius(10.0) + if searchMode { - Image(systemName: "xmark.circle.fill") - .opacity(searchText == "" ? 0 : 1) + Text("Cancel") + .foregroundColor(.accentColor) .onTapGesture { + hideKeyboard() searchText = "" + searchMode = false } - } else { - Image(systemName: "qrcode") - .onTapGesture { - showScanCodeSheet = true - } + .transition(.identity) } } - .padding(EdgeInsets(top: 7, leading: 7, bottom: 7, trailing: 7)) - .foregroundColor(.secondary) - .background(Color(.tertiarySystemFill)) - .cornerRadius(10.0) - - if searchMode { - Text("Cancel") - .foregroundColor(.accentColor) - .onTapGesture { - hideKeyboard() - searchText = "" - searchMode = false - } - .transition(.identity) - } + Divider() } - .padding(.bottom, 2) .sheet(isPresented: $showScanCodeSheet) { NewChatView(selection: .connect, showQRCodeScanner: true) .environment(\EnvironmentValues.refresh as! WritableKeyPath, nil) // fixes .refreshable in ChatListView affecting nested view