Browse Source

validation added for page 2

pull/1/head
gme_2 6 years ago
parent
commit
8d89c3e7aa
  1. 31
      GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift
  2. 2
      GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractorIO.swift
  3. 1
      GMERemittance/Module/New Group/Kyc/Module Interface/KycModuleInterface.swift
  4. 7
      GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift
  5. 27
      GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewController.swift
  6. 1
      GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewInterface.swift
  7. 2
      GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift
  8. 14
      GMERemittance/Module/New Group/kycForm2/User Interface/View/kycForm2ViewController.swift
  9. 7
      GMERemittance/Module/New Group/kycForm2/User Interface/Wireframe/kycForm2Wireframe.swift

31
GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractor.swift

@ -49,6 +49,31 @@ class KycInteractor {
})
return (sucks, errorsDick) // (isValid, errorsDick)
}
func _validate(model: KycForm2Model) -> (isValid: Bool, errorsDick: [String: String]) {
var errorsDick: [String: String] = [:]
var sucks = true // isValid = true
let formDick =
[
KycForm2FieldKeys.bank: model.bank,
KycForm2FieldKeys.accountNumber: model.accountNumber,
KycForm2FieldKeys.verificationId: model.verificationId,
KycForm2FieldKeys.verificationIdNumber: model.verificationIdNumber,
KycForm2FieldKeys.expiryDate: model.expiryDate,
KycForm2FieldKeys.sourceOfFund: model.sourceOfFund
]
formDick.forEach({
if $0.value.isEmpty {
sucks = false // isValid = false
errorsDick[$0.key] = "required"
}
})
return (sucks, errorsDick) // (isValid, errorsDick)
}
}
// MARK: Kyc interactor input interface
@ -57,6 +82,10 @@ extension KycInteractor: KycInteractorInput {
func validate(model: KycForm1Model) {
let result = self._validate(model: model)
self.output?.show(resutl: (isValid: result.doesNotSucks, errorsDick: result.errorsDick))
}
func validate(model: KycForm2Model) {
let result = self._validate(model: model)
self.output?.show(resut2: (isValid: result.isValid, errorsDick: result.errorsDick))
}
}

2
GMERemittance/Module/New Group/Kyc/Application Logic/Interactor/KycInteractorIO.swift

@ -8,8 +8,10 @@
protocol KycInteractorInput: class {
func validate(model: KycForm1Model)
func validate(model: KycForm2Model)
}
protocol KycInteractorOutput: class {
func show(resutl: (isValid: Bool, errorsDick: [String: String]))
func show(resut2: (isValid: Bool, errorsDick: [String: String]))
}

1
GMERemittance/Module/New Group/Kyc/Module Interface/KycModuleInterface.swift

@ -8,4 +8,5 @@
protocol KycModuleInterface: class {
func validate(model: KycForm1Model)
func validate(model: KycForm2Model)
}

7
GMERemittance/Module/New Group/Kyc/User Interface/Presenter/KycPresenter.swift

@ -25,6 +25,10 @@ extension KycPresenter: KycModuleInterface {
func validate(model: KycForm1Model) {
self.interactor?.validate(model: model)
}
func validate(model: KycForm2Model) {
self.interactor?.validate(model: model)
}
}
@ -34,4 +38,7 @@ extension KycPresenter: KycInteractorOutput {
func show(resutl: (isValid: Bool, errorsDick: [String : String])) {
self.view?.show(resutl: resutl)
}
func show(resut2: (isValid: Bool, errorsDick: [String : String])) {
self.view?.show(resut2: resut2)
}
}

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

