Browse Source

add native country, optional setting

pull/1/head
InKwon James Kim 5 years ago
parent
commit
3f23d0896b
  1. 8
      GME Remit/APIs/Router/APIRouter.swift
  2. 18
      GME Remit/Extensions/UITextField+Ext.swift
  3. 13
      GME Remit/Modules/AutoDebitModules/AutoDebit/User Interface/View/AutoDebitViewController.swift
  4. 8
      GME Remit/Modules/RecipientModules/Recipients/Application Logic/Model/Recipient/Recipient.swift
  5. 4
      GME Remit/Modules/RecipientModules/Recipients/User Interface/Presenter/RecipientsPresenter.swift
  6. 4
      GME Remit/Modules/RecipientModules/Recipients/User Interface/Wireframe/RecipientsWireframe.swift
  7. 1
      GME Remit/Modules/RecipientModules/Recipients/User Interface/Wireframe/RecipientsWireframeInputOutput.swift
  8. 3
      GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Interactor/SetupRecipientInteractor.swift
  9. 2
      GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Interactor/SetupRecipientInteractorIO.swift
  10. 4
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/Presenter/SetupRecipientPresenter.swift
  11. 33
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipient.storyboard
  12. 88
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipientViewController.swift
  13. 42
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/ViewModel/SetupRecipientViewModel.swift
  14. 2
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/ViewModel/SetupRecipientViewModelInterface.swift
  15. 4
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/Wireframe/SetupRecipientWireframe.swift
  16. 1
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/Wireframe/SetupRecipientWireframeInputOutput.swift
  17. 4
      GME Remit/MultiLanguages/km.lproj/Localizable.strings

8
GME Remit/APIs/Router/APIRouter.swift

