Browse Source

add all use balance button at recharge payment

pull/1/head
InKwon James Kim 5 years ago
parent
commit
2d71551abb
  1. 9
      GME Remit/Modules/PowerCallModules/RechargePayment/User Interface/Presenter/RechargePaymentPresenter.swift
  2. 45
      GME Remit/Modules/PowerCallModules/RechargePayment/User Interface/View/RechargePayment.storyboard
  3. 14
      GME Remit/Modules/PowerCallModules/RechargePayment/User Interface/View/RechargePaymentViewController.swift

9
GME Remit/Modules/PowerCallModules/RechargePayment/User Interface/Presenter/RechargePaymentPresenter.swift

@ -29,6 +29,7 @@ class RechargePaymentPresenter: ViewModelType {
let paymentAmount: Driver<String>
let isAvailableUseBalance: Driver<Bool>
let finalPaymentAmount: Driver<String>
let maxBalance: Driver<String>
let verifySuccess: Driver<Void>
let submitSuccess: Driver<VerificationAndBuy>
}
@ -112,6 +113,13 @@ class RechargePaymentPresenter: ViewModelType {
return finalPaymentAmount >= 0 ? true : false
}
let maxBalance = Driver.combineLatest(
input.availableBalance.map {Int($0.stringRemovingComma()) ?? 0},
model.asDriverOnErrorJustComplete().map { Int($0?.productPrice ?? "0") ?? 0}
).map { availableBalance, productPrice in
return availableBalance > productPrice ? "\(productPrice)" : "\(availableBalance)"
}
return Output(
isError: errorLinker.asDriverOnErrorJustComplete(),
isProgress: progressLinker.asDriverOnErrorJustComplete(),
@ -119,6 +127,7 @@ class RechargePaymentPresenter: ViewModelType {
paymentAmount: model.map {$0?.productPrice ?? "0"}.asDriverOnErrorJustComplete(),
isAvailableUseBalance: isAvailableUseBalance,
finalPaymentAmount: finalPaymentAmount,
maxBalance: maxBalance,
verifySuccess: verifySuccess.asDriverOnErrorJustComplete(),
submitSuccess: submitSuccess.asDriverOnErrorJustComplete()
)

45
GME Remit/Modules/PowerCallModules/RechargePayment/User Interface/View/RechargePayment.storyboard

@ -153,14 +153,39 @@
<stackView opaque="NO" contentMode="scaleToFill" spacing="5" translatesAutoresizingMaskIntoConstraints="NO" id="Rid-0B-kk2">
<rect key="frame" x="0.0" y="40" width="335" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Balance to use" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hXj-jC-Rzc">
<rect key="frame" x="0.0" y="0.0" width="126.5" height="40"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="19"/>
<color key="textColor" name="ThemeText"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="UN2-6J-8og">
<rect key="frame" x="0.0" y="0.0" width="230.5" height="40"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="Balance to use" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hXj-jC-Rzc">
<rect key="frame" x="0.0" y="0.0" width="126.5" height="40"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="19"/>
<color key="textColor" name="ThemeText"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="K7t-Mk-WsV">
<rect key="frame" x="136.5" y="0.0" width="94" height="40"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="253" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xd4-lX-npP">
<rect key="frame" x="0.0" y="5" width="94" height="30"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Regular" family="San Francisco Display" pointSize="19"/>
<inset key="titleEdgeInsets" minX="5" minY="5" maxX="5" maxY="5"/>
<state key="normal" title="Use all">
<color key="titleColor" name="ThemeBlue"/>
</state>
</button>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="Xd4-lX-npP" secondAttribute="bottom" constant="5" id="0pO-6w-cCi"/>
<constraint firstItem="Xd4-lX-npP" firstAttribute="leading" secondItem="K7t-Mk-WsV" secondAttribute="leading" id="6UT-K6-IoC"/>
<constraint firstItem="Xd4-lX-npP" firstAttribute="top" secondItem="K7t-Mk-WsV" secondAttribute="top" constant="5" id="Ty8-1j-EiN"/>
<constraint firstAttribute="trailing" secondItem="Xd4-lX-npP" secondAttribute="trailing" id="jPA-2o-SDH"/>
</constraints>
</view>
</subviews>
</stackView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="- ₩" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6zb-eZ-Fcc">
<rect key="frame" x="131.5" y="0.0" width="187.5" height="40"/>
<rect key="frame" x="235.5" y="0.0" width="83.5" height="40"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="19"/>
<color key="textColor" name="ThemeRed"/>
<nil key="highlightedColor"/>
@ -179,7 +204,7 @@
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uGW-1G-WK3">
<rect key="frame" x="0.0" y="80" width="335" height="30"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="The minimum payment amount is ₩1,000" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="7Bu-hh-vj6">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="The minimum payment amount is ₩1,000" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="7Bu-hh-vj6">
<rect key="frame" x="0.0" y="0.0" width="335" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="Csq-aF-2os"/>
@ -391,6 +416,7 @@
<outlet property="paymentAmountLabel" destination="MkW-zy-Pnl" id="eZ5-gE-kpT"/>
<outlet property="rechargeButton" destination="ndU-4T-cSq" id="Dox-dY-sqD"/>
<outlet property="rechargeButtonContainerView" destination="e74-Cq-lAv" id="BvP-bR-iYk"/>
<outlet property="useAllButton" destination="Xd4-lX-npP" id="I7E-UA-NMe"/>
<outlet property="useBalanceTextField" destination="5h7-OV-JiD" id="AGF-nR-ZcE"/>
</connections>
</viewController>
@ -405,6 +431,9 @@
<namedColor name="ThemeBlack">
<color red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="ThemeBlue">
<color red="0.18799999356269836" green="0.24300000071525574" blue="0.62400001287460327" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="ThemeMainBackground">
<color red="0.097999997437000275" green="0.097999997437000275" blue="0.097999997437000275" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>

14
GME Remit/Modules/PowerCallModules/RechargePayment/User Interface/View/RechargePaymentViewController.swift

@ -46,6 +46,7 @@ class RechargePaymentViewController: UIViewController {
@IBOutlet private weak var balanceLabel: UILabel!
@IBOutlet private weak var paymentAmountLabel: UILabel!
@IBOutlet private weak var useBalanceTextField: UITextField!
@IBOutlet private weak var useAllButton: UIButton!
@IBOutlet private weak var finalPaymentLabel: UILabel!
@IBOutlet private weak var errorMessageLabel: UILabel!
@ -115,6 +116,12 @@ extension RechargePaymentViewController {
availableBalance.onNext(GMEDB.shared.user.string(.availableBalance) ?? "0")
rechargeButton.layer.cornerRadius = 5
errorMessageLabel.alpha = 0
useAllButton.layer.cornerRadius = 5
useAllButton.layer.borderWidth = 1
useAllButton.layer.borderColor = UIColor.themeBlue.cgColor
useAllButton.titleLabel?.minimumScaleFactor = 0.1
useAllButton.titleLabel?.adjustsFontSizeToFitWidth = true
}
private func setBinding() {
@ -242,6 +249,13 @@ extension RechargePaymentViewController {
.disposed(by: disposeBag)
self.view.addGestureRecognizer(tapGestureRecognizer)
useAllButton.rx.tap.asDriver().withLatestFrom(output.maxBalance) {$1}
.drive(onNext: { [weak self] in
self?.useBalanceTextField.text = $0
self?.useBalanceTextField.sendActions(for: .editingChanged)
})
.disposed(by: disposeBag)
}
@objc func keyboardWillShow(_ notification: Notification) {

Loading…
Cancel
Save