Use Siesta framework

This commit is contained in:
Arkadiusz Fal
2021-06-28 12:43:07 +02:00
parent 8d89d7cc08
commit b840974f08
26 changed files with 365 additions and 411 deletions

View File

@@ -1,31 +1,27 @@
import SwiftUI
struct TrendingCountrySelectionView: View {
@Environment(\.presentationMode) private var presentationMode
@ObservedObject private var provider = TrendingCountriesProvider()
@State private var query: String = ""
@ObservedObject private var store = Store<[Country]>()
@Binding var selectedCountry: Country
@Environment(\.dismiss) private var dismiss
var body: some View {
ScrollView(.vertical) {
ForEach(countries) { country in
ForEach(store.collection) { country in
Button(country.name) {
selectedCountry = country
presentationMode.wrappedValue.dismiss()
dismiss()
}
}
.frame(width: 800)
}
.searchable(text: $query)
.searchable(text: $query, prompt: Text("Country name or two letter code"))
.onChange(of: query) { newQuery in
store.replace(Country.search(newQuery))
}
.background(.thinMaterial)
}
var countries: [Country] {
provider.load(query)
return provider.countries
}
}