From e7549803b6fe067872c9badfbc41cb6d3b64bf9b Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 30 Jun 2025 18:49:47 +0800 Subject: [PATCH] fix --- dimensionhub/Views/Search/SearchView.swift | 53 ++++++++++------------ 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/dimensionhub/Views/Search/SearchView.swift b/dimensionhub/Views/Search/SearchView.swift index 88da06b..a74ae83 100644 --- a/dimensionhub/Views/Search/SearchView.swift +++ b/dimensionhub/Views/Search/SearchView.swift @@ -25,40 +25,35 @@ struct SearchView: View { @State private var isFocused: Bool = true var body: some View { - VStack(spacing: 12) { - if showSearchResult { - if searchModel.dramaGroups.isEmpty { - Spacer() - Text("什么都没有找到") - .font(.system(size: 18)) - .foregroundColor(Color(hex: "#333333")) - Spacer() - } else { - ScrollView(.vertical, showsIndicators: false) { - LazyVStack(alignment: .center, spacing: 10) { - ForEach(searchModel.dramaGroups, id: \.group_id) { group in - SearchDramaGroupView(group: group) - } + VStack(spacing: 0) { + Color.clear + .frame(height: 8) + + VStack { + ScrollView(.vertical, showsIndicators: false) { + LazyVStack(alignment: .center, spacing: 10) { + ForEach(searchModel.dramaGroups, id: \.group_id) { group in + SearchDramaGroupView(group: group) } - .padding(.top, 8) } - .onTapGesture { + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .onTapGesture { + isFocused = false + } + .simultaneousGesture( + DragGesture().onChanged{ _ in isFocused = false } - .simultaneousGesture( - DragGesture().onChanged{ _ in - isFocused = false - } - ) - } - } else { - // 预留用来显示热搜词 - Spacer() + ) + } + .overlay(alignment: .center) { + Text("什么都没有找到") + .font(.system(size: 18)) + .foregroundColor(Color(hex: "#333333")) + .opacity(showSearchResult && searchModel.dramaGroups.isEmpty ? 1 : 0) } - } - .padding(.top, 10) - .background(Color(.systemBackground)) .navigationTitle("") .toolbar { ToolbarItem(placement: .principal) { @@ -69,8 +64,6 @@ struct SearchView: View { .id(toolbarID) } } - .padding(.horizontal, 12) - .ignoresSafeArea(.keyboard, edges: .bottom) // 避免键盘遮挡 .onAppear { toolbarID = UUID() }