Browse Source

moved to next page after validation only if the continue button was tapped

pull/1/head
gme_2 6 years ago
parent
commit
4a47d0de34
  1. 5
      GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift
  2. 17
      GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift
  3. 29
      GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift

5
GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift

@ -56,6 +56,10 @@ class KycViewController: ButtonBarPagerTabStripViewController {
var kycModel: KycModel? var kycModel: KycModel?
var presenter: KycModuleInterface? var presenter: KycModuleInterface?
var isForm1Valid = false
var isForm2Valid = false
var isForm3Valid = false
// MARK: VC's Life cycle // MARK: VC's Life cycle
@ -117,6 +121,7 @@ class KycViewController: ButtonBarPagerTabStripViewController {
// MARK: KycViewInterface // MARK: KycViewInterface
extension KycViewController: KycViewInterface { extension KycViewController: KycViewInterface {
func show(resutl: (isValid: Bool, errorsDick: [String : String])) { func show(resutl: (isValid: Bool, errorsDick: [String : String])) {
self.isForm1Valid = resutl.isValid
if let viewcontroller = self.form1 as? KycForm1ViewController { if let viewcontroller = self.form1 as? KycForm1ViewController {
viewcontroller.show(result: (doesNotSucks: resutl.isValid , errorsDick:resutl.errorsDick )) viewcontroller.show(result: (doesNotSucks: resutl.isValid , errorsDick:resutl.errorsDick ))
} }

17
GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift

@ -88,7 +88,7 @@ class KycForm1ViewController: UIViewController {
var presenter: KycForm1ModuleInterface? var presenter: KycForm1ModuleInterface?
var kycForm1Model: KycForm1Model = KycForm1Model() var kycForm1Model: KycForm1Model = KycForm1Model()
var continueActionInitiated = false
let datePicker = UIDatePicker() let datePicker = UIDatePicker()
var errorTextFieldDict: [String: UITextField] = [:] var errorTextFieldDict: [String: UITextField] = [:]
@ -140,15 +140,16 @@ class KycForm1ViewController: UIViewController {
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
createModel()
self.continueActionInitiated = false
self.validate() self.validate()
} }
// MARK: IBActions // MARK: IBActions
@IBAction func save(_ sender: UIButton) { @IBAction func save(_ sender: UIButton) {
self.view.endEditing(true) self.view.endEditing(true)
createModel()
self.continueActionInitiated = true
validate() validate()
} }
@ -207,6 +208,7 @@ class KycForm1ViewController: UIViewController {
} }
private func validate() { private func validate() {
self.createModel()
self.delegate?.validate(model: self.kycForm1Model) self.delegate?.validate(model: self.kycForm1Model)
} }
@ -288,9 +290,14 @@ extension KycForm1ViewController: KycForm1ViewInterface {
// todo remove this from this viper flow. its now in parent // todo remove this from this viper flow. its now in parent
func show(result: (doesNotSucks: Bool, errorsDick: [String : String])) { func show(result: (doesNotSucks: Bool, errorsDick: [String : String])) {
var position = 11 var position = 11
var result = result
result.doesNotSucks = true
if result.doesNotSucks { // if isValid if result.doesNotSucks { // if isValid
// its is not valid, lets go to security page
self.delegate?._continue(model: self.kycForm1Model)
// its is not valid, lets go to security page only if continue button was tapped
if self.continueActionInitiated {
self.delegate?._continue(model: self.kycForm1Model)
}
}else { }else {
result.errorsDick.forEach({ result.errorsDick.forEach({
let label = errorLabelsDict[$0.key] let label = errorLabelsDict[$0.key]

29
GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift

@ -11,7 +11,12 @@ import XLPagerTabStrip
class KycForm2Model { class KycForm2Model {
var bank = ""
var accountNumber = ""
var verificationId = ""
var verificationIdNumber = ""
var expiryDate = ""
var sourceOfFund = ""
} }
struct KycForm2FieldKeys { struct KycForm2FieldKeys {
@ -76,18 +81,36 @@ class KycForm2ViewController: UIViewController {
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
validate()
} }
// MARK: IBActions // MARK: IBActions
@IBAction func _continue(_ sender: UIButton) { @IBAction func _continue(_ sender: UIButton) {
validate()
} }
// MARK: Other Functions // MARK: Other Functions
private func createModel() {
self.kycForm2Model.bank = self.bankTextField.text!
self.kycForm2Model.accountNumber = self.accountNumberTextField.text!
self.kycForm2Model.verificationId = self.verificationIdTextField.text!
self.kycForm2Model.verificationIdNumber = self.verificationIdTextField.text!
self.kycForm2Model.expiryDate = self.expiryDateTextField.text!
self.kycForm2Model.sourceOfFund = self.sourceOfFundTextField.text!
}
private func setup() { private func setup() {
// all setup should be done here // all setup should be done here
hideErrorLabels()
setupErrorLabels()
setupErrorTextFields()
}
private func validate() {
createModel()
self.delegate?.validate(model: self.kycForm2Model)
} }

Loading…
Cancel
Save