add dont close search
This commit is contained in:
		
							parent
							
								
									8c03574e6a
								
							
						
					
					
						commit
						21d120cb3d
					
				@ -113,10 +113,16 @@ struct TopBarView: View {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        .background(Color(UIColor.systemBackground))
 | 
					        .background(Color(UIColor.systemBackground))
 | 
				
			||||||
        .onChange(of: isChatsTab) { isChats in
 | 
					        .onChange(of: isChatsTab) { isChats in
 | 
				
			||||||
 | 
					            let hasSearchText = !chatSearchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
 | 
				
			||||||
            if !isChats {
 | 
					            if !isChats {
 | 
				
			||||||
 | 
					                guard !hasSearchText else { return }
 | 
				
			||||||
                withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
 | 
					                withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
 | 
				
			||||||
                    chatSearchRevealProgress = 0
 | 
					                    chatSearchRevealProgress = 0
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					            } else if hasSearchText {
 | 
				
			||||||
 | 
					                withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
 | 
				
			||||||
 | 
					                    chatSearchRevealProgress = 1
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -46,6 +46,12 @@ struct ChatsTab: View {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            .onChange(of: searchText) { newValue in
 | 
					            .onChange(of: searchText) { newValue in
 | 
				
			||||||
                handleSearchQueryChange(newValue)
 | 
					                handleSearchQueryChange(newValue)
 | 
				
			||||||
 | 
					                let trimmed = newValue.trimmingCharacters(in: .whitespacesAndNewlines)
 | 
				
			||||||
 | 
					                if !trimmed.isEmpty && searchRevealProgress < 1 {
 | 
				
			||||||
 | 
					                    withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
 | 
				
			||||||
 | 
					                        searchRevealProgress = 1
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            .onDisappear {
 | 
					            .onDisappear {
 | 
				
			||||||
                globalSearchTask?.cancel()
 | 
					                globalSearchTask?.cancel()
 | 
				
			||||||
@ -156,12 +162,23 @@ struct ChatsTab: View {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                let delta = verticalTranslation / searchRevealDistance
 | 
					                let delta = verticalTranslation / searchRevealDistance
 | 
				
			||||||
                let newProgress = searchDragStartProgress + delta
 | 
					                let newProgress = searchDragStartProgress + delta
 | 
				
			||||||
 | 
					                if isSearching && newProgress < 1 {
 | 
				
			||||||
 | 
					                    searchRevealProgress = 1
 | 
				
			||||||
 | 
					                    return
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                searchRevealProgress = max(0, min(1, newProgress))
 | 
					                searchRevealProgress = max(0, min(1, newProgress))
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            .onEnded { _ in
 | 
					            .onEnded { _ in
 | 
				
			||||||
                guard isSearchGestureActive else { return }
 | 
					                guard isSearchGestureActive else { return }
 | 
				
			||||||
                isSearchGestureActive = false
 | 
					                isSearchGestureActive = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if isSearching {
 | 
				
			||||||
 | 
					                    withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
 | 
				
			||||||
 | 
					                        searchRevealProgress = 1
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                    return
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                let target: CGFloat = searchRevealProgress > 0.5 ? 1 : 0
 | 
					                let target: CGFloat = searchRevealProgress > 0.5 ? 1 : 0
 | 
				
			||||||
                withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
 | 
					                withAnimation(.spring(response: 0.35, dampingFraction: 0.75)) {
 | 
				
			||||||
                    searchRevealProgress = target
 | 
					                    searchRevealProgress = target
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user