mirror of
https://github.com/yattee/yattee.git
synced 2024-12-15 14:50:32 +05:30
28 lines
782 B
Swift
28 lines
782 B
Swift
import SwiftUI
|
|
|
|
struct TrendingCountrySelectionView: View {
|
|
@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(store.collection) { country in
|
|
Button(country.name) {
|
|
selectedCountry = country
|
|
dismiss()
|
|
}
|
|
}
|
|
.frame(width: 800)
|
|
}
|
|
.searchable(text: $query, prompt: Text("Country name or two letter code"))
|
|
.onChange(of: query) { newQuery in
|
|
store.replace(Country.search(newQuery))
|
|
}
|
|
.background(.thinMaterial)
|
|
}
|
|
}
|