1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 06:10:32 +05:30
yattee/Apple TV/TrendingCountrySelectionView.swift
2021-06-28 12:43:07 +02:00

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)
}
}