add work search
This commit is contained in:
parent
b49281de91
commit
3d5ba0538f
@ -13,8 +13,7 @@ struct TopBarView: View {
|
||||
// Привязка для управления боковым меню
|
||||
@Binding var isSideMenuPresented: Bool
|
||||
@Binding var chatSearchRevealProgress: CGFloat
|
||||
|
||||
@State private var searchText: String = ""
|
||||
@Binding var chatSearchText: String
|
||||
|
||||
var isHomeTab: Bool {
|
||||
return title == "Home"
|
||||
@ -154,12 +153,12 @@ private extension TopBarView {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(.secondary)
|
||||
TextField(NSLocalizedString("Поиск", comment: ""), text: $searchText)
|
||||
TextField(NSLocalizedString("Поиск", comment: ""), text: $chatSearchText)
|
||||
.textFieldStyle(.plain)
|
||||
.textInputAutocapitalization(.never)
|
||||
.autocorrectionDisabled()
|
||||
if !searchText.isEmpty {
|
||||
Button(action: { searchText = "" }) {
|
||||
if !chatSearchText.isEmpty {
|
||||
Button(action: { chatSearchText = "" }) {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
@ -182,6 +181,7 @@ struct TopBarView_Previews: PreviewProvider {
|
||||
@State private var isSideMenuPresented = false
|
||||
@State private var revealProgress: CGFloat = 1
|
||||
@StateObject private var viewModel = LoginViewModel()
|
||||
@State private var searchText: String = ""
|
||||
|
||||
var body: some View {
|
||||
TopBarView(
|
||||
@ -190,7 +190,8 @@ struct TopBarView_Previews: PreviewProvider {
|
||||
accounts: [selectedAccount],
|
||||
viewModel: viewModel,
|
||||
isSideMenuPresented: $isSideMenuPresented,
|
||||
chatSearchRevealProgress: $revealProgress
|
||||
chatSearchRevealProgress: $revealProgress,
|
||||
chatSearchText: $searchText
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,17 +13,18 @@ import UIKit
|
||||
struct ChatsTab: View {
|
||||
var currentUserId: String?
|
||||
@Binding var searchRevealProgress: CGFloat
|
||||
@Binding var searchText: String
|
||||
@StateObject private var viewModel = PrivateChatsViewModel()
|
||||
@State private var selectedChatId: String?
|
||||
@State private var searchText: String = ""
|
||||
@State private var searchDragStartProgress: CGFloat = 0
|
||||
@State private var isSearchGestureActive: Bool = false
|
||||
|
||||
private let searchRevealDistance: CGFloat = 90
|
||||
|
||||
init(currentUserId: String? = nil, searchRevealProgress: Binding<CGFloat>) {
|
||||
init(currentUserId: String? = nil, searchRevealProgress: Binding<CGFloat>, searchText: Binding<String>) {
|
||||
self.currentUserId = currentUserId
|
||||
self._searchRevealProgress = searchRevealProgress
|
||||
self._searchText = searchText
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -143,31 +144,6 @@ struct ChatsTab: View {
|
||||
// }
|
||||
}
|
||||
|
||||
private var searchBar: some View {
|
||||
HStack(spacing: 8) {
|
||||
Image(systemName: "magnifyingglass")
|
||||
.foregroundColor(.secondary)
|
||||
TextField(NSLocalizedString("Поиск", comment: ""), text: $searchText)
|
||||
.textFieldStyle(.plain)
|
||||
.textInputAutocapitalization(.never)
|
||||
.autocorrectionDisabled()
|
||||
if !searchText.isEmpty {
|
||||
Button(action: { searchText = "" }) {
|
||||
Image(systemName: "xmark.circle.fill")
|
||||
.foregroundColor(.secondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.frame(minHeight: 36)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 12, style: .continuous)
|
||||
.fill(Color(UIColor.secondarySystemBackground))
|
||||
)
|
||||
}
|
||||
|
||||
private var searchBarGesture: some Gesture {
|
||||
DragGesture(minimumDistance: 10, coordinateSpace: .local)
|
||||
.onChanged { value in
|
||||
@ -624,9 +600,10 @@ private struct ChatRowView: View {
|
||||
struct ChatsTab_Previews: PreviewProvider {
|
||||
struct Wrapper: View {
|
||||
@State private var progress: CGFloat = 1
|
||||
@State private var searchText: String = ""
|
||||
|
||||
var body: some View {
|
||||
ChatsTab(searchRevealProgress: $progress)
|
||||
ChatsTab(searchRevealProgress: $progress, searchText: $searchText)
|
||||
.environmentObject(ThemeManager())
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ struct MainView: View {
|
||||
@State private var isSideMenuPresented = false
|
||||
@State private var menuOffset: CGFloat = 0
|
||||
@State private var chatSearchRevealProgress: CGFloat = 0
|
||||
@State private var chatSearchText: String = ""
|
||||
|
||||
private var tabTitle: String {
|
||||
switch selectedTab {
|
||||
@ -40,7 +41,8 @@ struct MainView: View {
|
||||
accounts: accounts,
|
||||
viewModel: viewModel,
|
||||
isSideMenuPresented: $isSideMenuPresented,
|
||||
chatSearchRevealProgress: $chatSearchRevealProgress
|
||||
chatSearchRevealProgress: $chatSearchRevealProgress,
|
||||
chatSearchText: $chatSearchText
|
||||
)
|
||||
|
||||
ZStack {
|
||||
@ -52,7 +54,8 @@ struct MainView: View {
|
||||
|
||||
ChatsTab(
|
||||
currentUserId: viewModel.userId.isEmpty ? nil : viewModel.userId,
|
||||
searchRevealProgress: $chatSearchRevealProgress
|
||||
searchRevealProgress: $chatSearchRevealProgress,
|
||||
searchText: $chatSearchText
|
||||
)
|
||||
.opacity(selectedTab == 2 ? 1 : 0)
|
||||
.allowsHitTesting(selectedTab == 2)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user