2021-06-17 10:02:39 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct TrendingCountrySelectionView: View {
|
|
|
|
@Environment(\.presentationMode) private var presentationMode
|
2021-06-19 20:17:48 +00:00
|
|
|
@ObservedObject private var provider = TrendingCountriesProvider()
|
2021-06-17 10:02:39 +00:00
|
|
|
|
|
|
|
@State private var query: String = ""
|
|
|
|
@Binding var selectedCountry: Country
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
ZStack {
|
|
|
|
VisualEffectView(effect: UIBlurEffect(style: .dark))
|
|
|
|
|
|
|
|
ScrollView(.vertical) {
|
|
|
|
ForEach(countries) { country in
|
|
|
|
Button(country.name) {
|
|
|
|
selectedCountry = country
|
|
|
|
presentationMode.wrappedValue.dismiss()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.frame(width: 800)
|
|
|
|
}
|
|
|
|
.searchable(text: $query)
|
|
|
|
}
|
|
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
|
.edgesIgnoringSafeArea(.all)
|
|
|
|
}
|
|
|
|
|
|
|
|
var countries: [Country] {
|
|
|
|
provider.load(query)
|
|
|
|
|
|
|
|
return provider.countries
|
|
|
|
}
|
|
|
|
}
|