Browse Source

added shadow

pull/1/head
gme_2 6 years ago
parent
commit
07a9c02128
  1. 6
      GMERemittance/Extension/CALayerExtension.swift
  2. 1
      GMERemittance/Library/CountryWithFlagPicker/CountryPickerViewController.swift
  3. 4
      GMERemittance/Module/New Group/kycForm1/Application Logic/Interactor/kycForm1Interactor.swift
  4. 1
      GMERemittance/Module/New Group/kycForm1/Application Logic/Interactor/kycForm1InteractorIO.swift
  5. 22
      GMERemittance/Module/New Group/kycForm1/Application Logic/Service/kycForm1ServiceType.swift
  6. 1
      GMERemittance/Module/New Group/kycForm1/Module Interface/kycForm1ModuleInterface.swift
  7. 4
      GMERemittance/Module/New Group/kycForm1/User Interface/Presenter/kycForm1Presenter.swift
  8. 2
      GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1.storyboard
  9. 120
      GMERemittance/Module/New Group/kycForm1/User Interface/View/kycForm1ViewController.swift

6
GMERemittance/Extension/CALayerExtension.swift

@ -10,10 +10,10 @@ import Foundation
extension CALayer { extension CALayer {
func addShadow(with color: UIColor) {
func addShadow(with color: UIColor, shadowRadius:CGFloat = 2, shadowOpacity: Float = 0.37) {
self.shadowOffset = .zero self.shadowOffset = .zero
self.shadowOpacity = 0.37
self.shadowRadius = 2
self.shadowOpacity = shadowOpacity
self.shadowRadius = shadowRadius
self.shadowColor = color.cgColor self.shadowColor = color.cgColor
self.masksToBounds = false self.masksToBounds = false
} }

1
GMERemittance/Library/CountryWithFlagPicker/CountryPickerViewController.swift

@ -17,6 +17,7 @@ enum PickerTitle: String {
case bank = "Bank" case bank = "Bank"
case branch = "Branch" case branch = "Branch"
case currency = "Currency" case currency = "Currency"
case occupation = "Occupation"
} }
class CountryPickerViewController: UIViewController { class CountryPickerViewController: UIViewController {

4
GMERemittance/Module/New Group/kycForm1/Application Logic/Interactor/kycForm1Interactor.swift

@ -58,4 +58,8 @@ extension KycForm1Interactor: KycForm1InteractorInput {
self.output?.show(errorsDick: result) self.output?.show(errorsDick: result)
} }
func viewIsReady() {
}
} }

1
GMERemittance/Module/New Group/kycForm1/Application Logic/Interactor/kycForm1InteractorIO.swift

@ -8,6 +8,7 @@
protocol KycForm1InteractorInput: class { protocol KycForm1InteractorInput: class {
func validate(model: kycForm1Model) func validate(model: kycForm1Model)
func viewIsReady()
} }
protocol KycForm1InteractorOutput: class { protocol KycForm1InteractorOutput: class {

22
GMERemittance/Module/New Group/kycForm1/Application Logic/Service/kycForm1ServiceType.swift

@ -12,3 +12,25 @@ protocol KycForm1ServiceType: class {
} }
protocol FetchKycInformation: ApiServiceType {
func fetch(success: @escaping (SendMoneyModel?) -> (), failure: @escaping (Error) -> () )
}
extension FetchKycInformation {
func fetch(success: @escaping (SendMoneyModel?) -> (), failure: @escaping (Error) -> () ) {
let url = baseUrl + "mobile/loadform/receiver"
auth.request(method: .get, url: url, params: nil, success: { (response: SendMoneyInformationContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.message ?? ""])
failure(error)
}else {
let model = response.data
success(model)
}
}) { (error) in
failure(error)
}
}
}

1
GMERemittance/Module/New Group/kycForm1/Module Interface/kycForm1ModuleInterface.swift

@ -8,4 +8,5 @@
protocol KycForm1ModuleInterface: class { protocol KycForm1ModuleInterface: class {
func validate(model: kycForm1Model) func validate(model: kycForm1Model)
func viewIsReady()
} }

4
GMERemittance/Module/New Group/kycForm1/User Interface/Presenter/kycForm1Presenter.swift

@ -33,4 +33,8 @@ extension KycForm1Presenter: KycForm1InteractorOutput {
func show(errorsDick: (doesNotSucks: Bool, errorsDick: [String : String])) { func show(errorsDick: (doesNotSucks: Bool, errorsDick: [String : String])) {
self.view?.show(result: errorsDick) self.view?.show(result: errorsDick)
} }
func viewIsReady() {
self.interactor?.viewIsReady()
}
} }

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

@ -26,7 +26,7 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="1300"/> <rect key="frame" x="0.0" y="0.0" width="375" height="1300"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ixK-Bl-e32">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" keyboardDismissMode="onDrag" translatesAutoresizingMaskIntoConstraints="NO" id="ixK-Bl-e32">
<rect key="frame" x="0.0" y="0.0" width="375" height="1300"/> <rect key="frame" x="0.0" y="0.0" width="375" height="1300"/>
<subviews> <subviews>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ulz-yj-JUf"> <stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ulz-yj-JUf">

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

@ -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
@ -151,35 +174,7 @@ class KycForm1ViewController: UIViewController {
dateFormatter.dateFormat = "yyyy-MM-dd" dateFormatter.dateFormat = "yyyy-MM-dd"
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
}
}
Loading…
Cancel
Save