mirror of
https://github.com/yattee/yattee.git
synced 2024-12-15 23:00:32 +05:30
32 lines
831 B
Swift
32 lines
831 B
Swift
import SwiftUI
|
|
|
|
struct TrendingCountrySelectionView: View {
|
|
@Environment(\.presentationMode) private var presentationMode
|
|
@ObservedObject private var provider = TrendingCountriesProvider()
|
|
|
|
@State private var query: String = ""
|
|
@Binding var selectedCountry: Country
|
|
|
|
@Environment(\.dismiss) private var dismiss
|
|
|
|
var body: some View {
|
|
ScrollView(.vertical) {
|
|
ForEach(countries) { country in
|
|
Button(country.name) {
|
|
selectedCountry = country
|
|
presentationMode.wrappedValue.dismiss()
|
|
}
|
|
}
|
|
.frame(width: 800)
|
|
}
|
|
.searchable(text: $query)
|
|
.background(.thinMaterial)
|
|
}
|
|
|
|
var countries: [Country] {
|
|
provider.load(query)
|
|
|
|
return provider.countries
|
|
}
|
|
}
|