@ -18,8 +18,8 @@ protocol KYCForm1Delegate {
}
protocol KYCForm2Delegate {
func _continue2(model: KycForm2Model)
func validate(model: KycForm2Model)
func _continue(model: KycForm2Model)
}
protocol KYCForm3Delegate {
@ -29,6 +29,7 @@ protocol KYCForm3Delegate {
class KYCRequestModel {
var kycForm1: KycForm1Model?
var kycForm2: KycForm2Model?
}
@ -87,7 +88,7 @@ class KycViewController: ButtonBarPagerTabStripViewController {
override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
self.form1 = KycForm1Wireframe().getMainViewWithDelegate(delegate: self)
self.form2 = KycForm2Wireframe().getMainView()
self.form2 = KycForm2Wireframe().getMainViewWithDelegate(delegate: self)
self.form3 = KycForm3Wireframe().getMainView()
return [form1, form2, form3]
@ -126,6 +127,14 @@ extension KycViewController: KycViewInterface {
viewcontroller.show(result: (doesNotSucks: resutl.isValid , errorsDick:resutl.errorsDick ))
}
}
func show(resut2: (isValid: Bool, errorsDick: [String : String])) {
self.isForm2Valid = resut2.isValid
if let viewcontroller = self.form2 as? KycForm2ViewController {
viewcontroller.show(resut2: resut2)
}
}
}
@ -150,3 +159,17 @@ extension KycViewController: KYCForm1Delegate {
}
}
extension KycViewController: KYCForm2Delegate {
func validate(model: KycForm2Model) {
self.presenter?.validate(model: model)
}
func _continue(model: KycForm2Model) {
self.requestModel?.kycForm2 = model
moveToViewController(at: 2)
}
}

1
GMERemittance/Module/New Group/Kyc/User Interface/View/KycViewInterface.swift

@ -8,4 +8,5 @@
protocol KycViewInterface: class {
func show(resutl: (isValid: Bool, errorsDick: [String : String]))
func show(resut2: (isValid: Bool, errorsDick: [String : String]))
}

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

@ -290,8 +290,6 @@ extension KycForm1ViewController: KycForm1ViewInterface {
// todo remove this from this viper flow. its now in parent
func show(result: (doesNotSucks: Bool, errorsDick: [String : String])) {
var position = 11
var result = result
result.doesNotSucks = true
if result.doesNotSucks { // if isValid
// its is not valid, lets go to security page only if continue button was tapped

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

@ -69,6 +69,7 @@ class KycForm2ViewController: UIViewController {
var delegate: KYCForm2Delegate?
var presenter: KycForm2ModuleInterface?
var continueActionInitiated = false
var kycForm2Model: KycForm2Model = KycForm2Model()
// MARK: VC's Life cycle
@ -81,12 +82,14 @@ class KycForm2ViewController: UIViewController {
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
continueActionInitiated = false
validate()
}
// MARK: IBActions
@IBAction func _continue(_ sender: UIButton) {
continueActionInitiated = true
validate()
}
// MARK: Other Functions
@ -172,13 +175,16 @@ class KycForm2ViewController: UIViewController {
// MARK: KycForm2ViewInterface
extension KycForm2ViewController: KycForm2ViewInterface {
func show(result: (doesNotSucks: Bool, errorsDick: [String : String])) {
func show(resut2: (isValid: Bool, errorsDick: [String : String])) {
var position = 15
if result.doesNotSucks { // if isValid
if resut2.isValid { // if isValid
// its is not valid, lets go to security page
self.delegate?._continue2(model: self.kycForm2Model)
if self.continueActionInitiated {
self.delegate?._continue(model: self.kycForm2Model)
}
}else {
result.errorsDick.forEach({
resut2.errorsDick.forEach({
let label = errorLabelsDict[$0.key]
self.show(error: $0.value, label: label)
let textfield = errorTextFieldDict[$0.key]

7
GMERemittance/Module/New Group/kycForm2/User Interface/Wireframe/kycForm2Wireframe.swift

@ -10,6 +10,7 @@ import UIKit
class KycForm2Wireframe {
weak var view: UIViewController!
var delegate: KYCForm2Delegate?
}
extension KycForm2Wireframe: KycForm2WireframeInput {
@ -23,6 +24,7 @@ extension KycForm2Wireframe: KycForm2WireframeInput {
let viewController = viewControllerFromStoryboard(of: KycForm2ViewController.self)
viewController.presenter = presenter
viewController.delegate = self.delegate
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = self
@ -31,4 +33,9 @@ extension KycForm2Wireframe: KycForm2WireframeInput {
self.view = viewController
return viewController
}
func getMainViewWithDelegate(delegate: KYCForm2Delegate) -> UIViewController {
self.delegate = delegate
return self.getMainView()
}
}
Loading…
Cancel
Save