Fix search on tvOS

This commit is contained in:
Arkadiusz Fal 2021-12-01 12:22:19 +01:00
parent 06f7391ad9
commit 1c61ad37a9

View File

@ -53,6 +53,7 @@ struct SearchView: View {
ZStack { ZStack {
results results
#if !os(tvOS)
if state.query.query != state.queryText, !state.queryText.isEmpty, !state.querySuggestions.collection.isEmpty { if state.query.query != state.queryText, !state.queryText.isEmpty, !state.querySuggestions.collection.isEmpty {
HStack { HStack {
Spacer() Spacer()
@ -61,6 +62,7 @@ struct SearchView: View {
.frame(maxWidth: 280) .frame(maxWidth: 280)
} }
} }
#endif
} }
#endif #endif
} }
@ -173,7 +175,14 @@ struct SearchView: View {
updateFavoriteItem() updateFavoriteItem()
} }
} }
#if !os(tvOS) #if os(tvOS)
.searchable(text: $state.queryText) {
ForEach(state.querySuggestions.collection, id: \.self) { suggestion in
Text(suggestion)
.searchCompletion(suggestion)
}
}
#else
.ignoresSafeArea(.keyboard, edges: .bottom) .ignoresSafeArea(.keyboard, edges: .bottom)
.navigationTitle("Search") .navigationTitle("Search")
#endif #endif