|
|
@ -98,23 +98,34 @@ class KycForm1ViewController: UIViewController { |
|
|
|
var textfields: [UITextField] = [] |
|
|
|
var delegate: KYCForm1Delegate? |
|
|
|
var countries: [KeyValueModel]? |
|
|
|
var occupations: [Occupation]? |
|
|
|
var occupations: [KeyValueModel]? |
|
|
|
|
|
|
|
var kycModel: KycModel? { |
|
|
|
didSet { |
|
|
|
self.countries = kycModel?.nativeCountry |
|
|
|
self.occupations = kycModel?.occupation |
|
|
|
self.proviences = kycModel?.city |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var proviences: [KeyValueModel]? |
|
|
|
|
|
|
|
var selectedCountry: SendMoneyCountryViewModel? { |
|
|
|
didSet { |
|
|
|
self.countryTextField.text = selectedCountry?.name |
|
|
|
self.nativeCountryTextField.text = selectedCountry?.name |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var selectedProvience: KeyValueModel? { |
|
|
|
didSet { |
|
|
|
self.provinceTextField.text = selectedProvience?.text |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var selectedOccupation: Occupation? { |
|
|
|
var selectedOccupation: KeyValueModel? { |
|
|
|
didSet { |
|
|
|
self.occupationTextField.text = selectedOccupation?.title |
|
|
|
self.occupationTextField.text = selectedOccupation?.text |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -131,6 +142,12 @@ class KycForm1ViewController: UIViewController { |
|
|
|
|
|
|
|
@IBAction func save(_ sender: UIButton) { |
|
|
|
self.view.endEditing(true) |
|
|
|
createModelAndValidate() |
|
|
|
} |
|
|
|
|
|
|
|
// MARK: Other Functions |
|
|
|
|
|
|
|
private func createModelAndValidate() { |
|
|
|
self.kycForm1Model.firstName = self.firstNameTextField.text! |
|
|
|
self.kycForm1Model.middleName = self.middleNmaeTextField.text! |
|
|
|
self.kycForm1Model.lastName = self.lastNameTextField.text! |
|
|
@ -145,7 +162,6 @@ class KycForm1ViewController: UIViewController { |
|
|
|
validate() |
|
|
|
} |
|
|
|
|
|
|
|
// MARK: Other Functions |
|
|
|
|
|
|
|
private func setup() { |
|
|
|
// all setup should be done here |
|
|
@ -318,20 +334,25 @@ extension KycForm1ViewController: UITextFieldDelegate { |
|
|
|
case genderTextField: |
|
|
|
self.genderErrorLabel.isHidden = true |
|
|
|
genderTextField.layer.borderWidth = 0 |
|
|
|
self.view.endEditing(true) |
|
|
|
self.showGenderPicker() |
|
|
|
return false |
|
|
|
case nativeCountryTextField: |
|
|
|
self.nativeCountryErrorLabel.isHidden = true |
|
|
|
nativeCountryTextField.layer.borderWidth = 0 |
|
|
|
self.view.endEditing(true) |
|
|
|
self.showCountryPickerview() |
|
|
|
return false |
|
|
|
case provinceTextField: |
|
|
|
self.provinceErrorLabel.isHidden = true |
|
|
|
provinceTextField.layer.borderWidth = 0 |
|
|
|
self.view.endEditing(true) |
|
|
|
self.showProviencePickerview() |
|
|
|
return false |
|
|
|
case occupationTextField: |
|
|
|
self.occupationErrorLabel.isHidden = true |
|
|
|
occupationTextField.layer.borderWidth = 0 |
|
|
|
self.view.endEditing(true) |
|
|
|
self.showOccupationPickerView() |
|
|
|
return false |
|
|
|
default: |
|
|
@ -434,7 +455,7 @@ extension KycForm1ViewController { |
|
|
|
private func showOccupationPickerView() { |
|
|
|
let viewcontroller = self.getPickerViewController() |
|
|
|
let occupations = self.occupations ?? [] |
|
|
|
let names = occupations.compactMap({$0.title}) |
|
|
|
let names = occupations.compactMap({$0.text}) |
|
|
|
viewcontroller.data = names |
|
|
|
viewcontroller.type = PickerTitle.occupation |
|
|
|
viewcontroller.doneAction = self.occupationSelected |
|
|
@ -446,7 +467,26 @@ extension KycForm1ViewController { |
|
|
|
} |
|
|
|
|
|
|
|
func occupationSelected(occupations: [String]) { |
|
|
|
let _occupation = self.occupations?.filter({($0.title ?? "") == (occupations.first ?? "") }).first |
|
|
|
let _occupation = self.occupations?.filter({($0.text ?? "") == (occupations.first ?? "") }).first |
|
|
|
self.selectedOccupation = _occupation |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func showProviencePickerview() { |
|
|
|
let viewcontroller = self.getPickerViewController() |
|
|
|
let proviences = self.proviences |
|
|
|
let names = (proviences ?? []).compactMap({$0.text}) |
|
|
|
viewcontroller.data = names |
|
|
|
viewcontroller.type = PickerTitle.state |
|
|
|
viewcontroller.doneAction = self.provienceSelected |
|
|
|
self.present(viewcontroller, animated: true, completion: nil) |
|
|
|
} |
|
|
|
|
|
|
|
func provienceSelected(provience: [String]) { |
|
|
|
let _provience = (self.proviences ?? []).filter({ |
|
|
|
($0.text ?? "") == (provience.first ?? "") |
|
|
|
}) |
|
|
|
|
|
|
|
self.selectedProvience = _provience.first |
|
|
|
} |
|
|
|
} |