Browse Source

edit TablePresenter, add ValidationTextField Type as Dropdown

pull/1/head
InKwon James Kim 5 years ago
parent
commit
6d9535230f
  1. BIN
      .DS_Store
  2. 4
      GME Remit.xcodeproj/project.pbxproj
  3. 3
      GME Remit/Modules/ExchangeRates/User Interface/View/ExchangeRatesViewController.swift
  4. 3
      GME Remit/Modules/Home/User Interface/View/HomeViewController.swift
  5. 29
      GME Remit/Modules/PowerCallModules/PhoneCardRecharge/User Interface/View/PhoneCardRecharge.storyboard
  6. 38
      GME Remit/Modules/PowerCallModules/PhoneCardRecharge/User Interface/View/PhoneCardRechargeViewController.swift
  7. 12
      GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/Wireframe/SetupRecipientWireframe.swift
  8. 12
      GME Remit/Modules/RegisterModules/KYC/kycForm1/User Interface/Wireframe/kycForm1Wireframe.swift
  9. 3
      GME Remit/Modules/RegisterModules/KYC/kycForm2/User Interface/Wireframe/kycForm2Wireframe.swift
  10. 3
      GME Remit/Modules/RegisterModules/Register/User Interface/View/RegisterViewController.swift
  11. 3
      GME Remit/Modules/RemittanceModules/DomesticModules/DomesticRemit/User Interface/Wireframe/DomesticRemitWireframe.swift
  12. 3
      GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift
  13. 3
      GME Remit/Modules/SideMenu/SettingViewController.swift
  14. 3
      GME Remit/Modules/SplashScreen/User Interface/View/SplashScreenViewController.swift
  15. 22
      GME Remit/Utilities/DismissAnimator.swift
  16. 100
      GME Remit/Utilities/TablePresenter/User Interface/View/TablePresenterViewController.swift
  17. 81
      GME Remit/Utilities/ValidationTextField.swift

BIN
.DS_Store

4
GME Remit.xcodeproj/project.pbxproj

@ -257,6 +257,7 @@
73469FA12293C1B00062946B /* PaymentCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73469F952293C1AF0062946B /* PaymentCell.swift */; };
73469FA22293C1B00062946B /* SelectPaymentViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73469F962293C1AF0062946B /* SelectPaymentViewInterface.swift */; };
73469FA32293C1B00062946B /* SelectPayment.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 73469F972293C1AF0062946B /* SelectPayment.storyboard */; };
734930B023500E660022D1A9 /* DismissAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 734930AF23500E660022D1A9 /* DismissAnimator.swift */; };
73538B2222EFC5FA00188CDD /* CommonServiceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73538B2122EFC5FA00188CDD /* CommonServiceType.swift */; };
736A8C402277EB2A00337A50 /* BiometricNotificationModuleInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C2D2277EB2900337A50 /* BiometricNotificationModuleInterface.swift */; };
736A8C412277EB2A00337A50 /* BiometricNotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736A8C312277EB2900337A50 /* BiometricNotificationService.swift */; };
@ -2498,6 +2499,7 @@
73469F952293C1AF0062946B /* PaymentCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PaymentCell.swift; sourceTree = "<group>"; };
73469F962293C1AF0062946B /* SelectPaymentViewInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectPaymentViewInterface.swift; sourceTree = "<group>"; };
73469F972293C1AF0062946B /* SelectPayment.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = SelectPayment.storyboard; sourceTree = "<group>"; };
734930AF23500E660022D1A9 /* DismissAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissAnimator.swift; sourceTree = "<group>"; };
73538B2122EFC5FA00188CDD /* CommonServiceType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommonServiceType.swift; sourceTree = "<group>"; };
736A8C2D2277EB2900337A50 /* BiometricNotificationModuleInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricNotificationModuleInterface.swift; sourceTree = "<group>"; };
736A8C312277EB2900337A50 /* BiometricNotificationService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BiometricNotificationService.swift; sourceTree = "<group>"; };
@ -11200,6 +11202,7 @@
73976D212331BFB1003CF5E1 /* BankEnum.swift */,
7303E5722344A1F000472407 /* StoreReviewHelper.swift */,
739F8186234AFF13003ABCF3 /* DebugManager.swift */,
734930AF23500E660022D1A9 /* DismissAnimator.swift */,
);
path = Utilities;
sourceTree = "<group>";
@ -14290,6 +14293,7 @@
D96A4FF72146625C00CFD507 /* RegisterServiceType.swift in Sources */,
7301979822535135001954AB /* kycForm1ServiceType.swift in Sources */,
D95B5E3C21311057000C0B33 /* GmeContactsInteractor.swift in Sources */,
734930B023500E660022D1A9 /* DismissAnimator.swift in Sources */,
BEC9AFFF224FC49C00A2DA06 /* BiometricAuthenticationInteractorIO.swift in Sources */,
73185314230E19DD00BA9AE3 /* ValidateAccountRequest.swift in Sources */,
D9B7ADF32130048E009B0564 /* ExchangeRatesInteractorIO.swift in Sources */,

