mobven / CountryPicker

Country Picker with unicode flags and country codes.
MIT License
66 stars 19 forks source link

UIViewRepresentable #2

Closed dardoc-Tech closed 2 years ago

dardoc-Tech commented 3 years ago

struct CountryPicker : UIViewControllerRepresentable{

typealias UIViewControllerType = CountryPickerViewController

let countryPicker = CountryPickerViewController() func makeUIViewController(context: Context) -> CountryPickerViewController {

countryPicker.selectedCountry = "TR"
return countryPicker

}

func updateUIViewController(_ uiViewController: CountryPickerViewController, context: Context) {

} func makeCoordinator() -> Coordinator { return Coordinator(countryPicker) }

class Coordinator : NSObject , CountryPickerDelegate{

init(_ parent : CountryPickerViewController) {
    super.init()
    parent.delegate = self
}

func countryPicker(didSelect country: Country) {
    print(country)
}

} }