Skip to content

Commit

Permalink
Merge pull request #106 from kizitonwose/dev
Browse files Browse the repository at this point in the history
Release 3.0.9
  • Loading branch information
kizitonwose authored Feb 22, 2020
2 parents 71a427a + 1ea8009 commit 544786e
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CountryPickerView.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |spec|

spec.name = "CountryPickerView"
spec.version = "3.0.8"
spec.version = "3.0.9"
spec.summary = "A simple, customizable view for selecting countries in iOS apps."
spec.homepage = "https://github.com/kizitonwose/CountryPickerView"
spec.license = "MIT"
Expand Down
36 changes: 27 additions & 9 deletions CountryPickerView/CountryPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,33 @@ 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() }
didSet {
if showCountryNameInView && showCountryCodeInView {
showCountryNameInView = false
} else {
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 {
if showCountryCodeInView && showCountryNameInView {
showCountryCodeInView = false
} else {
setup()
}
}
}

/// Change the font of phone code
public var font = UIFont.systemFont(ofSize: 17.0) {
didSet { setup() }
Expand Down Expand Up @@ -106,13 +123,14 @@ public class CountryPickerView: NibView {
flagImageView.image = selectedCountry.flag
countryDetailsLabel.font = font
countryDetailsLabel.textColor = textColor
if showPhoneCodeInView && showCountryCodeInView {
if showCountryCodeInView && showPhoneCodeInView {
countryDetailsLabel.text = "(\(selectedCountry.code)) \(selectedCountry.phoneCode)"
return
}

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

0 comments on commit 544786e

Please sign in to comment.