Skip to content

Commit

Permalink
Merge pull request #105 from teambulb/add-country-name
Browse files Browse the repository at this point in the history
Add country name to view
  • Loading branch information
kizitonwose authored Feb 22, 2020
2 parents 71a427a + 79a2d4e commit c9b436b
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 37 deletions.
15 changes: 10 additions & 5 deletions CountryPickerView/CountryPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ public class CountryPickerView: NibView {
}
@IBOutlet public weak var countryDetailsLabel: UILabel!

// Show/Hide the country code on the view.
/// Show/Hide the country code on the view.
public var showCountryCodeInView = true {
didSet { setup() }
}

// Show/Hide the phone code on the view.
/// Show/Hide the phone code on the view.
public var showPhoneCodeInView = true {
didSet { setup() }
}

/// Show/Hide the country name on the view.
public var showCountryNameInView = false {
didSet { setup() }
}

/// Change the font of phone code
public var font = UIFont.systemFont(ofSize: 17.0) {
didSet { setup() }
Expand Down Expand Up @@ -109,10 +114,10 @@ public class CountryPickerView: NibView {
if showPhoneCodeInView && showCountryCodeInView {
countryDetailsLabel.text = "(\(selectedCountry.code)) \(selectedCountry.phoneCode)"
return
}

if showCountryCodeInView || showPhoneCodeInView {
} else if showCountryCodeInView || showPhoneCodeInView {
countryDetailsLabel.text = showCountryCodeInView ? selectedCountry.code : selectedCountry.phoneCode
} else if showCountryNameInView {
countryDetailsLabel.text = selectedCountry.localizedName()
} else {
countryDetailsLabel.text = nil
}
Expand Down
Loading

0 comments on commit c9b436b

Please sign in to comment.