3
GME Remit/Modules/ExchangeRates/User Interface/View/ExchangeRatesViewController.swift

@ -527,8 +527,7 @@ extension ExchangeRatesViewController: TablePresenterDelegate {
presenterTitle: "search_currency_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_currency_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_currency_text".localized()
)
}

3
GME Remit/Modules/Home/User Interface/View/HomeViewController.swift

@ -716,7 +716,8 @@ extension HomeViewController: HomeCollectionDelegate {
case .resend: showResendMoney()
case .walletToWallet: showWalletToWallet()
case .demosticRemit: showDomesticRemit()
case .phoneRecharge: ()
case .phoneRecharge:
PhoneCardRechargeWireframe().pushMainView(on: self)
case .cardRecharge: ()
}
}

29
GME Remit/Modules/PowerCallModules/PhoneCardRecharge/User Interface/View/PhoneCardRecharge.storyboard

@ -20,13 +20,13 @@
<!--PhoneCardRecharge-->
<scene sceneID="R60-Pu-Hpy">
<objects>
<viewController storyboardIdentifier="PhoneCardRechargeViewController" title="PhoneCardRecharge" id="HSb-ou-7T5" customClass="PhoneCardRechargeViewController" sceneMemberID="viewController">
<viewController storyboardIdentifier="PhoneCardRechargeViewController" title="PhoneCardRecharge" id="HSb-ou-7T5" customClass="PhoneCardRechargeViewController" customModule="GME_Remit" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="9Uc-9s-KgO">
<rect key="frame" x="0.0" y="0.0" width="375" height="1000"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="1500"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HAO-OX-Hu1">
<rect key="frame" x="0.0" y="44" width="375" height="866"/>
<rect key="frame" x="0.0" y="44" width="375" height="1366"/>
<subviews>
<view contentMode="scaleToFill" placeholderIntrinsicWidth="375" placeholderIntrinsicHeight="956" translatesAutoresizingMaskIntoConstraints="NO" id="bLc-vG-GQk">
<rect key="frame" x="0.0" y="0.0" width="375" height="1376"/>
@ -38,7 +38,7 @@
<rect key="frame" x="10" y="10" width="355" height="96"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="QVg-Ii-ls0">
<rect key="frame" x="0.0" y="0.0" width="355" height="55.5"/>
<rect key="frame" x="0.0" y="0.0" width="355" height="50"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="EA8-0Y-03d">
<rect key="frame" x="0.0" y="0.0" width="355" height="50"/>
@ -74,32 +74,25 @@
</view>
</subviews>
</stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XaI-Ty-jIE">
<rect key="frame" x="0.0" y="55" width="355" height="0.5"/>
<color key="backgroundColor" name="ThemeSeparate"/>
<constraints>
<constraint firstAttribute="height" constant="0.5" id="Y0F-gh-zWo"/>
</constraints>
</view>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="DZ1-Nc-ndh">
<rect key="frame" x="0.0" y="75.5" width="355" height="20.5"/>
<rect key="frame" x="0.0" y="70" width="355" height="26"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="My Cash" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3sX-PN-Zns">
<rect key="frame" x="0.0" y="0.0" width="67.5" height="20.5"/>
<rect key="frame" x="0.0" y="0.0" width="67.5" height="26"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="17"/>
<color key="textColor" name="ThemeText"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="₩" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nhP-WU-Prr">
<rect key="frame" x="67.5" y="0.0" width="244.5" height="20.5"/>
<rect key="frame" x="67.5" y="0.0" width="244.5" height="26"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="17"/>
<color key="textColor" name="ThemeText"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="2,000" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ao5-ep-Uh6">
<rect key="frame" x="312" y="0.0" width="43" height="20.5"/>
<rect key="frame" x="312" y="0.0" width="43" height="26"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="17"/>
<color key="textColor" name="ThemeText"/>
<nil key="highlightedColor"/>
@ -161,7 +154,6 @@
<color key="backgroundColor" name="ThemeRed"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="SHz-ez-pi3"/>
<constraint firstAttribute="width" constant="50" id="xtG-n3-plb"/>
</constraints>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="17"/>
<state key="normal" title="₩ 10,000">
@ -242,6 +234,7 @@
<constraint firstAttribute="trailing" secondItem="2jz-Oc-Za2" secondAttribute="trailing" constant="5" id="baB-yP-VZa"/>
<constraint firstItem="2jz-Oc-Za2" firstAttribute="top" secondItem="CmC-Q1-ZRq" secondAttribute="top" constant="5" id="gCe-LD-cpl"/>
<constraint firstAttribute="bottom" secondItem="2jz-Oc-Za2" secondAttribute="bottom" constant="5" id="sl3-VY-4Wg"/>
<constraint firstAttribute="height" constant="80" id="yE0-0T-hFx"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="irB-sa-xqC">
@ -424,7 +417,7 @@
</constraints>
</scrollView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="TJE-ol-Hx6">
<rect key="frame" x="10" y="930" width="355" height="50"/>
<rect key="frame" x="10" y="1430" width="355" height="50"/>
<color key="backgroundColor" name="ThemeRed"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="ml6-m3-hSl"/>
@ -448,7 +441,7 @@
<viewLayoutGuide key="safeArea" id="O1T-1R-Sun"/>
</view>
<navigationItem key="navigationItem" title="Prepaid Phone Card Recharge" id="3H9-66-Lec"/>
<size key="freeformSize" width="375" height="1000"/>
<size key="freeformSize" width="375" height="1500"/>
<connections>
<outlet property="amountButton1" destination="uxJ-Fa-1i9" id="zwT-7e-KKv"/>
<outlet property="amountButton2" destination="nN1-tj-eIz" id="R3U-lV-BO5"/>

