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 isSideMenuPresented: Bool
 | 
				
			||||||
    @Binding var chatSearchRevealProgress: CGFloat
 | 
					    @Binding var chatSearchRevealProgress: CGFloat
 | 
				
			||||||
    
 | 
					    @Binding var chatSearchText: String
 | 
				
			||||||
    @State private var searchText: String = ""
 | 
					 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    var isHomeTab: Bool {
 | 
					    var isHomeTab: Bool {
 | 
				
			||||||
        return title == "Home"
 | 
					        return title == "Home"
 | 
				
			||||||
@ -154,12 +153,12 @@ private extension TopBarView {
 | 
				
			|||||||
        HStack(spacing: 8) {
 | 
					        HStack(spacing: 8) {
 | 
				
			||||||
            Image(systemName: "magnifyingglass")
 | 
					            Image(systemName: "magnifyingglass")
 | 
				
			||||||
                .foregroundColor(.secondary)
 | 
					                .foregroundColor(.secondary)
 | 
				
			||||||
            TextField(NSLocalizedString("Поиск", comment: ""), text: $searchText)
 | 
					            TextField(NSLocalizedString("Поиск", comment: ""), text: $chatSearchText)
 | 
				
			||||||
                .textFieldStyle(.plain)
 | 
					                .textFieldStyle(.plain)
 | 
				
			||||||
                .textInputAutocapitalization(.never)
 | 
					                .textInputAutocapitalization(.never)
 | 
				
			||||||
                .autocorrectionDisabled()
 | 
					                .autocorrectionDisabled()
 | 
				
			||||||
            if !searchText.isEmpty {
 | 
					            if !chatSearchText.isEmpty {
 | 
				
			||||||
                Button(action: { searchText = "" }) {
 | 
					                Button(action: { chatSearchText = "" }) {
 | 
				
			||||||
                    Image(systemName: "xmark.circle.fill")
 | 
					                    Image(systemName: "xmark.circle.fill")
 | 
				
			||||||
                        .foregroundColor(.secondary)
 | 
					                        .foregroundColor(.secondary)
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@ -182,6 +181,7 @@ struct TopBarView_Previews: PreviewProvider {
 | 
				
			|||||||
        @State private var isSideMenuPresented = false
 | 
					        @State private var isSideMenuPresented = false
 | 
				
			||||||
        @State private var revealProgress: CGFloat = 1
 | 
					        @State private var revealProgress: CGFloat = 1
 | 
				
			||||||
        @StateObject private var viewModel = LoginViewModel()
 | 
					        @StateObject private var viewModel = LoginViewModel()
 | 
				
			||||||
 | 
					        @State private var searchText: String = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var body: some View {
 | 
					        var body: some View {
 | 
				
			||||||
            TopBarView(
 | 
					            TopBarView(
 | 
				
			||||||
@ -190,7 +190,8 @@ struct TopBarView_Previews: PreviewProvider {
 | 
				
			|||||||
                accounts: [selectedAccount],
 | 
					                accounts: [selectedAccount],
 | 
				
			||||||
                viewModel: viewModel,
 | 
					                viewModel: viewModel,
 | 
				
			||||||
                isSideMenuPresented: $isSideMenuPresented,
 | 
					                isSideMenuPresented: $isSideMenuPresented,
 | 
				
			||||||
                chatSearchRevealProgress: $revealProgress
 | 
					                chatSearchRevealProgress: $revealProgress,
 | 
				
			||||||
 | 
					                chatSearchText: $searchText
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -13,17 +13,18 @@ import UIKit
 | 
				
			|||||||
struct ChatsTab: View {
 | 
					struct ChatsTab: View {
 | 
				
			||||||
    var currentUserId: String?
 | 
					    var currentUserId: String?
 | 
				
			||||||
    @Binding var searchRevealProgress: CGFloat
 | 
					    @Binding var searchRevealProgress: CGFloat
 | 
				
			||||||
 | 
					    @Binding var searchText: String
 | 
				
			||||||
    @StateObject private var viewModel = PrivateChatsViewModel()
 | 
					    @StateObject private var viewModel = PrivateChatsViewModel()
 | 
				
			||||||
    @State private var selectedChatId: String?
 | 
					    @State private var selectedChatId: String?
 | 
				
			||||||
    @State private var searchText: String = ""
 | 
					 | 
				
			||||||
    @State private var searchDragStartProgress: CGFloat = 0
 | 
					    @State private var searchDragStartProgress: CGFloat = 0
 | 
				
			||||||
    @State private var isSearchGestureActive: Bool = false
 | 
					    @State private var isSearchGestureActive: Bool = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private let searchRevealDistance: CGFloat = 90
 | 
					    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.currentUserId = currentUserId
 | 
				
			||||||
        self._searchRevealProgress = searchRevealProgress
 | 
					        self._searchRevealProgress = searchRevealProgress
 | 
				
			||||||
 | 
					        self._searchText = searchText
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var body: some View {
 | 
					    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 {
 | 
					    private var searchBarGesture: some Gesture {
 | 
				
			||||||
        DragGesture(minimumDistance: 10, coordinateSpace: .local)
 | 
					        DragGesture(minimumDistance: 10, coordinateSpace: .local)
 | 
				
			||||||
            .onChanged { value in
 | 
					            .onChanged { value in
 | 
				
			||||||
@ -624,9 +600,10 @@ private struct ChatRowView: View {
 | 
				
			|||||||
struct ChatsTab_Previews: PreviewProvider {
 | 
					struct ChatsTab_Previews: PreviewProvider {
 | 
				
			||||||
    struct Wrapper: View {
 | 
					    struct Wrapper: View {
 | 
				
			||||||
        @State private var progress: CGFloat = 1
 | 
					        @State private var progress: CGFloat = 1
 | 
				
			||||||
 | 
					        @State private var searchText: String = ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var body: some View {
 | 
					        var body: some View {
 | 
				
			||||||
            ChatsTab(searchRevealProgress: $progress)
 | 
					            ChatsTab(searchRevealProgress: $progress, searchText: $searchText)
 | 
				
			||||||
                .environmentObject(ThemeManager())
 | 
					                .environmentObject(ThemeManager())
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -14,6 +14,7 @@ struct MainView: View {
 | 
				
			|||||||
    @State private var isSideMenuPresented = false
 | 
					    @State private var isSideMenuPresented = false
 | 
				
			||||||
    @State private var menuOffset: CGFloat = 0
 | 
					    @State private var menuOffset: CGFloat = 0
 | 
				
			||||||
    @State private var chatSearchRevealProgress: CGFloat = 0
 | 
					    @State private var chatSearchRevealProgress: CGFloat = 0
 | 
				
			||||||
 | 
					    @State private var chatSearchText: String = ""
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    private var tabTitle: String {
 | 
					    private var tabTitle: String {
 | 
				
			||||||
        switch selectedTab {
 | 
					        switch selectedTab {
 | 
				
			||||||
@ -40,19 +41,21 @@ struct MainView: View {
 | 
				
			|||||||
                        accounts: accounts,
 | 
					                        accounts: accounts,
 | 
				
			||||||
                        viewModel: viewModel,
 | 
					                        viewModel: viewModel,
 | 
				
			||||||
                        isSideMenuPresented: $isSideMenuPresented,
 | 
					                        isSideMenuPresented: $isSideMenuPresented,
 | 
				
			||||||
                        chatSearchRevealProgress: $chatSearchRevealProgress
 | 
					                        chatSearchRevealProgress: $chatSearchRevealProgress,
 | 
				
			||||||
 | 
					                        chatSearchText: $chatSearchText
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
                    
 | 
					                    
 | 
				
			||||||
                    ZStack {
 | 
					                    ZStack {
 | 
				
			||||||
                        NewHomeTab()
 | 
					                        NewHomeTab()
 | 
				
			||||||
                            .opacity(selectedTab == 0 ? 1 : 0)
 | 
					                            .opacity(selectedTab == 0 ? 1 : 0)
 | 
				
			||||||
                        
 | 
					
 | 
				
			||||||
                        ConceptTab()
 | 
					                        ConceptTab()
 | 
				
			||||||
                            .opacity(selectedTab == 1 ? 1 : 0)
 | 
					                            .opacity(selectedTab == 1 ? 1 : 0)
 | 
				
			||||||
                        
 | 
					
 | 
				
			||||||
                        ChatsTab(
 | 
					                        ChatsTab(
 | 
				
			||||||
                            currentUserId: viewModel.userId.isEmpty ? nil : viewModel.userId,
 | 
					                            currentUserId: viewModel.userId.isEmpty ? nil : viewModel.userId,
 | 
				
			||||||
                            searchRevealProgress: $chatSearchRevealProgress
 | 
					                            searchRevealProgress: $chatSearchRevealProgress,
 | 
				
			||||||
 | 
					                            searchText: $chatSearchText
 | 
				
			||||||
                        )
 | 
					                        )
 | 
				
			||||||
                            .opacity(selectedTab == 2 ? 1 : 0)
 | 
					                            .opacity(selectedTab == 2 ? 1 : 0)
 | 
				
			||||||
                            .allowsHitTesting(selectedTab == 2)
 | 
					                            .allowsHitTesting(selectedTab == 2)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user