Browse Source

glitch controlled

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

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

@ -321,7 +321,7 @@
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="VKC-oG-zQf">
<rect key="frame" x="0.0" y="737" width="345" height="83"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Country" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qfd-4I-OvP">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Address" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qfd-4I-OvP">
<rect key="frame" x="0.0" y="0.0" width="345" height="15"/>
<constraints>
<constraint firstAttribute="height" constant="15" id="tjn-mF-Qhk"/>
@ -339,7 +339,7 @@
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Select your Country" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="bRp-8B-RFU">
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Your Address In Korea" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="bRp-8B-RFU">
<rect key="frame" x="0.0" y="40" width="345" height="43"/>
<constraints>
<constraint firstAttribute="height" constant="43" id="46e-Ms-7Qp"/>

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

@ -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
}
}
Loading…
Cancel
Save