Browse Source

attempt to scroll to teh textfield

pull/1/head
gme_2 6 years ago
parent
commit
6a0debb33c
  1. 1
      GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1.storyboard
  2. 25
      GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift

1
GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1.storyboard

@ -496,6 +496,7 @@
<outlet property="occupationTextField" destination="ayn-DP-9bq" id="Yzu-LO-qYT"/>
<outlet property="provinceErrorLabel" destination="rqL-H3-Mlf" id="fh6-zB-S6J"/>
<outlet property="provinceTextField" destination="SC9-rY-28Z" id="3vx-ba-VhU"/>
<outlet property="scrollView" destination="ixK-Bl-e32" id="Kyc-Bb-cjk"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8je-5K-XuW" userLabel="First Responder" sceneMemberID="firstResponder"/>

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

@ -56,6 +56,7 @@ class KycForm1ViewController: UIViewController {
// MARK: IBOutlets
@IBOutlet weak var scrollView: UIScrollView!
// validation labels
@IBOutlet weak var firstNameErrorLabel: UILabel!
@IBOutlet weak var middleNameErrorLabel: UILabel!
@ -207,6 +208,18 @@ class KycForm1ViewController: UIViewController {
private func setupErrorTextFields() {
self.textfields = [firstNameTextField, lastNameTextField, middleNmaeTextField, genderTextField, dobTextField, mobileNumberTextField, emailTextField, nativeCountryTextField, countryTextField, provinceTextField, occupationTextField]
firstNameTextField.tag = 1
middleNmaeTextField.tag = 2
lastNameTextField.tag = 3
genderTextField.tag = 4
dobTextField.tag = 5
mobileNumberTextField.tag = 6
emailTextField.tag = 7
nativeCountryTextField.tag = 8
countryTextField.tag = 9
provinceTextField.tag = 10
occupationTextField.tag = 11
self.errorTextFieldDict =
[
@ -232,6 +245,7 @@ class KycForm1ViewController: UIViewController {
}
private func show( error: String, label: UILabel?) {
// scroll to the top of the view
guard let label = label else {return}
label.textColor = Constants.stateRedColor
label.isHidden = false
@ -242,6 +256,7 @@ class KycForm1ViewController: UIViewController {
// MARK: KycForm1ViewInterface
extension KycForm1ViewController: KycForm1ViewInterface {
func show(result: (doesNotSucks: Bool, errorsDick: [String : String])) {
var position = 11
if result.doesNotSucks { // if isValid
// its is not valid, lets go to security page
self.delegate?._continue(model: self.kycModel)
@ -251,6 +266,15 @@ extension KycForm1ViewController: KycForm1ViewInterface {
self.show(error: $0.value, label: label)
let textfield = errorTextFieldDict[$0.key]
self.showBorder(textfield: textfield)
let tag = (textfield?.tag ?? 11)
position = tag < position ? tag : position
if let topMostTextField = self.textfields.filter({
$0.tag == tag
}).first {
// scroll to view here
}
})
}
@ -397,4 +421,3 @@ extension KycForm1ViewController {
self.selectedOccupation = _occupation
}
}
Loading…
Cancel
Save