From e90d164f5de1a13ecbe0b9e32a103aeda48d1975 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Tue, 1 Jul 2025 17:48:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=90=9C=E7=B4=A2=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=9C=A8=E5=8F=B3=E6=BB=91=E5=8A=A8=E6=97=B6=E5=80=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dimensionhub/Views/Search/SearchView.swift | 64 ++++++++++------------ 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/dimensionhub/Views/Search/SearchView.swift b/dimensionhub/Views/Search/SearchView.swift index 8833231..4166896 100644 --- a/dimensionhub/Views/Search/SearchView.swift +++ b/dimensionhub/Views/Search/SearchView.swift @@ -25,46 +25,40 @@ struct SearchView: View { @State private var isFocused: Bool = true var body: some View { - VStack(spacing: 0) { - Color.clear - .frame(height: 8) - .background( - GestureObserver { - // 当检测到系统返回手势时调用 - if isFocused { - isFocused = false - } - } onGestureCancelled: { - if !isFocused && !showSearchResult { - isFocused = true - } - } - ) - - VStack { - ScrollView(.vertical, showsIndicators: false) { - LazyVStack(alignment: .center, spacing: 10) { - ForEach(searchModel.dramaGroups, id: \.group_id) { group in - SearchDramaGroupView(group: group) - } - } + ScrollView(.vertical, showsIndicators: false) { + LazyVStack(alignment: .center, spacing: 10) { + ForEach(searchModel.dramaGroups, id: \.group_id) { group in + SearchDramaGroupView(group: group) } - .frame(maxWidth: .infinity, maxHeight: .infinity) - .onTapGesture { + } + .padding(.top, 8) + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background( + GestureObserver { + // 当检测到系统返回手势时调用 + if isFocused { isFocused = false } - .simultaneousGesture( - DragGesture().onChanged{ _ in - isFocused = false - } - ) + } onGestureCancelled: { + if !isFocused && !showSearchResult { + isFocused = true + } } - .overlay(alignment: .center) { - Text("什么都没有找到") - .font(.system(size: 18)) - .foregroundColor(Color(hex: "#333333")) - .opacity(showSearchResult && searchModel.dramaGroups.isEmpty ? 1 : 0) + ) + .onTapGesture { + isFocused = false + } + .simultaneousGesture( + DragGesture().onChanged{ _ in + isFocused = false } + ) + .overlay(alignment: .center) { + Text("什么都没有找到") + .font(.system(size: 18)) + .foregroundColor(Color(hex: "#333333")) + .opacity(showSearchResult && searchModel.dramaGroups.isEmpty ? 1 : 0) } .navigationTitle("") .toolbar {