38
GME Remit/Modules/PowerCallModules/PhoneCardRecharge/User Interface/View/PhoneCardRechargeViewController.swift

@ -57,6 +57,10 @@ class PhoneCardRechargeViewController: UIViewController {
setup()
}
override func viewWillAppear(_ animated: Bool) {
setupNormalNavigation()
}
// MARK: IBActions
@IBAction func touchAmountButton(_ sender: UIButton) {
selectedAmountButton.onNext(sender.tag)
@ -68,10 +72,8 @@ extension PhoneCardRechargeViewController {
private func setup() {
// all setup should be done here
setBinding()
}
@objc private func selectType(sender: UISegmentedControl) {
// switch sender.selectedSegmentIndex
test()
}
private func setBinding() {
@ -119,3 +121,33 @@ extension PhoneCardRechargeViewController {
}
}
// MARK: Test
extension PhoneCardRechargeViewController {
private func test() {
let item1 = PaymentServiceType()
item1.subtitle = "Main Item 1"
let item2 = PaymentServiceType()
item2.subtitle = "Main Item 2"
let item3 = PaymentServiceType()
item3.subtitle = "Main Item 3"
let mainConfiguration = TablePresenterConfiguration(presenterTitle: "Main Items")
carrierTypeTextField.useAsDropDown(with: mainConfiguration, items: [item1, item2, item3])
let sitem1 = PaymentServiceType()
sitem1.subtitle = "Sub Item 1"
let sitem2 = PaymentServiceType()
sitem2.subtitle = "Sub Item 2"
let sitem3 = PaymentServiceType()
sitem3.subtitle = "Sub Item 3"
let subConfiguration = TablePresenterConfiguration(presenterTitle: "Sub Items")
carrierPlanTextField.useAsDropDown(with: subConfiguration, items: [sitem1, sitem2, sitem3])
}
}

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

@ -100,8 +100,7 @@ extension SetupRecipientWireframe: TablePresenterDelegate {
presenterTitle: "search_payout_country_text".localized(),
closeButtonTitle: "penny_test_close_text".localized(),
notFoundTitle: "no_payout_country_found_text".localized(),
searchBarPlaceHolder: "search_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_text".localized()
)
guard let type = SetupOpenType(rawValue: viewController.view.tag) else {
@ -114,39 +113,30 @@ extension SetupRecipientWireframe: TablePresenterDelegate {
case .paymentMode:
configure.presenterTitle = "search_payment_method_text".localized()
configure.notFoundTitle = "no_payment_method_found_text".localized()
configure.isUseSearchBar = false
case .bank:
configure.presenterTitle = "search_bank_text".localized()
configure.notFoundTitle = "no_bank_found_text".localized()
configure.isUseSearchBar = true
case .branch:
configure.presenterTitle = "search_branch_text".localized()
configure.notFoundTitle = "no_branch_found_text".localized()
configure.isUseSearchBar = true
case .idType:
configure.presenterTitle = "search_id_type_text".localized()
configure.notFoundTitle = "no_id_type_found_text".localized()
configure.isUseSearchBar = true
case .stateProvince:
configure.presenterTitle = "search_province_text".localized()
configure.notFoundTitle = "no_province_found_text".localized()
configure.isUseSearchBar = true
case .district:
configure.presenterTitle = "search_district_text".localized()
configure.notFoundTitle = "no_district_found_text".localized()
configure.isUseSearchBar = true
case .relation:
configure.presenterTitle = "search_relation_text".localized()
configure.notFoundTitle = "no_relation_found_text".localized()
configure.isUseSearchBar = true
case .reason:
configure.presenterTitle = "search_reason_text".localized()
configure.notFoundTitle = "no_reason_found_text".localized()
configure.isUseSearchBar = true
case .nativeCountry:
configure.presenterTitle = "search_native_country_text".localized()
configure.notFoundTitle = "no_native_country_found_text".localized()
configure.isUseSearchBar = true
}
return configure

12
GME Remit/Modules/RegisterModules/KYC/kycForm1/User Interface/Wireframe/kycForm1Wireframe.swift

@ -70,24 +70,21 @@ extension KycForm1Wireframe: TablePresenterDelegate {
presenterTitle: "select_country_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_country_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_country_text".localized()
)
case 1:
return TablePresenterConfiguration(
presenterTitle: "select_occupation_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_occupation_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_occupation_text".localized()
)
case 2:
return TablePresenterConfiguration(
presenterTitle: "province_placeholder_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_province_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_province_text".localized()
)
default:
@ -95,8 +92,7 @@ extension KycForm1Wireframe: TablePresenterDelegate {
presenterTitle: "select_country_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_country_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_country_text".localized()
)
}
}

3
GME Remit/Modules/RegisterModules/KYC/kycForm2/User Interface/Wireframe/kycForm2Wireframe.swift

@ -101,8 +101,7 @@ extension KycForm2Wireframe: TablePresenterDelegate {
presenterTitle: title,
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: searchPlaceHolder,
isUseSearchBar: true
searchBarPlaceHolder: searchPlaceHolder
)
}

