diff --git a/GME Remit.xcodeproj/project.pbxproj b/GME Remit.xcodeproj/project.pbxproj index 52e25854..86fe9041 100644 --- a/GME Remit.xcodeproj/project.pbxproj +++ b/GME Remit.xcodeproj/project.pbxproj @@ -165,6 +165,8 @@ 730D78BF227A94F2007E517E /* SearchAddress.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 730D78AF227A94F2007E517E /* SearchAddress.storyboard */; }; 730D78C0227A94F2007E517E /* SearchAddressViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 730D78B0227A94F2007E517E /* SearchAddressViewController.swift */; }; 7310475C226960E70025D77D /* KeychainTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7310475B226960E70025D77D /* KeychainTest.swift */; }; + 73106884236FFBCB00B6F28A /* RechargeHistoryCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73106883236FFBCB00B6F28A /* RechargeHistoryCell.swift */; }; + 7310688623701A1800B6F28A /* RechargeHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7310688523701A1800B6F28A /* RechargeHistory.swift */; }; 731154CA227BF4CA00FEBF7F /* Redeem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731154C9227BF4CA00FEBF7F /* Redeem.swift */; }; 731154CC227C178A00FEBF7F /* APITest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731154CB227C178A00FEBF7F /* APITest.swift */; }; 731154CE227C430C00FEBF7F /* Branch.swift in Sources */ = {isa = PBXBuildFile; fileRef = 731154CD227C430C00FEBF7F /* Branch.swift */; }; @@ -2452,6 +2454,8 @@ 730D78AF227A94F2007E517E /* SearchAddress.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = SearchAddress.storyboard; sourceTree = ""; }; 730D78B0227A94F2007E517E /* SearchAddressViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchAddressViewController.swift; sourceTree = ""; }; 7310475B226960E70025D77D /* KeychainTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainTest.swift; sourceTree = ""; }; + 73106883236FFBCB00B6F28A /* RechargeHistoryCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RechargeHistoryCell.swift; sourceTree = ""; }; + 7310688523701A1800B6F28A /* RechargeHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RechargeHistory.swift; sourceTree = ""; }; 731154C9227BF4CA00FEBF7F /* Redeem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Redeem.swift; sourceTree = ""; }; 731154CB227C178A00FEBF7F /* APITest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APITest.swift; sourceTree = ""; }; 731154CD227C430C00FEBF7F /* Branch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Branch.swift; sourceTree = ""; }; @@ -6538,6 +6542,7 @@ 73549BA2236FDD5600AD75D2 /* Model */ = { isa = PBXGroup; children = ( + 7310688523701A1800B6F28A /* RechargeHistory.swift */, ); path = Model; sourceTree = ""; @@ -6592,6 +6597,7 @@ children = ( 73549BB0236FDD5600AD75D2 /* RechargeHistory.storyboard */, 73549BB1236FDD5600AD75D2 /* RechargeHistoryViewController.swift */, + 73106883236FFBCB00B6F28A /* RechargeHistoryCell.swift */, ); path = View; sourceTree = ""; @@ -14759,6 +14765,7 @@ 73210DA822FBE73100715D6C /* RecipientsWireframeInputOutput.swift in Sources */, 7301979122535135001954AB /* KycWireframe.swift in Sources */, 73185350230EACA400BA9AE3 /* SendMoneyCountryViewModel.swift in Sources */, + 73106884236FFBCB00B6F28A /* RechargeHistoryCell.swift in Sources */, D950BED221549242008367A1 /* HomeServiceType.swift in Sources */, 733A3BA2235557E100E6B87E /* CreditCardView.swift in Sources */, 7301978E22535135001954AB /* KycInteractor.swift in Sources */, @@ -15030,6 +15037,7 @@ 73469FA02293C1B00062946B /* SelectPaymentViewController.swift in Sources */, D97785A4215DC55F00754079 /* TransactionHistoryWireframe.swift in Sources */, D96848CC212D3F2300EF12B1 /* ExchangeRateApiService.swift in Sources */, + 7310688623701A1800B6F28A /* RechargeHistory.swift in Sources */, D9DC108421639E56008F3C51 /* SuccessMessage.swift in Sources */, 7318534E230EACA400BA9AE3 /* SendMoneyTransFerReasonViewModel.swift in Sources */, 73195ABB22FD14D500151434 /* SetupRecipientViewModelInterface.swift in Sources */, diff --git a/GME Remit/APIs/Router/APIRouter.swift b/GME Remit/APIs/Router/APIRouter.swift index cb7b5f21..4aae8f96 100644 --- a/GME Remit/APIs/Router/APIRouter.swift +++ b/GME Remit/APIs/Router/APIRouter.swift @@ -735,15 +735,15 @@ extension APIRouter { ] case .verificationAndBuy(let model): let senderID = GMEDB.shared.user.string(.senderId) ?? "" - let now = Date() - let timestamp = "\(Int64(now.timeIntervalSince1970 * 1000))" - +// let now = Date() +// let timestamp = "\(Int64(now.timeIntervalSince1970 * 1000))" return [ "BuyType" : model.type, "CustomerId" : senderID, "ReceiptId" : model.receiptID ?? "", - "OrderNo" : model.orderNo ?? timestamp, +// "OrderNo" : model.orderNo ?? timestamp, "ChargeType": model.chargeType, + "CardName": model.cardName, "PhoneNo" : model.mobile, "ProductPrice" : model.productPrice ?? "", "UseBalancePrice" : model.useBalancePrice ?? "", diff --git a/GME Remit/Extensions/UIColor+Ext.swift b/GME Remit/Extensions/UIColor+Ext.swift index aeb66a75..c7edb3c6 100644 --- a/GME Remit/Extensions/UIColor+Ext.swift +++ b/GME Remit/Extensions/UIColor+Ext.swift @@ -33,6 +33,10 @@ extension UIColor { return .init(hex: "#303e9f") } + class var themeGreen: UIColor { + return .init(hex: "#08A384") + } + class var themeGray3: UIColor { return UIColor(red:0.67, green:0.67, blue:0.67, alpha:1.0) } diff --git a/GME Remit/Modules/Home/Module Interface/HomeModuleInterface.swift b/GME Remit/Modules/Home/Module Interface/HomeModuleInterface.swift index 0ab46b18..7d294100 100644 --- a/GME Remit/Modules/Home/Module Interface/HomeModuleInterface.swift +++ b/GME Remit/Modules/Home/Module Interface/HomeModuleInterface.swift @@ -8,6 +8,7 @@ protocol HomeModuleInterface: class { func openTransactionHistory() + func openRechargeHistory() func openTodaysRate() func openSendMoney() func openTrackYourTransfer() diff --git a/GME Remit/Modules/Home/User Interface/Presenter/HomePresenter.swift b/GME Remit/Modules/Home/User Interface/Presenter/HomePresenter.swift index 83dcd206..a105a5bd 100644 --- a/GME Remit/Modules/Home/User Interface/Presenter/HomePresenter.swift +++ b/GME Remit/Modules/Home/User Interface/Presenter/HomePresenter.swift @@ -26,6 +26,10 @@ extension HomePresenter: HomeModuleInterface { wireframe?.openTransactionHistory() } + func openRechargeHistory() { + wireframe?.openRechargeHistory() + } + func openTodaysRate() { wireframe?.openTodaysRate() } diff --git a/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift b/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift index e704e2cf..7633b2e3 100644 --- a/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift +++ b/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift @@ -736,6 +736,16 @@ extension HomeViewController: SideMenuDelegate { showSideMenuAboutGme() case .setting: showSideMenuSetting() + case .rechargeHistory: + let kycSubmited = user?.kyc ?? false + let pennyTestComplete = Utility.pennyTestVerified() + + if kycSubmited == true && pennyTestComplete == false { + self.show(error: StringConstants().pennyTestPrimaryBankText) + return + } + + isUserVerified ? (presenter?.openRechargeHistory()) : (self.showUnVerifiedMessage()) } } } diff --git a/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframe.swift b/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframe.swift index 7683e125..31f2c783 100644 --- a/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframe.swift +++ b/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframe.swift @@ -47,6 +47,12 @@ extension HomeWireframe: HomeWireframeInput { } } + func openRechargeHistory() { + if let navigation = self.view.navigationController { + RechargeHistoryWireframe().pushMainView(in: navigation) + } + } + func openSendMoney() { if let navigation = self.view.navigationController { self.sendMoneyWireframe.pushMainView(in: navigation) diff --git a/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframeInput.swift b/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframeInput.swift index 2f4fe494..1383a583 100644 --- a/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframeInput.swift +++ b/GME Remit/Modules/Home/User Interface/Wireframe/HomeWireframeInput.swift @@ -10,6 +10,7 @@ import Foundation protocol HomeWireframeInput: WireframeInput { func openTransactionHistory() + func openRechargeHistory() func openTodaysRate() func openSendMoney() func openTrackYourTransfer() diff --git a/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/Application Logic/Model/RechargeModel.swift b/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/Application Logic/Model/RechargeModel.swift index 463aa0bc..076d089a 100644 --- a/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/Application Logic/Model/RechargeModel.swift +++ b/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/Application Logic/Model/RechargeModel.swift @@ -9,6 +9,7 @@ struct RechargeModel { let type: String let chargeType: String + let cardName: String let mobile: String var productPrice: String? var useBalancePrice: String? @@ -19,11 +20,13 @@ struct RechargeModel { init( type: String, chargeType: String, + cardName: String, mobile: String, price: String ) { self.type = type self.chargeType = chargeType + self.cardName = cardName self.mobile = mobile self.productPrice = price self.useBalancePrice = price diff --git a/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/User Interface/Presenter/PhoneCardRechargePresenter.swift b/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/User Interface/Presenter/PhoneCardRechargePresenter.swift index e4022d4e..3d7b064e 100644 --- a/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/User Interface/Presenter/PhoneCardRechargePresenter.swift +++ b/GME Remit/Modules/PowerCallModules/LocalTopup/PhoneCardRecharge/User Interface/Presenter/PhoneCardRechargePresenter.swift @@ -140,6 +140,7 @@ class PhoneCardRechargePresenter: ViewModelType { return RechargeModel( type: type.value, chargeType: "", + cardName: "", mobile: mobile, price: priceModel?.price ?? "0" ) @@ -147,6 +148,7 @@ class PhoneCardRechargePresenter: ViewModelType { return RechargeModel( type: type.value, chargeType: carrierPlan?.cardType ?? "", + cardName: carrierPlan?.cardName ?? "", mobile: mobile, price: carrierPlan?.facePrice ?? "0" ) @@ -154,6 +156,7 @@ class PhoneCardRechargePresenter: ViewModelType { return RechargeModel( type: type.value, chargeType: dataOnlyType?.cardCode ?? "", + cardName: dataOnlyType?.cardName ?? "", mobile: mobile, price: dataOnlyType?.facePrice ?? "0" ) diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractor.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractor.swift index 07b6708a..89ce38c4 100644 --- a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractor.swift +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractor.swift @@ -14,6 +14,7 @@ class RechargeHistoryInteractor { weak var output: RechargeHistoryInteractorOutput? private let service: RechargeHistoryServiceType + private var histories: [RechargeHistory]? // MARK: Initialization @@ -26,5 +27,21 @@ class RechargeHistoryInteractor { // MARK: RechargeHistory interactor input interface extension RechargeHistoryInteractor: RechargeHistoryInteractorInput { + func fetchHistory(from: String, to: String) { + service.fetchHistory( + from: from, + to: to, + success: {[weak self] in + self?.histories = $0 + self?.output?.setModel(with: $0) + }, + failure: {[weak self] in + self?.output?.setError(with: $0) + } + ) + } + func fetchFilteredHistory(search text: String) { + output?.setModel(with: histories?.filter {text == "" || $0.cellPhone?.contains(text) ?? false} ?? []) + } } diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractorIO.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractorIO.swift index df693f34..28048681 100644 --- a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractorIO.swift +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Interactor/RechargeHistoryInteractorIO.swift @@ -7,9 +7,11 @@ // protocol RechargeHistoryInteractorInput: class { - + func fetchHistory(from: String, to: String) + func fetchFilteredHistory(search text: String) } protocol RechargeHistoryInteractorOutput: class { - + func setModel(with model: [RechargeHistory]) + func setError(with error: Error) } diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Model/RechargeHistory.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Model/RechargeHistory.swift new file mode 100644 index 00000000..77f73124 --- /dev/null +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Model/RechargeHistory.swift @@ -0,0 +1,29 @@ +// +// RechargeHistory.swift +// GME Remit +// +// Created by InKwon James Kim on 2019/11/04. +// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. +// + +import ObjectMapper + +struct RechargeHistory: Mappable { + var cardName: String? + var rechargeDate: String? + var cellPhone: String? + var carrier: String? + var amount: String? + var status: String? + + init?(map: Map) {} + + mutating func mapping(map: Map) { + cardName <- map["CardName"] + rechargeDate <- map["RechargeDate"] + cellPhone <- map["CellPhone"] + carrier <- map["Carrier"] + amount <- map["Amount"] + status <- map["Status"] + } +} diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryService.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryService.swift index aa89ec9d..930f50a5 100644 --- a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryService.swift +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryService.swift @@ -9,5 +9,65 @@ import Foundation class RechargeHistoryService: RechargeHistoryServiceType { - + func fetchHistory( + from: String, + to: String, + success: @escaping ([RechargeHistory]) -> Void, + failure: @escaping (Error) -> Void + ) { + //FIXME: Test + let text = +""" +{ + "Id" : "", + "Extra" : "", + "Extra2" : "", + "Data" : [ + { + "CardName": "Test-001", + "RechargeDate": "2019-05-04", + "CellPhone": "01052850125", + "Carrier": "SK Telecom", + "Amount": "39000", + "Status": "W" + }, + { + "CardName": "Test-002", + "RechargeDate": "2019-06-01", + "CellPhone": "01052850125", + "Carrier": "SK Telecom", + "Amount": "39000", + "Status": "C" + }, + { + "CardName": "Test-003", + "RechargeDate": "2019-07-05", + "CellPhone": "01052850125", + "Carrier": "SK Telecom", + "Amount": "39000", + "Status": "R" + }, + { + "CardName": "Test-004", + "RechargeDate": "2019-08-10", + "CellPhone": "01052850125", + "Carrier": "SK Telecom", + "Amount": "39000", + "Status": "R" + } + ], + "ErrorCode" : "0", + "Msg" : "Success" +} +""" + guard + let json = ResponseContainerArray(JSONString: text), + let data = json.data else { + let error = NSError(domain: "TEST data error", code: 0, message: "Wrong Test Data") + failure(error) + return + } + + success(data) + } } diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryServiceType.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryServiceType.swift index 998aac71..8b38e0a1 100644 --- a/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryServiceType.swift +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/Application Logic/Service/RechargeHistoryServiceType.swift @@ -7,5 +7,10 @@ // protocol RechargeHistoryServiceType: class { - + func fetchHistory( + from: String, + to: String, + success: @escaping ([RechargeHistory]) -> Void, + failure: @escaping (Error) -> Void + ) } diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/Presenter/RechargeHistoryPresenter.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/Presenter/RechargeHistoryPresenter.swift index 258bb4d9..63c8add6 100644 --- a/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/Presenter/RechargeHistoryPresenter.swift +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/Presenter/RechargeHistoryPresenter.swift @@ -13,11 +13,15 @@ class RechargeHistoryPresenter: ViewModelType { var interactor: RechargeHistoryInteractorInput? var wireframe: RechargeHistoryWireframeInput? - struct Input {} + struct Input { + let viewWillAppear: Driver + let searchText: Driver + } struct Output { let isError: Driver let isProgress: Driver + let histories: Driver<[RechargeHistory]> } private let disposeBag = DisposeBag() @@ -25,15 +29,32 @@ class RechargeHistoryPresenter: ViewModelType { private let progressLinker = PublishSubject() private let errorLinker = PublishSubject() + private let histories = PublishSubject<[RechargeHistory]>() + func transform(input: Input) -> Output { + input.viewWillAppear.drive(onNext: {[weak self] in + self?.interactor?.fetchHistory(from: "", to: "") + }).disposed(by: disposeBag) + + input.searchText.drive(onNext: { [weak self] in + self?.interactor?.fetchFilteredHistory(search: $0) + }).disposed(by: disposeBag) + return Output( isError: errorLinker.asDriverOnErrorJustComplete(), - isProgress: progressLinker.asDriverOnErrorJustComplete() + isProgress: progressLinker.asDriverOnErrorJustComplete(), + histories: histories.asDriverOnErrorJustComplete() ) } } // MARK: RechargeHistory interactor output interface extension RechargeHistoryPresenter: RechargeHistoryInteractorOutput { + func setModel(with model: [RechargeHistory]) { + histories.onNext(model) + } + func setError(with error: Error) { + errorLinker.onNext(error) + } } diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistory.storyboard b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistory.storyboard index 1660d550..b120324a 100644 --- a/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistory.storyboard +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistory.storyboard @@ -20,180 +20,325 @@ - + - - + + - - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - + + + - + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - - - - - - - - - + + + + + + + + + + + + @@ -203,7 +348,21 @@ - + + + + + + + + + + + + + + + diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistoryCell.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistoryCell.swift new file mode 100644 index 00000000..c72bcede --- /dev/null +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistoryCell.swift @@ -0,0 +1,72 @@ +// +// RechargeHistoryCell.swift +// GME Remit +// +// Created by InKwon James Kim on 2019/11/04. +// Copyright © 2019 Gobal Money Express Co. Ltd. All rights reserved. +// + +import UIKit + +class RechargeHistoryCell: UITableViewCell { + private enum Status: String { + case recharged = "R" + case canceled = "C" + case waiting = "W" + + var name: String { + switch self { + case .recharged: + return "RECHARGED" + case .canceled: + return "CANCELED" + case .waiting: + return "WAITING" + } + } + + var color: UIColor { + switch self { + case .recharged: + return .themeBlue + case .canceled: + return .themeRed + case .waiting: + return .themeGreen + } + } + } + + @IBOutlet private weak var dateLabel: UILabel! + @IBOutlet private weak var cellPhoneLabel: UILabel! + @IBOutlet private weak var cellPhoneCarrierLabel: UILabel! + @IBOutlet private weak var rechargeTypeLabel: UILabel! + @IBOutlet private weak var rechargeAmountLabel: UILabel! + @IBOutlet private weak var rechargeStatusLabel: UILabel! + + override func awakeFromNib() { + super.awakeFromNib() + // Initialization code + } + + func setModel(with model: RechargeHistory) { + guard let type = Status(rawValue: model.status ?? "C") else { + rechargeStatusLabel.text = Status.canceled.name + rechargeStatusLabel.backgroundColor = Status.canceled.color + return + } + + rechargeStatusLabel.text = type.name + rechargeStatusLabel.backgroundColor = type.color + + dateLabel.text = model.rechargeDate + cellPhoneLabel.text = model.cellPhone + cellPhoneCarrierLabel.text = model.carrier + rechargeTypeLabel.text = model.cardName + rechargeAmountLabel.text = model.amount?.decimalToCurrency() + + rechargeStatusLabel.layer.cornerRadius = 5 + + layoutIfNeeded() + } +} diff --git a/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistoryViewController.swift b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistoryViewController.swift index ee3ae281..59c13584 100644 --- a/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistoryViewController.swift +++ b/GME Remit/Modules/PowerCallModules/RechargeHistory/User Interface/View/RechargeHistoryViewController.swift @@ -19,6 +19,13 @@ class RechargeHistoryViewController: UIViewController { // MARK: Computed Properties // MARK: IBOutlets + @IBOutlet private weak var searchBar: UISearchBar! + @IBOutlet private weak var calandarButton: UIButton! + @IBOutlet private weak var periodView: UIView! + @IBOutlet private weak var periodViewCloseButton: UIButton! + @IBOutlet private weak var errorLabel: UILabel! + + @IBOutlet weak var tableView: UITableView! // MARK: VC's Life cycle override func viewDidLoad() { @@ -28,6 +35,7 @@ class RechargeHistoryViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) + setupNormalNavigation() } override func viewWillDisappear(_ animated: Bool) { @@ -48,7 +56,7 @@ extension RechargeHistoryViewController { } private func setUI() { - + periodView.isHidden = true } private func setUIBinding() { @@ -56,7 +64,15 @@ extension RechargeHistoryViewController { } private func setBinding() { - let input = RechargeHistoryPresenter.Input() + let viewWillAppear = rx.sentMessage(#selector(UIViewController.viewWillAppear(_:))) + .mapToVoid() + .asDriverOnErrorJustComplete() + + let input = RechargeHistoryPresenter.Input( + viewWillAppear: viewWillAppear, + searchText: searchBar.rx.text.orEmpty.asDriver() + ) + let output = presenter.transform(input: input) output.isError @@ -68,5 +84,16 @@ extension RechargeHistoryViewController { .drive( onNext: { $0 ? self.showProgressHud() : self.hideProgressHud() } ).disposed(by: disposeBag) + + output.histories + .drive( + tableView.rx.items(cellIdentifier: "RechargeHistoryCell") + ) { (_, element: RechargeHistory, cell: RechargeHistoryCell) in + cell.setModel(with: element) + }.disposed(by: disposeBag) + + output.histories.map {$0.count != 0} + .drive(errorLabel.rx.isHidden) + .disposed(by: disposeBag) } } diff --git a/GME Remit/Modules/RemittanceModules/TransactionHistoryModules/TransactionHistory/User Interface/View/TransactionHistory.storyboard b/GME Remit/Modules/RemittanceModules/TransactionHistoryModules/TransactionHistory/User Interface/View/TransactionHistory.storyboard index d55db911..f1a22e04 100644 --- a/GME Remit/Modules/RemittanceModules/TransactionHistoryModules/TransactionHistory/User Interface/View/TransactionHistory.storyboard +++ b/GME Remit/Modules/RemittanceModules/TransactionHistoryModules/TransactionHistory/User Interface/View/TransactionHistory.storyboard @@ -81,7 +81,7 @@