Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support list mode for Objective-C #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/FPNCountry.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit

public struct FPNCountry: Equatable {
public class FPNCountry: NSObject {

public var code: FPNCountryCode
public var name: String
Expand Down
12 changes: 6 additions & 6 deletions Sources/FPNCountryListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

import UIKit

open class FPNCountryListViewController: UITableViewController, UISearchResultsUpdating, UISearchControllerDelegate {
open class FPNCountryListViewController: UITableViewController, UISearchResultsUpdating, UISearchControllerDelegate {

open var repository: FPNCountryRepository?
open var showCountryPhoneCode: Bool = true
open var searchController: UISearchController = UISearchController(searchResultsController: nil)
open var didSelect: ((FPNCountry) -> Void)?
@objc open var repository: FPNCountryRepository?
@objc open var showCountryPhoneCode: Bool = true
@objc open var searchController: UISearchController = UISearchController(searchResultsController: nil)
@objc open var didSelect: ((FPNCountry) -> Void)?

var results: [FPNCountry]?

Expand All @@ -25,7 +25,7 @@ open class FPNCountryListViewController: UITableViewController, UISearchResultsU
initSearchBarController()
}

open func setup(repository: FPNCountryRepository) {
@objc open func setup(repository: FPNCountryRepository) {
self.repository = repository
}

Expand Down
8 changes: 5 additions & 3 deletions Sources/FPNCountryRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import Foundation

open class FPNCountryRepository {
open class FPNCountryRepository : NSObject {

open var locale: Locale
open var locale: Locale
open var countries: [FPNCountry] = []

public init(locale: Locale = Locale.current) {
self.locale = locale
self.locale = locale

super.init()

countries = getAllCountries()
}
Expand Down
10 changes: 8 additions & 2 deletions Sources/FPNTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class FPNTextField: UITextField {
private var nbPhoneNumber: NBPhoneNumber?
private var formatter: NBAsYouTypeFormatter?

open var flagButton: UIButton = UIButton()
@objc open var flagButton: UIButton = UIButton()

open override var font: UIFont? {
didSet {
Expand All @@ -59,7 +59,7 @@ open class FPNTextField: UITextField {
}
}

open var countryRepository = FPNCountryRepository()
@objc open var countryRepository = FPNCountryRepository()

open var selectedCountry: FPNCountry? {
didSet {
Expand Down Expand Up @@ -281,6 +281,12 @@ open class FPNTextField: UITextField {
setFlag(countryCode: countryCode)
}
}

/// Set the country image according to country.code
@objc open func setFlag(country: FPNCountry) {
setFlag(countryCode: country.code)
}


/// Set the country list excluding the provided countries
open func setCountries(excluding countries: [FPNCountryCode]) {
Expand Down