@ -350,7 +350,8 @@ extension APIRouter {
case .calculateDefExRate:
return "\(baseUrl)/mobile/calculateDefExRate"
case .dynamicReceiver(let username, let countryID, let serviceType):
return "\(baseUrlWithoutVersion)v3/mobile/receiver/\(username)/dynamicField?countryId=\(countryID)&serviceType=\(serviceType)"
let path = "\(username)/dynamicField?countryId=\(countryID)&serviceType=\(serviceType)"
return "\(baseUrlWithoutVersion)v3/mobile/receiver/\(path)"
case .getKFTCParamers(let username):
return "\(baseUrl)/kftc/GetKftcParameters/\(username)"
case .deleteAutoDebitAccount(let username, _):
@ -548,7 +549,10 @@ extension APIRouter {
"purposeOfRemitId": recipient.purposeOfRemitID ?? "",
"fullName": recipient.fullName ?? "",
"idType": recipient.idType ?? "",
"idNumber": recipient.idNumber ?? ""
"idNumber": recipient.idNumber ?? "",
"nativeCountry": recipient.nativeCountry ?? "",
"nativeCountryID": recipient.nativeCountryID ?? "",
"nativeCountryCode": recipient.nativeCountryCode ?? ""
]
case .editRecipient(let senderID, let recipient):

18
GME Remit/Extensions/UITextField+Ext.swift

@ -8,21 +8,23 @@
import UIKit
enum GMEKeyboardType {
case an
case ans
case n
enum GMEKeyboardType: String {
case alphabet = "A"
case alphabetNumberic = "AN"
case alphabetNumbericSpecial = "ANS"
case numberic = "N"
}
extension UITextField {
func setKeyboardType(type: GMEKeyboardType, isSendAction: Bool = true) {
func fitlerBy(type: GMEKeyboardType, isSendAction: Bool = true) {
let extractText: String?
switch type {
case .an: extractText = text?.extract(regex: "[A-Z0-9a-z\\s]")
case .ans: extractText = text?.filter { $0.isASCII }
case .n: extractText = text?.extract(regex: "[0-9]")
case .alphabet: extractText = text?.extract(regex: "[A-Za-z\\s]")
case .alphabetNumberic: extractText = text?.extract(regex: "[A-Z0-9a-z\\s]")
case .alphabetNumbericSpecial: extractText = text?.filter { $0.isASCII }
case .numberic: extractText = text?.extract(regex: "[0-9]")
}
if text != extractText {

13
GME Remit/Modules/AutoDebitModules/AutoDebit/User Interface/View/AutoDebitViewController.swift

@ -129,19 +129,8 @@ class AutoDebitViewController: UIViewController {
.keyboardToolbar
.doneBarButton
.setTarget(self, action: #selector(self.editingDidEnd(_:)))
DispatchQueue.main.asyncAfter(deadline: .now()) {[weak self] in
guard let `self` = self else {return}
self.tableView.refreshControl?.endRefreshing()
}
},
cancelAction: {
DispatchQueue.main.asyncAfter(deadline: .now()) {[weak self] in
guard let `self` = self else {return}
self.tableView.refreshControl?.endRefreshing()
}
}
cancelAction: nil
)
}

8
GME Remit/Modules/RecipientModules/Recipients/Application Logic/Model/Recipient/Recipient.swift

@ -52,6 +52,10 @@ struct Recipient: Mappable {
var payoutPartner: String?
var nativeCountry: String?
var nativeCountryCode: String?
var nativeCountryID: String?
init?(map: Map) {}
init() {
agent = AgentModel()
@ -125,6 +129,10 @@ struct Recipient: Mappable {
districtID <- map["districtId"]
purposeOfRemitID <- map["purposeOfRemitId"]
payoutPartner <- map["payoutPartner"]
nativeCountry <- map["nativeCountry"]
nativeCountryCode <- map["nativeCountryCode"]
nativeCountryID <- map["nativeCountryID"]
}
func serialize() -> [String : String] {

4
GME Remit/Modules/RecipientModules/Recipients/User Interface/Presenter/RecipientsPresenter.swift

@ -75,4 +75,8 @@ extension RecipientsPresenter: RecipientsWireframeOutput {
func openedSetupRecipient() {
viewModel?.progress(isShow: false)
}
func setSelectAccountError(with error: Error) {
viewModel?.setError(with: error)
}
}

4
GME Remit/Modules/RecipientModules/Recipients/User Interface/Wireframe/RecipientsWireframe.swift

@ -69,13 +69,15 @@ extension RecipientsWireframe: RecipientsWireframeInput {
extension RecipientsWireframe: SelectPaymentDelegate {
func selectPayment(_ viewController: SelectPaymentViewController, selectedAccount: Account) {
DispatchQueue.main.async {
viewController.dismiss(animated: true) {
self.output?.setSelectedAccount(selectedAccount)
}
}
}
func selectPayment(_ viewController: SelectPaymentViewController, error: Error) {
self.output?.setSelectAccountError(with: error)
}
}

1
GME Remit/Modules/RecipientModules/Recipients/User Interface/Wireframe/RecipientsWireframeInputOutput.swift

@ -18,4 +18,5 @@ protocol RecipientsWireframeInput: WireframeInput {
protocol RecipientsWireframeOutput: class {
func setSelectedAccount(_ account: Account)
func openedSetupRecipient()
func setSelectAccountError(with error: Error)
}

3
GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Interactor/SetupRecipientInteractor.swift

@ -15,6 +15,7 @@ class SetupRecipientInteractor {
weak var output: SetupRecipientInteractorOutput?
private let service: SetupRecipientServiceType
private let recipient: Recipient?
private lazy var nativeCountries = StaticModels().nativeCountries
// MARK: Initialization
init(service: SetupRecipientServiceType, _ recipient: Recipient?) {
@ -38,7 +39,7 @@ extension SetupRecipientInteractor: SetupRecipientInteractorInput {
service.fetchDynamicReceiverFields(
of: country,
paymentModeID: paymentMode,
success: {self.output?.setDynamicFields(with: $0)},
success: {self.output?.setDynamicFields(with: $0, nativeCountires: self.nativeCountries)},
failure: {self.output?.setError(with: $0)}
)
}

2
GME Remit/Modules/RecipientModules/SetupRecipient/Application Logic/Interactor/SetupRecipientInteractorIO.swift

@ -18,7 +18,7 @@ protocol SetupRecipientInteractorInput: class {
protocol SetupRecipientInteractorOutput: class {
func setCoutryServices(with model: [CountryAndServiceModel], recipient: Recipient?)
func setDynamicFields(with model: DynamicFieldModel)
func setDynamicFields(with model: DynamicFieldModel, nativeCountires: [NativeCountryModel])
func setError(with error: Error)
func success(with model: ResponseContainerObject<Recipient>)

4
GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/Presenter/SetupRecipientPresenter.swift

@ -62,9 +62,9 @@ extension SetupRecipientPresenter: SetupRecipientInteractorOutput {
viewModel?.setCoutryServices(with: model, recipient: recipient)
}
func setDynamicFields(with model: DynamicFieldModel) {
func setDynamicFields(with model: DynamicFieldModel, nativeCountires: [NativeCountryModel]) {
viewModel?.progress(isShow: false)
viewModel?.setDynamicFields(with: model)
viewModel?.setDynamicFields(with: model, nativeCountires: nativeCountires)
}
func setError(with error: Error) {

33
GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipient.storyboard

@ -30,10 +30,10 @@
<rect key="frame" x="0.0" y="64" width="375" height="2436"/>
<subviews>
<view contentMode="scaleToFill" placeholderIntrinsicWidth="375" placeholderIntrinsicHeight="900" translatesAutoresizingMaskIntoConstraints="NO" id="PIe-ui-tiD">
<rect key="frame" x="0.0" y="0.0" width="375" height="2220"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="2300"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="equalSpacing" spacing="30" translatesAutoresizingMaskIntoConstraints="NO" id="XVK-dn-bWy" userLabel="ContentStackView">
<rect key="frame" x="20" y="20" width="335" height="2180"/>
<rect key="frame" x="20" y="20" width="335" height="2260"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Z73-uy-Dpy" customClass="ShadowView" customModule="GME_Remit" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="335" height="190"/>
@ -81,10 +81,10 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="KuO-v7-G5i" customClass="ShadowView" customModule="GME_Remit" customModuleProvider="target">
<rect key="frame" x="0.0" y="220" width="335" height="990"/>
<rect key="frame" x="0.0" y="220" width="335" height="1070"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="fh8-An-4Jk">
<rect key="frame" x="20" y="20" width="295" height="940"/>
<rect key="frame" x="20" y="20" width="295" height="1020"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Select bank" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="z1Z-0h-bqe" customClass="ValidationTextField" customModule="GME_Remit" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="295" height="60"/>
@ -231,8 +231,22 @@
<userDefinedRuntimeAttribute type="boolean" keyPath="isShowTitle" value="NO"/>
</userDefinedRuntimeAttributes>
</textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter mobile number" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="vrr-rD-c2Z" customClass="ValidationTextField" customModule="GME_Remit" customModuleProvider="target">
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Select native country" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="hkx-NG-MWg" customClass="ValidationTextField" customModule="GME_Remit" customModuleProvider="target">
<rect key="frame" x="0.0" y="880" width="295" height="60"/>
<color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="DF8-kg-QqI"/>
</constraints>
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="17"/>
<textInputTraits key="textInputTraits"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="titleText" value="Native Country"/>
<userDefinedRuntimeAttribute type="boolean" keyPath="isShowTitle" value="NO"/>
</userDefinedRuntimeAttributes>
</textField>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Enter mobile number" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="vrr-rD-c2Z" customClass="ValidationTextField" customModule="GME_Remit" customModuleProvider="target">
<rect key="frame" x="0.0" y="960" width="295" height="60"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="Hjz-6c-T5H"/>
</constraints>
@ -256,7 +270,7 @@
</constraints>
</view>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="20" translatesAutoresizingMaskIntoConstraints="NO" id="0dO-n3-qcW">
<rect key="frame" x="0.0" y="1240" width="335" height="940"/>
<rect key="frame" x="0.0" y="1320" width="335" height="940"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mjU-QV-AaS" customClass="ShadowView" customModule="GME_Remit" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="335" height="190"/>
@ -435,7 +449,7 @@
<rect key="frame" x="0.0" y="870" width="335" height="70"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ppQ-QG-Dmc">
<rect key="frame" x="20" y="20" width="295" height="50"/>
<rect key="frame" x="0.0" y="20" width="335" height="50"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="uSo-1V-hoA"/>
@ -449,8 +463,8 @@
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="ppQ-QG-Dmc" secondAttribute="bottom" id="506-XD-Xp9"/>
<constraint firstAttribute="trailing" secondItem="ppQ-QG-Dmc" secondAttribute="trailing" constant="20" id="Uec-7m-1aB"/>
<constraint firstItem="ppQ-QG-Dmc" firstAttribute="leading" secondItem="QfV-jH-lw7" secondAttribute="leading" constant="20" id="YHn-L1-Afd"/>
<constraint firstAttribute="trailing" secondItem="ppQ-QG-Dmc" secondAttribute="trailing" id="Uec-7m-1aB"/>
<constraint firstItem="ppQ-QG-Dmc" firstAttribute="leading" secondItem="QfV-jH-lw7" secondAttribute="leading" id="YHn-L1-Afd"/>
<constraint firstItem="ppQ-QG-Dmc" firstAttribute="top" secondItem="QfV-jH-lw7" secondAttribute="top" constant="20" id="ie5-L9-JYi"/>
</constraints>
</view>
@ -518,6 +532,7 @@
<outlet property="middleNameLocalTextField" destination="55n-GU-u5y" id="QU2-vt-in9"/>
<outlet property="middleNameTextField" destination="YHH-Sk-Jvp" id="UOi-e8-myH"/>
<outlet property="mobileTextField" destination="vrr-rD-c2Z" id="ZJM-s6-HGX"/>
<outlet property="nativeCountryTextField" destination="hkx-NG-MWg" id="Nrl-QC-Fc3"/>
<outlet property="otherContainerView" destination="vQa-dv-Y9J" id="3PJ-UF-67d"/>
<outlet property="paymentModeTextField" destination="LWt-fH-90a" id="LNF-VE-HPt"/>
<outlet property="reasonTextField" destination="nsx-wB-rlf" id="HeD-RV-QWj"/>

88
GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipientViewController.swift

@ -10,6 +10,12 @@ import UIKit
import RxSwift
import RxCocoa
enum DynamicFieldRequire: String {
case mandatory = "M"
case optional = "O"
case hidden = "H"
}
class SetupRecipientViewController: UIViewController {
// MARK: Properties
var viewModel: SetupRecipientViewModel!
@ -49,6 +55,7 @@ class SetupRecipientViewController: UIViewController {
@IBOutlet private weak var lastNameLocalTextField: ValidationTextField!
@IBOutlet private weak var fullNameLocalTextField: ValidationTextField!
@IBOutlet private weak var nativeCountryTextField: ValidationTextField!
@IBOutlet private weak var mobileTextField: ValidationTextField!
@IBOutlet private weak var emailTextField: ValidationTextField!
@ -165,7 +172,8 @@ extension SetupRecipientViewController {
setSelectTextFields(of:[
countryTextField, paymentModeTextField, bankTextField, branchTextField,
idTextField, stateProvinceTextField, districtTextField, relationTextField, reasonTextField
idTextField, stateProvinceTextField, districtTextField, relationTextField, reasonTextField,
nativeCountryTextField
]
)
recipientBankInfomationContainerView.isHidden = true
@ -200,6 +208,7 @@ extension SetupRecipientViewController {
"Middle Name in Local": middleNameLocalTextField,
"Last Name in Local": lastNameLocalTextField,
"Local Name": fullNameLocalTextField,
"Native Country": nativeCountryTextField,
"Id Type": idTextField,
"ID Number": idNumberTextField,
"Mobile Number": mobileTextField,
@ -249,6 +258,7 @@ extension SetupRecipientViewController {
openDistrictTrigger: districtTextField.rx.controlEvent(.editingDidBegin).asDriver(),
openRelationTrigger: relationTextField.rx.controlEvent(.editingDidBegin).asDriver(),
openReasonTrigger: reasonTextField.rx.controlEvent(.editingDidBegin).asDriver(),
openNativeCountryTrigger: nativeCountryTextField.rx.controlEvent(.editingDidBegin).asDriver(),
saveTrigger: saveTrigger
)
@ -319,6 +329,24 @@ extension SetupRecipientViewController {
output.selectedBank.drive(onNext: {
self.bankTextField.text = $0?.name
self.bankTextField.sendActions(for: .editingChanged)
if $0?.branchRequired?.lowercased() == "false" {
self.branchTextField.isHidden = true
self.branchTextField.text = ""
self.branchTextField.valid.onNext(true)
} else {
self.branchTextField.isHidden = false
self.branchTextField.valid.onNext(false)
}
if $0?.accountRequired?.lowercased() == "false" {
self.accountTextField.isHidden = true
self.accountTextField.text = ""
self.accountTextField.valid.onNext(true)
} else {
self.accountTextField.isHidden = false
self.accountTextField.valid.onNext(false)
}
}).disposed(by: disposeBag)
output.selectedBranch.drive(onNext: {
@ -334,6 +362,16 @@ extension SetupRecipientViewController {
output.selectedStateProvince.drive(onNext: {
self.stateProvinceTextField.text = $0?.name
self.stateProvinceTextField.sendActions(for: .editingChanged)
let count = $0?.districts?.count ?? 0
if count == 0 {
self.districtTextField.isHidden = true
self.districtTextField.valid.onNext(true)
} else {
self.districtTextField.isHidden = false
self.districtTextField.valid.onNext(false)
}
}).disposed(by: disposeBag)
output.selectedDistrict.drive(onNext: {
@ -351,6 +389,12 @@ extension SetupRecipientViewController {
self.reasonTextField.sendActions(for: .editingChanged)
}).disposed(by: disposeBag)
output.selectedNativeCountry.drive(onNext: {
self.nativeCountryTextField.text = $0?.text
// self.nativeCountryTextField.setCountry(with: $0?.code, isShowCode: false)
self.nativeCountryTextField.sendActions(for: .editingChanged)
}).disposed(by: disposeBag)
output.models.dynamicFieldsModel.drive(onNext: {
self.setDynamicFields(dynamicFieldInfo: $0)
self.recipientBankInfomationContainerView.animateHidden(isHidden: false, duration: 0.5)
@ -363,42 +407,58 @@ extension SetupRecipientViewController {
guard
let key = property.fieldName,
let textField = self.dynamicFieldDic?[key],
let isRequire = property.required,
let isRequire = DynamicFieldRequire(rawValue: property.required ?? ""),
let min = property.minLength,
let max = property.maxLength,
let keyboardType = property.keyBoardType else { return }
textField.isHidden = isRequire == "M" ? false : true
textField.errorMessage = "general_length_error_text".localized().replacingOccurrences(
of: "xxx",
with: "\(min)"
).replacingOccurrences(of: "ooo", with: "\(max)")
if !textField.isHidden {
switch isRequire {
case .mandatory:
textField.isHidden = false
if max == min && min == -1 {
textField.validCondition = { !$0.isEmpty }
textField.errorMessage = nil
} else {
textField.validCondition = { ($0.count >= min && $0.count <= max) && !$0.isEmpty }
textField.errorMessage = "general_length_error_text".localized().replacingOccurrences(
of: "xxx",
with: "\(min)"
).replacingOccurrences(of: "ooo", with: "\(max)")
}
case .optional:
textField.isHidden = false
if max == min && min == -1 {
textField.validCondition = nil
textField.errorMessage = nil
} else {
textField.validCondition = { ($0.count >= min && $0.count <= max) }
}
if !textField.titleText.contains(" (Optional)") {
textField.titleText += " (Optional)"
textField.placeholder = "\(textField.placeholder ?? "") (Optional)"
}
case .hidden:
textField.isHidden = true
textField.text = ""
}
if key.contains("Local") {
textField.keyboardType = .default
} else {
switch keyboardType {
case "N": textField.keyboardType = .numberPad
let keyType = GMEKeyboardType(rawValue: keyboardType) ?? GMEKeyboardType.alphabetNumbericSpecial
switch keyType {
case .numberic: textField.keyboardType = .numberPad
default: textField.keyboardType = .asciiCapable
}
textField.rx.controlEvent(.editingChanged).asDriver()
.drive(onNext: { _ in
switch keyboardType {
case "AN": textField.setKeyboardType(type: .an, isSendAction: false)
case "ANS": textField.setKeyboardType(type: .ans, isSendAction: false)
default: textField.setKeyboardType(type: .ans, isSendAction: false)
switch keyType {
case .numberic: textField.fitlerBy(type: .alphabetNumberic, isSendAction: false)
default: textField.fitlerBy(type: keyType, isSendAction: false)
}
}).disposed(by: disposeBag)
}

42
GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/ViewModel/SetupRecipientViewModel.swift

@ -21,6 +21,7 @@ class SetupRecipientViewModel: ViewModelType {
let openDistrictTrigger: Driver<Void>
let openRelationTrigger: Driver<Void>
let openReasonTrigger: Driver<Void>
let openNativeCountryTrigger: Driver<Void>
let saveTrigger: Driver<Recipient>
}
@ -39,6 +40,7 @@ class SetupRecipientViewModel: ViewModelType {
let selectedDistrict: Driver<District?>
let selectedRelation: Driver<Relation?>
let selectedReason: Driver<TransferReason?>
let selectedNativeCountry: Driver<NativeCountryModel?>
}
struct Models {
@ -62,6 +64,7 @@ class SetupRecipientViewModel: ViewModelType {
private let stateProvincesLinker = PublishSubject<[Provience]>()
private let relationsLinker = PublishSubject<[Relation]>()
private let reasonsLinker = PublishSubject<[TransferReason]>()
private let nativeCountiresLinker = PublishSubject<[NativeCountryModel]>()
// Selected Model Linker
private let selectedRecipientLinker = BehaviorSubject<Recipient?>(value: nil)
@ -74,6 +77,7 @@ class SetupRecipientViewModel: ViewModelType {
private let selectedDistrictLinker = BehaviorSubject<District?>(value: nil)
private let selectedRelationLinker = BehaviorSubject<Relation?>(value: nil)
private let selectedReasonLinker = BehaviorSubject<TransferReason?>(value: nil)
private let selectedNativeCountryLinker = BehaviorSubject<NativeCountryModel?>(value: nil)
// Properties
var presenter: SetupRecipientModuleInterface?
@ -98,6 +102,8 @@ class SetupRecipientViewModel: ViewModelType {
let districtsModel = selectedStateProvinceLinker.flatMap {Observable.just($0?.districts ?? [])}
.asDriverOnErrorJustComplete()
let nativeCountrisModel = nativeCountiresLinker.asDriverOnErrorJustComplete()
let model = Models(
countryServicesModel: countryServicesModel,
paymentModel: paymentModeModel,
@ -148,6 +154,10 @@ class SetupRecipientViewModel: ViewModelType {
input.openReasonTrigger.withLatestFrom(reasonsModel) {$1}
.drive(onNext: {self.presenter?.openSelectMode(with: $0, type: .reason)}).disposed(by: disposeBag)
input.openNativeCountryTrigger.withLatestFrom(nativeCountrisModel) {$1}
.drive(onNext: {self.presenter?.openSelectMode(with: $0, type: .nativeCountry)})
.disposed(by: disposeBag)
// // Handle save event
input.saveTrigger
.drive(onNext: {
@ -161,6 +171,7 @@ class SetupRecipientViewModel: ViewModelType {
let selectedRelation = try? self.selectedRelationLinker.value()
let selectedReason = try? self.selectedReasonLinker.value()
let selectedRecipient = try? self.selectedRecipientLinker.value()
let selectedNativeCountry = try? self.selectedNativeCountryLinker.value()
var recipient = $0
recipient.receiverID = selectedRecipient?.receiverID
@ -192,6 +203,10 @@ class SetupRecipientViewModel: ViewModelType {
recipient.purposeOfRemit = selectedReason?.title
recipient.purposeOfRemitID = selectedReason?.id
recipient.nativeCountry = selectedNativeCountry?.text
recipient.nativeCountryID = selectedNativeCountry?.id
recipient.nativeCountryCode = selectedNativeCountry?.code
if selectedBank?.accountValidationRequired == "True" {
let validateModel = ValidateAccountRequest(
firstName: recipient.firstName ?? "",
@ -226,19 +241,14 @@ class SetupRecipientViewModel: ViewModelType {
selectedStateProvince: selectedStateProvinceLinker.asDriverOnErrorJustComplete(),
selectedDistrict: selectedDistrictLinker.asDriverOnErrorJustComplete(),
selectedRelation: selectedRelationLinker.asDriverOnErrorJustComplete(),
selectedReason: selectedReasonLinker.asDriverOnErrorJustComplete()
selectedReason: selectedReasonLinker.asDriverOnErrorJustComplete(),
selectedNativeCountry: selectedNativeCountryLinker.asDriverOnErrorJustComplete()
)
}
}
// MARK: SetupRecipient view interface
extension SetupRecipientViewModel: SetupRecipientViewModelInterface {
/// Selected country
///
/// - Parameters:
/// - model: CountryAndServiceModel
/// - recipient: Selected Recipient Model
func setCoutryServices(with model: [CountryAndServiceModel], recipient: Recipient?) {
countryServicesLinker.onNext(model)
@ -254,18 +264,23 @@ extension SetupRecipientViewModel: SetupRecipientViewModelInterface {
)
}
/// Set Dynamic Fields based on DynamicFIeld response
///
/// - Parameter model: DynamicFieldModel
func setDynamicFields(with model: DynamicFieldModel) {
func setDynamicFields(with model: DynamicFieldModel, nativeCountires: [NativeCountryModel]) {
dynamicFieldsLinker.onNext(model.dynamicField ?? [])
reasonsLinker.onNext(model.transferReasons ?? [])
relationsLinker.onNext(model.relations ?? [])
idTypeLinker.onNext(model.idTypes ?? [])
banksLinker.onNext(model.banks ?? [])
stateProvincesLinker.onNext(model.provinces ?? [])
nativeCountiresLinker.onNext(nativeCountires)
payoutPartner = model.payoutPartner
let country = try? selectedCountryServicesLinker.value()
// Default native country setting as selected country
let nativeCountry = nativeCountires.filter({$0.code == country?.countryCode}).first
setSelectedData(with: nativeCountry, type: .nativeCountry)
guard let recipient = try? selectedRecipientLinker.value() else { return }
let selectedBank = model.banks?.filter({$0.id == recipient.agent?.id}).first
@ -275,6 +290,7 @@ extension SetupRecipientViewModel: SetupRecipientViewModelInterface {
let selectedDistrict = selectedStateProvince?.districts?.filter({$0.id == recipient.districtID}).first
let selectedRelation = model.relations?.filter({$0.title == recipient.relationshipID}).first
let selectedReason = model.transferReasons?.filter({$0.title == recipient.purposeOfRemitID}).first
let selectedNativeCountry = nativeCountires.filter({$0.text == recipient.nativeCountry}).first
setSelectedData(with: selectedBank, type: .bank)
setSelectedData(with: selectedBranch, type: .branch)
@ -283,6 +299,7 @@ extension SetupRecipientViewModel: SetupRecipientViewModelInterface {
setSelectedData(with: selectedDistrict, type: .district)
setSelectedData(with: selectedRelation, type: .relation)
setSelectedData(with: selectedReason, type: .reason)
setSelectedData(with: selectedNativeCountry, type: .nativeCountry)
}
func setSelectedData(with model: TablePresenterProtocol?, type: SetupOpenType) {
@ -339,6 +356,9 @@ extension SetupRecipientViewModel: SetupRecipientViewModelInterface {
case .reason:
guard let model = model as? TransferReason else { return }
selectedReasonLinker.onNext(model)
case .nativeCountry:
guard let model = model as? NativeCountryModel else { return }
selectedNativeCountryLinker.onNext(model)
}
}

2
GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/ViewModel/SetupRecipientViewModelInterface.swift

@ -9,7 +9,7 @@
protocol SetupRecipientViewModelInterface: class {
func setCoutryServices(with model: [CountryAndServiceModel], recipient: Recipient?)
func setDynamicFields(with model: DynamicFieldModel)
func setDynamicFields(with model: DynamicFieldModel, nativeCountires: [NativeCountryModel])
func setError(with error: Error)
func progress(isShow: Bool)

4
GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/Wireframe/SetupRecipientWireframe.swift

@ -134,6 +134,9 @@ extension SetupRecipientWireframe: TablePresenterDelegate {
case .reason:
configure.presenterTitle = "select_transfer_reason_text".localized()
configure.isUseSearchBar = true
case .nativeCountry:
configure.presenterTitle = "select_native_country_text".localized()
configure.isUseSearchBar = true
}
return configure
@ -148,6 +151,5 @@ extension SetupRecipientWireframe: TablePresenterDelegate {
}
output?.setSelectedData(with: model, type: type)
}
}

1
GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/Wireframe/SetupRecipientWireframeInputOutput.swift

@ -18,6 +18,7 @@ enum SetupOpenType: Int {
case district
case relation
case reason
case nativeCountry
}
protocol SetupRecipientWireframeInput: WireframeInput {

4
GME Remit/MultiLanguages/km.lproj/Localizable.strings

@ -41,7 +41,7 @@
"complete_your_registration_text" = "សូមបញ្ចប់ការចុះឈ្មោះ";
"verification_in_aproval_process_text" = "ការចុះឈ្មោះរបស់អ្នកត្រូវបានកំពុងពិនិត្យ";
"complete_penny_test" = "សូមបញ្ចូលលេខ៤ខ្ទង់ដែលបានផ្ញើចូលកុងធនាគាររបស់អ្នកដើម្បីបញ្ចប់ការចុះឈ្មោះ";
"remaining_limit_text" = "ចំនួនផ្ទេរបានប្រចាំឆ្នាំនៅសល់";
"remaining_limit_text" = "ចំនួនទឹកប្រាក់ប្រចាំឆ្នាំនៅអាចផ្ទេរបាន";
"send_money_text" = "ផ្ទេរប្រាក់";
"todays_rate_text" = "អត្រាប្តូរប្រាក់ថ្ងៃនេះ";
"transaction_report_text" = "របាយការណ៍ប្រតិបត្តការណ៍";
@ -158,7 +158,7 @@
"transfer_success_info_text" = "លោកអ្នកបានផ្ទេរប្រាក់ដោយជោគជ័យហើយ ";
"total_payout_amount_text" = "ចំនួនផ្ទេរប្រាក់សរុប";
"gme_control_no_text" = "លេខកូដដកលុយ GME";
"gme_control_security_text" = "សូមរក្សា លេខកូដដកលុយជាសម្ងាត់ ";
"gme_control_security_text" = "សូមរក្សាលេខកូដដកលុយជាសម្ងាត់ ";
"share_party_text" = "ចែករំលែកអោយតែអ្នកទទួលប្រាក់";
"transaction_date_text" = "កាលបរិច្ឆេទប្រតិបត្តិការ";
"receiver_text" = "អ្នកទទួល";

Loading…
Cancel
Save