From d99b0599e74a1a50f6f2275c89fb6b32afc49eb9 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:14:06 +0400 Subject: [PATCH] regular paste button --- .../Shared/Views/ChatList/ChatListView.swift | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 74c274bd03..c2aedebafa 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -301,10 +301,19 @@ private struct ChatListSearchBar: View { searchText = "" } } else { - Image(systemName: "qrcode") - .onTapGesture { - showScanCodeSheet = true - } + HStack(spacing: 12) { + Image(systemName: "doc") + .onTapGesture { + if let str = UIPasteboard.general.string { + searchText = str + } + } + + Image(systemName: "qrcode") + .onTapGesture { + showScanCodeSheet = true + } + } } } .padding(EdgeInsets(top: 7, leading: 7, bottom: 7, trailing: 7)) @@ -333,13 +342,17 @@ private struct ChatListSearchBar: View { } .onChange(of: searchText) { t in let link = t.trimmingCharacters(in: .whitespaces) - if strIsSimplexLink(link) { + if strIsSimplexLink(link) { // if SimpleX link is pasted, show connection dialogue hideKeyboard() searchText = "" withAnimation { searchMode = false } connect(link) + } else if t != "" && !searchMode { // if some other text is pasted, enter search mode + withAnimation { + searchMode = true + } } } .alert(item: $alert) { a in