1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-15 23:00:32 +05:30
yattee/Apple TV/TrendingCountrySelectionView.swift

32 lines
831 B
Swift
Raw Normal View History

2021-06-17 15:32:39 +05:30
import SwiftUI
struct TrendingCountrySelectionView: View {
@Environment(\.presentationMode) private var presentationMode
2021-06-20 01:47:48 +05:30
@ObservedObject private var provider = TrendingCountriesProvider()
2021-06-17 15:32:39 +05:30
@State private var query: String = ""
@Binding var selectedCountry: Country
2021-06-27 04:59:55 +05:30
@Environment(\.dismiss) private var dismiss
2021-06-17 15:32:39 +05:30
2021-06-27 04:59:55 +05:30
var body: some View {
ScrollView(.vertical) {
ForEach(countries) { country in
Button(country.name) {
selectedCountry = country
presentationMode.wrappedValue.dismiss()
2021-06-17 15:32:39 +05:30
}
}
2021-06-27 04:59:55 +05:30
.frame(width: 800)
2021-06-17 15:32:39 +05:30
}
2021-06-27 04:59:55 +05:30
.searchable(text: $query)
.background(.thinMaterial)
2021-06-17 15:32:39 +05:30
}
var countries: [Country] {
provider.load(query)
return provider.countries
}
}