search_top_bar #1
@ -6,6 +6,9 @@
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
#if canImport(UIKit)
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
struct ChatsTab: View {
|
||||
var currentUserId: String?
|
||||
@ -125,7 +128,9 @@ struct ChatsTab: View {
|
||||
}
|
||||
}
|
||||
.listStyle(.plain)
|
||||
.modifier(ScrollDismissesKeyboardModifier())
|
||||
.simultaneousGesture(searchBarGesture)
|
||||
.simultaneousGesture(tapToDismissKeyboardGesture)
|
||||
// .safeAreaInset(edge: .top) {
|
||||
// VStack(spacing: 0) {
|
||||
// searchBar
|
||||
@ -193,6 +198,12 @@ struct ChatsTab: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var tapToDismissKeyboardGesture: some Gesture {
|
||||
TapGesture().onEnded {
|
||||
dismissKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
private var isSearching: Bool {
|
||||
!searchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||
}
|
||||
@ -286,6 +297,24 @@ struct ChatsTab: View {
|
||||
}
|
||||
}
|
||||
|
||||
private extension ChatsTab {
|
||||
func dismissKeyboard() {
|
||||
#if canImport(UIKit)
|
||||
UIApplication.shared.sendAction(#selector(UIResponder.resignFirstResponder), to: nil, from: nil, for: nil)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private struct ScrollDismissesKeyboardModifier: ViewModifier {
|
||||
func body(content: Content) -> some View {
|
||||
if #available(iOS 16.0, *) {
|
||||
content.scrollDismissesKeyboard(.interactively)
|
||||
} else {
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct ChatRowView: View {
|
||||
let chat: PrivateChatListItem
|
||||
let currentUserId: String?
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user