mirror of
https://github.com/yattee/yattee.git
synced 2026-01-02 01:42:31 +00:00
Use Siesta framework
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user