修改搜索页面在右滑动时候的问题

This commit is contained in:
anlicheng 2025-07-01 17:48:27 +08:00
parent 6603132568
commit e90d164f5d

View File

@ -25,46 +25,40 @@ struct SearchView: View {
@State private var isFocused: Bool = true @State private var isFocused: Bool = true
var body: some View { var body: some View {
VStack(spacing: 0) { ScrollView(.vertical, showsIndicators: false) {
Color.clear LazyVStack(alignment: .center, spacing: 10) {
.frame(height: 8) ForEach(searchModel.dramaGroups, id: \.group_id) { group in
.background( SearchDramaGroupView(group: group)
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)
}
}
} }
.frame(maxWidth: .infinity, maxHeight: .infinity) }
.onTapGesture { .padding(.top, 8)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(
GestureObserver {
//
if isFocused {
isFocused = false isFocused = false
} }
.simultaneousGesture( } onGestureCancelled: {
DragGesture().onChanged{ _ in if !isFocused && !showSearchResult {
isFocused = false isFocused = true
} }
)
} }
.overlay(alignment: .center) { )
Text("什么都没有找到") .onTapGesture {
.font(.system(size: 18)) isFocused = false
.foregroundColor(Color(hex: "#333333")) }
.opacity(showSearchResult && searchModel.dramaGroups.isEmpty ? 1 : 0) .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("") .navigationTitle("")
.toolbar { .toolbar {