3
GME Remit/Modules/RegisterModules/Register/User Interface/View/RegisterViewController.swift

@ -309,8 +309,7 @@ extension RegisterViewController: TablePresenterDelegate {
presenterTitle: "select_country_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_country_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_country_text".localized()
)
}

3
GME Remit/Modules/RemittanceModules/DomesticModules/DomesticRemit/User Interface/Wireframe/DomesticRemitWireframe.swift

@ -104,8 +104,7 @@ extension DomesticRemitWireframe: TablePresenterDelegate {
presenterTitle: "select_bank_text".localized(),
closeButtonTitle: "penny_test_close_text".localized(),
notFoundTitle: "no_bank_found_text".localized(),
searchBarPlaceHolder: "search_bank_text".localized(),
isUseSearchBar: false
searchBarPlaceHolder: "search_bank_text".localized()
)
}

3
GME Remit/Modules/RemittanceModules/OverseasModules/SendMoneyExchangeRate/User Interface/View/SendMoneyExchangeRateViewController.swift

@ -511,8 +511,7 @@ extension SendMoneyExchangeRateViewController: TablePresenterDelegate {
presenterTitle: "search_currency_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_currency_text".localized(),
isUseSearchBar: true
searchBarPlaceHolder: "search_currency_text".localized()
)
}

3
GME Remit/Modules/SideMenu/SettingViewController.swift

@ -162,8 +162,7 @@ extension SettingViewController: TablePresenterDelegate {
presenterTitle: "select_country_text".localized(),
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "search_country_text".localized(),
isUseSearchBar: false
searchBarPlaceHolder: "search_country_text".localized()
)
}

3
GME Remit/Modules/SplashScreen/User Interface/View/SplashScreenViewController.swift

