|
@ -23,6 +23,11 @@ class kycForm1Model { |
|
|
var occupation = "" |
|
|
var occupation = "" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class Occupation { |
|
|
|
|
|
var title: String? |
|
|
|
|
|
var id: String? |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
struct KycForm1FieldKeys { |
|
|
struct KycForm1FieldKeys { |
|
|
static let firstName = "firstName" |
|
|
static let firstName = "firstName" |
|
|
static let middleName = "middleName" |
|
|
static let middleName = "middleName" |
|
@ -42,6 +47,7 @@ class KycForm1ViewController: UIViewController { |
|
|
struct Constants { |
|
|
struct Constants { |
|
|
static let segmentBackgroundViewColor = UIColor.init(hex: "E7EDF2") |
|
|
static let segmentBackgroundViewColor = UIColor.init(hex: "E7EDF2") |
|
|
static let stateRedColor = UIColor.init(hex: "#EC1C24") |
|
|
static let stateRedColor = UIColor.init(hex: "#EC1C24") |
|
|
|
|
|
static let clearColor = UIColor.clear |
|
|
static let male = "Male" |
|
|
static let male = "Male" |
|
|
static let female = "Female" |
|
|
static let female = "Female" |
|
|
static let other = "Other" |
|
|
static let other = "Other" |
|
@ -89,11 +95,28 @@ class KycForm1ViewController: UIViewController { |
|
|
var errorLabels: [UILabel] = [] |
|
|
var errorLabels: [UILabel] = [] |
|
|
var textfields: [UITextField] = [] |
|
|
var textfields: [UITextField] = [] |
|
|
var delegate: KYCForm1Delegate? |
|
|
var delegate: KYCForm1Delegate? |
|
|
|
|
|
var countries: [SendMoneyCountryViewModel]? |
|
|
|
|
|
var occupations: [Occupation]? |
|
|
|
|
|
|
|
|
|
|
|
var selectedCountry: SendMoneyCountryViewModel? { |
|
|
|
|
|
didSet { |
|
|
|
|
|
self.countryTextField.text = selectedCountry?.name |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var selectedOccupation: Occupation? { |
|
|
|
|
|
didSet { |
|
|
|
|
|
self.occupationTextField.text = selectedOccupation?.title |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// MARK: VC's Life cycle |
|
|
// MARK: VC's Life cycle |
|
|
|
|
|
|
|
|
override func viewDidLoad() { |
|
|
override func viewDidLoad() { |
|
|
super.viewDidLoad() |
|
|
super.viewDidLoad() |
|
|
self.setup() |
|
|
self.setup() |
|
|
|
|
|
presenter?.viewIsReady() |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// MARK: IBActions |
|
|
// MARK: IBActions |
|
@ -152,34 +175,6 @@ class KycForm1ViewController: UIViewController { |
|
|
self.dobTextField.text = dateFormatter.string(from: sender.date) |
|
|
self.dobTextField.text = dateFormatter.string(from: sender.date) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func showGenderPicker() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let alertcontroller = UIAlertController.init(title: "Gender", message: nil, preferredStyle: .actionSheet) |
|
|
|
|
|
alertcontroller.view.tintColor = UIColor.init(hex: "#7b7a7a") |
|
|
|
|
|
let maleAction = UIAlertAction(title: Constants.male, style: .default, handler: { _ in |
|
|
|
|
|
self.genderTextField.text = Constants.male |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
let femaleAction = UIAlertAction(title: Constants.female, style: .default, handler: { _ in |
|
|
|
|
|
self.genderTextField.text = Constants.female |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
let otherAction = UIAlertAction(title: Constants.other, style: .default, handler: { _ in |
|
|
|
|
|
self.genderTextField.text = Constants.other |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cancelAction = UIAlertAction(title: Constants.cancelTitleString, style: .cancel, handler: nil) |
|
|
|
|
|
|
|
|
|
|
|
alertcontroller.addAction(maleAction) |
|
|
|
|
|
alertcontroller.addAction(femaleAction) |
|
|
|
|
|
alertcontroller.addAction(otherAction) |
|
|
|
|
|
alertcontroller.addAction(cancelAction) |
|
|
|
|
|
self.present(alertcontroller, animated: true, completion: nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func validate() { |
|
|
private func validate() { |
|
|
self.presenter?.validate(model: self.kycModel) |
|
|
self.presenter?.validate(model: self.kycModel) |
|
|
} |
|
|
} |
|
@ -232,7 +227,8 @@ class KycForm1ViewController: UIViewController { |
|
|
private func showBorder(textfield :UITextField?) { |
|
|
private func showBorder(textfield :UITextField?) { |
|
|
guard let textfield = textfield else {return} |
|
|
guard let textfield = textfield else {return} |
|
|
textfield.layer.borderColor = Constants.stateRedColor.cgColor |
|
|
textfield.layer.borderColor = Constants.stateRedColor.cgColor |
|
|
textfield.layer.borderWidth = 1 |
|
|
|
|
|
|
|
|
textfield.layer.borderWidth = 0.3 |
|
|
|
|
|
textfield.layer.addShadow(with: Constants.stateRedColor) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private func show( error: String, label: UILabel?) { |
|
|
private func show( error: String, label: UILabel?) { |
|
@ -270,6 +266,7 @@ extension KycForm1ViewController: IndicatorInfoProvider { |
|
|
|
|
|
|
|
|
extension KycForm1ViewController: UITextFieldDelegate { |
|
|
extension KycForm1ViewController: UITextFieldDelegate { |
|
|
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { |
|
|
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool { |
|
|
|
|
|
textField.layer.addShadow(with: Constants.clearColor) |
|
|
switch textField { |
|
|
switch textField { |
|
|
case genderTextField: |
|
|
case genderTextField: |
|
|
self.genderErrorLabel.isHidden = true |
|
|
self.genderErrorLabel.isHidden = true |
|
@ -279,6 +276,7 @@ extension KycForm1ViewController: UITextFieldDelegate { |
|
|
case nativeCountryTextField: |
|
|
case nativeCountryTextField: |
|
|
self.nativeCountryErrorLabel.isHidden = true |
|
|
self.nativeCountryErrorLabel.isHidden = true |
|
|
nativeCountryTextField.layer.borderWidth = 0 |
|
|
nativeCountryTextField.layer.borderWidth = 0 |
|
|
|
|
|
self.showCountryPickerview() |
|
|
return false |
|
|
return false |
|
|
case provinceTextField: |
|
|
case provinceTextField: |
|
|
self.provinceErrorLabel.isHidden = true |
|
|
self.provinceErrorLabel.isHidden = true |
|
@ -287,6 +285,8 @@ extension KycForm1ViewController: UITextFieldDelegate { |
|
|
case occupationTextField: |
|
|
case occupationTextField: |
|
|
self.occupationErrorLabel.isHidden = true |
|
|
self.occupationErrorLabel.isHidden = true |
|
|
occupationTextField.layer.borderWidth = 0 |
|
|
occupationTextField.layer.borderWidth = 0 |
|
|
|
|
|
|
|
|
|
|
|
self.showOccupationPickerView() |
|
|
return false |
|
|
return false |
|
|
default: |
|
|
default: |
|
|
return true |
|
|
return true |
|
@ -295,6 +295,7 @@ extension KycForm1ViewController: UITextFieldDelegate { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func textFieldDidBeginEditing(_ textField: UITextField) { |
|
|
func textFieldDidBeginEditing(_ textField: UITextField) { |
|
|
|
|
|
textField.layer.addShadow(with: Constants.clearColor) |
|
|
switch textField { |
|
|
switch textField { |
|
|
case firstNameTextField: |
|
|
case firstNameTextField: |
|
|
self.firstNameErrorLabel.isHidden = true |
|
|
self.firstNameErrorLabel.isHidden = true |
|
@ -336,3 +337,64 @@ extension KycForm1ViewController: UITextFieldDelegate { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extension KycForm1ViewController { |
|
|
|
|
|
private func showCountryPickerview() { |
|
|
|
|
|
let viewcontroller = UIStoryboard.init(name: "CountryPicker", bundle: nil).instantiateViewController(withIdentifier: "CountryPickerViewController") as! CountryPickerViewController |
|
|
|
|
|
viewcontroller.data = self.countries ?? [] |
|
|
|
|
|
viewcontroller.doneAction = self.countrySelected |
|
|
|
|
|
viewcontroller.defaultSelectedData = [self.selectedCountry] |
|
|
|
|
|
viewcontroller.type = PickerTitle.country |
|
|
|
|
|
self.present(viewcontroller, animated: true, completion: nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func countrySelected(models: [SendMoneyCountryViewModel]) { |
|
|
|
|
|
self.selectedCountry = models.first |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private func showGenderPicker() { |
|
|
|
|
|
let alertcontroller = UIAlertController.init(title: "Gender", message: nil, preferredStyle: .actionSheet) |
|
|
|
|
|
alertcontroller.view.tintColor = UIColor.init(hex: "#7b7a7a") |
|
|
|
|
|
let maleAction = UIAlertAction(title: Constants.male, style: .default, handler: { _ in |
|
|
|
|
|
self.genderTextField.text = Constants.male |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
let femaleAction = UIAlertAction(title: Constants.female, style: .default, handler: { _ in |
|
|
|
|
|
self.genderTextField.text = Constants.female |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
let otherAction = UIAlertAction(title: Constants.other, style: .default, handler: { _ in |
|
|
|
|
|
self.genderTextField.text = Constants.other |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cancelAction = UIAlertAction(title: Constants.cancelTitleString, style: .cancel, handler: nil) |
|
|
|
|
|
|
|
|
|
|
|
alertcontroller.addAction(maleAction) |
|
|
|
|
|
alertcontroller.addAction(femaleAction) |
|
|
|
|
|
alertcontroller.addAction(otherAction) |
|
|
|
|
|
alertcontroller.addAction(cancelAction) |
|
|
|
|
|
self.present(alertcontroller, animated: true, completion: nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func showOccupationPickerView() { |
|
|
|
|
|
let viewcontroller = self.getPickerViewController() |
|
|
|
|
|
let occupations = self.occupations ?? [] |
|
|
|
|
|
let names = occupations.compactMap({$0.title}) |
|
|
|
|
|
viewcontroller.data = names |
|
|
|
|
|
viewcontroller.type = PickerTitle.occupation |
|
|
|
|
|
viewcontroller.doneAction = self.occupationSelected |
|
|
|
|
|
self.present(viewcontroller, animated: true, completion: nil) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private func getPickerViewController()-> ItemsPickerViewController { |
|
|
|
|
|
return UIStoryboard.init(name: "ItemsPicker", bundle: nil).instantiateViewController(withIdentifier: "ItemsPickerViewController") as! ItemsPickerViewController |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func occupationSelected(occupations: [String]) { |
|
|
|
|
|
let _occupation = self.occupations?.filter({($0.title ?? "") == (occupations.first ?? "") }).first |
|
|
|
|
|
self.selectedOccupation = _occupation |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|