This commit is contained in:
Evgeny Poberezkin 2023-12-01 19:05:39 +00:00
parent 0b4a858496
commit 75ebc01e7f
2 changed files with 18 additions and 18 deletions

View File

@ -12,7 +12,7 @@ import SimpleXChat
struct ChatListView: View { struct ChatListView: View {
@EnvironmentObject var chatModel: ChatModel @EnvironmentObject var chatModel: ChatModel
@Binding var showSettings: Bool @Binding var showSettings: Bool
@State private var searchMode = false @FocusState private var searchMode
@State private var searchText = "" @State private var searchText = ""
@State private var newChatMenuOption: NewChatMenuOption? = nil @State private var newChatMenuOption: NewChatMenuOption? = nil
@State private var userPickerVisible = false @State private var userPickerVisible = false
@ -85,7 +85,6 @@ struct ChatListView: View {
.listStyle(.plain) .listStyle(.plain)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
.navigationBarHidden(searchMode) .navigationBarHidden(searchMode)
.animation(.easeInOut(duration: 0.2))
.toolbar { .toolbar {
ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
let user = chatModel.currentUser ?? User.sampleData let user = chatModel.currentUser ?? User.sampleData
@ -155,7 +154,6 @@ struct ChatListView: View {
.disabled(chatModel.chatRunning != true) .disabled(chatModel.chatRunning != true)
} }
.offset(x: -8) .offset(x: -8)
.animation(nil)
} }
} }
.onChange(of: chatModel.chatId) { _ in .onChange(of: chatModel.chatId) { _ in
@ -257,7 +255,7 @@ struct ChatListView: View {
} }
private struct ChatListSearchBar: View { private struct ChatListSearchBar: View {
@Binding var searchMode: Bool @FocusState.Binding var searchMode: Bool
@Binding var searchText: String @Binding var searchText: String
@State private var showScanCodeSheet = false @State private var showScanCodeSheet = false
@State private var alert: PlanAndConnectAlert? @State private var alert: PlanAndConnectAlert?
@ -269,13 +267,9 @@ private struct ChatListSearchBar: View {
HStack(spacing: 4) { HStack(spacing: 4) {
Image(systemName: "magnifyingglass") Image(systemName: "magnifyingglass")
TextField("Search or paste link", text: $searchText) TextField("Search or paste link", text: $searchText)
.focused($searchMode)
.foregroundColor(.primary) .foregroundColor(.primary)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)
.onTapGesture {
withAnimation {
searchMode = true
}
}
if searchMode { if searchMode {
Image(systemName: "xmark.circle.fill") Image(systemName: "xmark.circle.fill")
@ -284,19 +278,25 @@ private struct ChatListSearchBar: View {
searchText = "" searchText = ""
} }
} else { } else {
HStack(spacing: 16) { HStack(spacing: 24) {
Image(systemName: "doc") if UIPasteboard.general.hasURLs {
.onTapGesture { Image(systemName: "doc")
if let str = UIPasteboard.general.string { .onTapGesture {
searchText = str if let str = UIPasteboard.general.string {
searchText = str
}
} }
} }
Image(systemName: "qrcode") Image(systemName: "qrcode.viewfinder")
.resizable()
.scaledToFit()
.frame(width: 27, height: 27)
.onTapGesture { .onTapGesture {
showScanCodeSheet = true showScanCodeSheet = true
} }
} }
.padding(.trailing, 2)
} }
} }
.padding(EdgeInsets(top: 7, leading: 7, bottom: 7, trailing: 7)) .padding(EdgeInsets(top: 7, leading: 7, bottom: 7, trailing: 7))

View File

@ -23,12 +23,12 @@ struct NewChatMenuButton: View {
Button { Button {
newChatMenuOption = .newContact newChatMenuOption = .newContact
} label: { } label: {
Text("New contact") Text("Add contact")
} }
Button { Button {
newChatMenuOption = .newGroup newChatMenuOption = .newGroup
} label: { } label: {
Text("New group") Text("Create group")
} }
} label: { } label: {
Image(systemName: "square.and.pencil") Image(systemName: "square.and.pencil")