@ -472,8 +472,7 @@ extension SplashScreenViewController: TablePresenterDelegate {
presenterTitle: title,
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: placeHolder,
isUseSearchBar: isUse
searchBarPlaceHolder: placeHolder
)
}

22
GME Remit/Utilities/DismissAnimator.swift

@ -0,0 +1,22 @@
//
// DismissAnimator.swift
// GME Remit
//
// Created by InKwon James Kim on 2019/10/11.
// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved.
//
import UIKit
class DismissAnimator: NSObject {}
extension DismissAnimator: UIViewControllerAnimatedTransitioning {
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
}
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.6
}
}

100
GME Remit/Utilities/TablePresenter/User Interface/View/TablePresenterViewController.swift

@ -14,7 +14,25 @@ struct TablePresenterConfiguration {
var closeButtonTitle: String
var notFoundTitle: String
var searchBarPlaceHolder: String
var isUseSearchBar: Bool
init(presenterTitle: String) {
self.presenterTitle = presenterTitle
closeButtonTitle = "penny_test_close_text".localized()
notFoundTitle = "no_result_found_text".localized()
searchBarPlaceHolder = "search_text".localized()
}
init(
presenterTitle: String,
closeButtonTitle: String,
notFoundTitle: String,
searchBarPlaceHolder: String
) {
self.presenterTitle = presenterTitle
self.closeButtonTitle = closeButtonTitle
self.notFoundTitle = notFoundTitle
self.searchBarPlaceHolder = searchBarPlaceHolder
}
}
protocol TablePresenterDelegate: class {
@ -41,6 +59,9 @@ class TablePresenterViewController: UIViewController {
private let impact = UISelectionFeedbackGenerator()
private var isFirst = true
private lazy var originPoint = CGPoint(x: 0, y: 0)
private lazy var isDismissAnimation = false
// MARK: Computed Properties
var model: [TablePresenterProtocol]? {
didSet {
@ -99,6 +120,12 @@ class TablePresenterViewController: UIViewController {
impact.selectionChanged()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
originPoint = mainView.frame.origin
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
IQKeyboardManager.shared.enable = true
@ -109,7 +136,7 @@ class TablePresenterViewController: UIViewController {
@IBAction func touchCloseButton(_ sender: UIButton) {
presentingViewController?.view.endEditing(true)
mainView.originToBottom {
self.delegate?.tablePresenterView(self, didSelectModel: nil)
// self.delegate?.tablePresenterView(self, didSelectModel: nil)
self.dismiss(animated: true)
}
}
@ -154,12 +181,11 @@ extension TablePresenterViewController {
transparentView.backgroundColor = .themeBackgroundGray
// searchBar.searchBarStyle = .default
// searchBar.set(textColor: .black)
// searchBar.setTextField(color: .themeWhite)
// searchBar.setPlaceholder(textColor: .themeTextColor)
// searchBar.setSearchImage(color: .themeTextColor)
// searchBar.setClearButton(color: .themeTextColor)
// let panGesture = UIPanGestureRecognizer(target: self,action: #selector(onDrag(_:)))
// panGesture.delegate = self
//
// tableView.bounces = false
// tableView.addGestureRecognizer(panGesture)
}
private func setConfiguration() {
@ -172,6 +198,52 @@ extension TablePresenterViewController {
// searchBar.isHidden = !(configuration?.isUseSearchBar ?? true)
}
@objc func onDrag(_ sender: UIPanGestureRecognizer) {
if tableView.contentOffset.y == 0 && sender.velocity(in: tableView).y > 0 {
isDismissAnimation = true
let percentThreshold: CGFloat = 0.5
let translation = sender.translation(in: mainView)
let newY = ensureRange(
value: mainView.frame.minY + translation.y,
minimum: 0,
maximum: mainView.frame.maxY
)
let progress = progressAlongAxis(newY, mainView.bounds.height)
mainView.frame.origin.y = newY
if sender.state == .ended {
let velocity = sender.velocity(in: mainView)
if velocity.y >= 200 || progress > percentThreshold {
self.touchCloseButton(UIButton())
} else {
UIView.animate(withDuration: 0.2, animations: {
self.mainView.frame.origin.y = self.originPoint.y
})
}
}
sender.setTranslation(.zero, in: mainView)
} else if isDismissAnimation {
isDismissAnimation = false
UIView.animate(withDuration: 0.2, animations: {
self.mainView.frame.origin.y = self.originPoint.y
})
}
}
func progressAlongAxis(_ pointOnAxis: CGFloat, _ axisLength: CGFloat) -> CGFloat {
let movementOnAxis = pointOnAxis / axisLength
let positiveMovementOnAxis = fmaxf(Float(movementOnAxis), 0.0)
let positiveMovementOnAxisPercent = fminf(positiveMovementOnAxis, 1.0)
return CGFloat(positiveMovementOnAxisPercent)
}
func ensureRange<T>(value: T, minimum: T, maximum: T) -> T where T : Comparable {
return min(max(value, minimum), maximum)
}
@objc private func tapGesture(_ sender: UITapGestureRecognizer) {
touchCloseButton(UIButton())
}
@ -216,7 +288,17 @@ extension TablePresenterViewController: UITableViewDelegate {
// MARK: - UIGestureRecognizerDelegate
extension TablePresenterViewController: UIGestureRecognizerDelegate {
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
return touch.view == gestureRecognizer.view
guard let tapRecognizer = gestureRecognizer as? UITapGestureRecognizer else {
return true
}
return touch.view == tapRecognizer.view
}
func gestureRecognizer(
_ gestureRecognizer: UIGestureRecognizer,
shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer
) -> Bool {
return true
}
}

81
GME Remit/Utilities/ValidationTextField.swift

@ -23,8 +23,12 @@ private enum ValidateType: String {
}
@available(iOS 9.0, *)
@IBDesignable
open class ValidationTextField: UITextField {
@IBDesignable open class ValidationTextField: UITextField {
@objc public enum ValidateTextFieldType: Int {
case dropdown
case `default`
}
// MARK: Left Flag View
private var leftViewPadding: CGFloat = 8
@ -142,6 +146,27 @@ open class ValidationTextField: UITextField {
}
}
private var type: ValidateTextFieldType = .default {
didSet {
switch type {
case .default:
inputView = nil
keyboardToolbar.isHidden = false
tintColor = .themeText
case .dropdown:
inputView = UIView()
keyboardToolbar.isHidden = true
tintColor = .clear
}
}
}
private lazy var tablePresenterWireframe = TablePresenterWireframe()
private var dropwDownItems: [TablePresenterProtocol]?
private var configure: TablePresenterConfiguration?
// MARK: Properties
open var validCondition: ((String) -> Bool)? {
@ -171,6 +196,8 @@ open class ValidationTextField: UITextField {
open var valid = BehaviorSubject<Bool>(value: false)
var selectedItem = BehaviorSubject<TablePresenterProtocol?>(value: nil)
open var successImage: UIImage?
open var errorImage: UIImage?
@ -245,11 +272,27 @@ open class ValidationTextField: UITextField {
createLineView()
createErrorLabel()
addTarget(self, action: #selector(editingDidBegin), for: .editingDidBegin)
addTarget(self, action: #selector(editingChanged), for: [.editingChanged])
}
@objc
private func editingChanged() {
@objc private func editingDidBegin() {
switch type {
case .dropdown:
guard let parentVC = parentContainerViewController() else {
return
}
tablePresenterWireframe.openWith(
delegate: self,
model: dropwDownItems,
source: parentVC
)
default : ()
}
}
@objc private func editingChanged() {
if let isValid = validCondition?(self.text ?? ""), !isValid {
self.isValid = isValid
valid.onNext(isValid)
@ -709,3 +752,33 @@ extension ValidationTextField {
leftView = paddingView
}
}
extension ValidationTextField {
func useAsDropDown(with configure: TablePresenterConfiguration? = nil, items: [TablePresenterProtocol]?) {
self.type = .dropdown
self.dropwDownItems = items
self.configure = configure
}
}
extension ValidationTextField: TablePresenterDelegate {
func tablePresenterView(_ viewController: TablePresenterViewController) -> TablePresenterConfiguration {
guard let configure = self.configure else {
return TablePresenterConfiguration(
presenterTitle: "DropDown",
closeButtonTitle: "cancel_text".localized(),
notFoundTitle: "no_result_found_text".localized(),
searchBarPlaceHolder: "Search"
)
}
return configure
}
func tablePresenterView(
_ viewController: TablePresenterViewController,
didSelectModel model: TablePresenterProtocol?
) {
selectedItem.onNext(model)
text = model?.cellTitle
}
}
Loading…
Cancel
Save