Browse Source

add fetch branch request into GMEContact module

pull/1/head
james 5 years ago
parent
commit
6fe7fc4270
  1. 36
      GMERemittance/Module/GmeContacts/Application Logic/Interactor/GmeContactsInteractor.swift
  2. 5
      GMERemittance/Module/GmeContacts/Application Logic/Interactor/GmeContactsInteractorIO.swift
  3. 30
      GMERemittance/Module/GmeContacts/Application Logic/Service/GmeContactsService.swift
  4. 7
      GMERemittance/Module/GmeContacts/Application Logic/Service/GmeContactsServiceType.swift
  5. 2
      GMERemittance/Module/GmeContacts/Module Interface/GmeContactsModuleInterface.swift
  6. 33
      GMERemittance/Module/GmeContacts/User Interface/Presenter/GmeContactsPresenter.swift
  7. 357
      GMERemittance/Module/GmeContacts/User Interface/View/GmeContactsViewController.swift
  8. 6
      GMERemittance/Module/GmeContacts/User Interface/View/GmeContactsViewInterface.swift
  9. 43
      GMERemittance/Module/GmeContacts/User Interface/Wireframe/GmeContactsWireframe.swift
  10. 2
      GMERemittance/Module/GmeContacts/User Interface/Wireframe/GmeContactsWireframeInput.swift
  11. 6
      GMERemittance/Module/RewardModules/DetailOrder/User Interface/View/DetailOrderViewController.swift
  12. 24
      GMERemittance/Module/RewardModules/OrderHistory/Application Logic/Interactor/OrderHistoryInteractor.swift
  13. 5
      GMERemittance/Module/RewardModules/OrderHistory/Application Logic/Model/Order.swift
  14. 81
      GMERemittance/Module/RewardModules/OrderHistory/User Interface/View/OrderHistory.storyboard
  15. 15
      GMERemittance/Module/RewardModules/OrderHistory/User Interface/View/OrderHistoryViewController.swift
  16. 82
      GMERemittance/Module/RewardModules/Redeem/Application Logic/Interactor/RedeemInteractor.swift
  17. 26
      GMERemittance/Module/RewardModules/Redeem/Application Logic/Interactor/RedeemInteractorIO.swift
  18. 33
      GMERemittance/Module/RewardModules/Redeem/Application Logic/Model/Branch.swift
  19. 36
      GMERemittance/Module/RewardModules/Redeem/Application Logic/Model/BranchContainer.swift
  20. 20
      GMERemittance/Module/RewardModules/Redeem/Application Logic/Model/Redeem.swift
  21. 172
      GMERemittance/Module/RewardModules/Redeem/Application Logic/Service/RedeemService.swift
  22. 28
      GMERemittance/Module/RewardModules/Redeem/Application Logic/Service/RedeemServiceType.swift
  23. 16
      GMERemittance/Module/RewardModules/Redeem/Module Interface/RedeemModuleInterface.swift
  24. 160
      GMERemittance/Module/RewardModules/Redeem/User Interface/Presenter/RedeemPresenter.swift
  25. 2
      GMERemittance/Module/RewardModules/Redeem/User Interface/View/Redeem.storyboard
  26. 32
      GMERemittance/Module/RewardModules/Redeem/User Interface/View/RedeemViewController.swift
  27. 24
      GMERemittance/Module/RewardModules/Redeem/User Interface/View/RedeemViewInterface.swift
  28. 88
      GMERemittance/Module/RewardModules/Redeem/User Interface/Wireframe/RedeemWireframe.swift
  29. 8
      GMERemittance/Module/RewardModules/Redeem/User Interface/Wireframe/RedeemWireframeInput.swift
  30. 40
      GMERemittance/Module/RewardModules/Reward/Application Logic/Interactor/RewardInteractor.swift
  31. 6
      GMERemittance/Module/RewardModules/Reward/Application Logic/Interactor/RewardInteractorIO.swift
  32. 30
      GMERemittance/Module/RewardModules/Reward/Application Logic/Model/RewardProduct.swift
  33. 38
      GMERemittance/Module/RewardModules/Reward/Application Logic/Model/RewardProductContainer.swift
  34. 52
      GMERemittance/Module/RewardModules/Reward/Application Logic/Service/RewardService.swift
  35. 12
      GMERemittance/Module/RewardModules/Reward/Application Logic/Service/RewardServiceType.swift
  36. 4
      GMERemittance/Module/RewardModules/Reward/Module Interface/RewardModuleInterface.swift
  37. 50
      GMERemittance/Module/RewardModules/Reward/User Interface/Presenter/RewardPresenter.swift
  38. 25
      GMERemittance/Module/RewardModules/Reward/User Interface/View/Cell/RewardItemCollectionViewCell.swift
  39. 11
      GMERemittance/Module/RewardModules/Reward/User Interface/View/Reward.storyboard
  40. 70
      GMERemittance/Module/RewardModules/Reward/User Interface/View/RewardViewController.swift
  41. 12
      GMERemittance/Module/RewardModules/Reward/User Interface/View/RewardViewInterface.swift
  42. 48
      GMERemittance/Module/RewardModules/Reward/User Interface/Wireframe/RewardWireframe.swift
  43. 2
      GMERemittance/Module/RewardModules/Reward/User Interface/Wireframe/RewardWireframeInput.swift
  44. 4
      en.lproj/Localizable.strings

36
GMERemittance/Module/GmeContacts/Application Logic/Interactor/GmeContactsInteractor.swift

@ -9,23 +9,31 @@
import Foundation import Foundation
class GmeContactsInteractor { class GmeContactsInteractor {
// MARK: Properties
weak var output: GmeContactsInteractorOutput?
private let service: GmeContactsServiceType
// MARK: Initialization
init(service: GmeContactsServiceType) {
self.service = service
}
// MARK: Converting entities
// MARK: Properties
weak var output: GmeContactsInteractorOutput?
private let service: GmeContactsServiceType
private let model: [Branch]?
// MARK: Initialization
init(service: GmeContactsServiceType, model: [Branch]?) {
self.service = service
self.model = model
}
// MARK: Converting entities
} }
// MARK: GmeContacts interactor input interface // MARK: GmeContacts interactor input interface
extension GmeContactsInteractor: GmeContactsInteractorInput { extension GmeContactsInteractor: GmeContactsInteractorInput {
func fetchBranches() {
service.fetchBranches(
success: {
self.output?.setBranchModel(with: $0)
}){
self.output?.setBranchesError(with: $0)
}
}
} }

5
GMERemittance/Module/GmeContacts/Application Logic/Interactor/GmeContactsInteractorIO.swift

@ -7,9 +7,10 @@
// //
protocol GmeContactsInteractorInput: class { protocol GmeContactsInteractorInput: class {
func fetchBranches()
} }
protocol GmeContactsInteractorOutput: class { protocol GmeContactsInteractorOutput: class {
func setBranchModel(with model: [Branch]?)
func setBranchesError(with error: Error)
} }

30
GMERemittance/Module/GmeContacts/Application Logic/Service/GmeContactsService.swift

@ -9,10 +9,32 @@
import Foundation import Foundation
class GmeContactsService: GmeContactsServiceType { class GmeContactsService: GmeContactsServiceType {
func fetchBranches(
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
) {
// MARK: Properties
let url = baseUrlWithoutVersion + "/v2/reward/branchInfo"
// let url = "http://gmeuat.gmeremit.com:5018/api/v2/reward/branchInfo"
// MARK: Initialization
// MARK: Data management
auth.request(
method: .post,
url: url,
params: nil,
success: { (response: BranchContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(
domain: "Network",
code: 0,
userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
)
failure(error)
}else {
success(response.data)
}
}) { (error) in
failure(error)
}
}
} }

7
GMERemittance/Module/GmeContacts/Application Logic/Service/GmeContactsServiceType.swift

@ -8,6 +8,9 @@
import Foundation import Foundation
protocol GmeContactsServiceType: class {
protocol GmeContactsServiceType: class, ApiServiceType {
func fetchBranches(
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
)
} }

2
GMERemittance/Module/GmeContacts/Module Interface/GmeContactsModuleInterface.swift

@ -7,5 +7,5 @@
// //
protocol GmeContactsModuleInterface: class { protocol GmeContactsModuleInterface: class {
func fetchBranch()
} }

33
GMERemittance/Module/GmeContacts/User Interface/Presenter/GmeContactsPresenter.swift

@ -9,24 +9,35 @@
import Foundation import Foundation
class GmeContactsPresenter { class GmeContactsPresenter {
// MARK: Properties
weak var view: GmeContactsViewInterface?
var interactor: GmeContactsInteractorInput?
var wireframe: GmeContactsWireframeInput?
// MARK: Converting entities
// MARK: Properties
weak var view: GmeContactsViewInterface?
var interactor: GmeContactsInteractorInput?
var wireframe: GmeContactsWireframeInput?
// MARK: Converting entities
} }
// MARK: GmeContacts module interface
// MARK: GmeContacts module interface
extension GmeContactsPresenter: GmeContactsModuleInterface { extension GmeContactsPresenter: GmeContactsModuleInterface {
func fetchBranch() {
view?.startLoading()
interactor?.fetchBranches()
}
} }
// MARK: GmeContacts interactor output interface // MARK: GmeContacts interactor output interface
extension GmeContactsPresenter: GmeContactsInteractorOutput { extension GmeContactsPresenter: GmeContactsInteractorOutput {
func setBranchModel(with model: [Branch]?) {
view?.endLoading()
view?.setBranchModel(with: model)
}
func setBranchesError(with error: Error) {
view?.endLoading()
view?.setBranchesError(with: error)
}
} }

357
GMERemittance/Module/GmeContacts/User Interface/View/GmeContactsViewController.swift

@ -10,205 +10,236 @@ import UIKit
import Localize_Swift import Localize_Swift
class GmeContactsViewController: UIViewController { class GmeContactsViewController: UIViewController {
// MARK: IBOutlets
@IBOutlet weak var tableview: UITableView!
var presenter: GmeContactsModuleInterface?
var contacts: [GmeContacts] = [] {
didSet {
self.tableview.reloadData()
}
}
var model: [Branch]? {
didSet {
guard let model = model
else {
return
}
contacts = model.map{
let branch = GmeContacts()
branch.title = $0.agentName
branch.address = $0.agentAddress
branch.contactNumber = [$0.agentPhone1] as? [String]
return branch
}
}
}
// MARK: Properties
// MARK: VC's Life cycle
override func viewDidLoad() {
super.viewDidLoad()
self.setup()
presenter?.fetchBranch()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationItem.title = "branch_text".localized()
// MARK: IBOutlets
@IBOutlet weak var tableview: UITableView!
var presenter: GmeContactsModuleInterface?
var contacts: [GmeContacts] = [] {
didSet {
self.tableview.reloadData()
}
if self.presentingViewController == nil {
self.navigationItem.rightBarButtonItem = nil
} }
}
// MARK: IBActions
@IBAction func touchClose(_ sender: UIBarButtonItem) {
self.dismiss(animated: true, completion: nil)
}
// MARK: Other Functions
private func setup() {
self.tableview.dataSource = self
self.tableview.delegate = self
// all setup should be done here
self.createTestContacts()
NotificationCenter.default.addObserver(self, selector: #selector(setupTabItem), name: NSNotification.Name(LCLLanguageChangeNotification), object: nil)
}
struct StringConstants {
// MARK: Properties
}
private func createTestContacts() {
// let headOfficeContacts = GmeContacts()
// headOfficeContacts.title = "Head Office"
// headOfficeContacts.address = "325, Jong-ro, Jongno-gu, 03104 Seoul"
// headOfficeContacts.contactNumber = ["15886864"]
// headOfficeContacts.language = "Korean Language Support"
// MARK: VC's Life cycle
let dongdaemunBranchContacts = GmeContacts()
dongdaemunBranchContacts.title = "Dongdaemun Branch"
dongdaemunBranchContacts.address = "315, Jong-ro Jongno-gu, Seoul \n(Dongdaemun Station - Exit 3) \n 서울시 종로구 종로 315"
dongdaemunBranchContacts.contactNumber = ["027635559"]
override func viewDidLoad() {
super.viewDidLoad()
self.viperSetup() // since the viewcontroller in the tabbar is in strong bind with storyboard and segue
self.setup()
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationItem.title = "branch_text".localized()
if self.presentingViewController == nil {
self.navigationItem.rightBarButtonItem = nil
}
}
// MARK: IBActions
@IBAction func touchClose(_ sender: UIBarButtonItem) {
self.dismiss(animated: true, completion: nil)
}
let hwaseongBranchContacts = GmeContacts()
hwaseongBranchContacts.title = "Hwaseong Branch"
hwaseongBranchContacts.address = "1101-1, 3.1 Manse-ro Hyangnam-eup, Hwaseong-si, Gyeonggi-do \n(Baran Market Place) \n 경기도 화성시 향남읍 3.1만세로 1101-1"
hwaseongBranchContacts.contactNumber = ["0313540450"]
// MARK: Other Functions
private func setup() {
self.tableview.dataSource = self
self.tableview.delegate = self
// all setup should be done here
self.createTestContacts()
NotificationCenter.default.addObserver(self, selector: #selector(setupTabItem), name: NSNotification.Name(LCLLanguageChangeNotification), object: nil)
}
let ansanBranchContacts = GmeContacts()
ansanBranchContacts.title = "Ansan Branch"
ansanBranchContacts.address = "2nd floor, 455, Jungang-daero, Danwon-gu, Ansan -si, Gyeonggi-do \n(Entrance of Asian Street) \n 경기도 안산시 단원구 중앙대로 455 2층"
ansanBranchContacts.contactNumber = ["0313626740"]
struct StringConstants {
}
let gimhaeBranchContacts = GmeContacts()
gimhaeBranchContacts.title = "Gimhae Branch"
gimhaeBranchContacts.address = "84, Garak-ro, Gimhae-si, Gyeongsangnam-do,\n(Opposite to Top Mart) \n 경상남도 김해시 가락로 84 "
gimhaeBranchContacts.contactNumber = ["0553295559"]
private func createTestContacts() {
// let headOfficeContacts = GmeContacts()
// headOfficeContacts.title = "Head Office"
// headOfficeContacts.address = "325, Jong-ro, Jongno-gu, 03104 Seoul"
// headOfficeContacts.contactNumber = ["15886864"]
// headOfficeContacts.language = "Korean Language Support"
let dongdaemunBranchContacts = GmeContacts()
dongdaemunBranchContacts.title = "Dongdaemun Branch"
dongdaemunBranchContacts.address = "315, Jong-ro Jongno-gu, Seoul \n(Dongdaemun Station - Exit 3) \n 서울시 종로구 종로 315"
dongdaemunBranchContacts.contactNumber = ["027635559"]
let hwaseongBranchContacts = GmeContacts()
hwaseongBranchContacts.title = "Hwaseong Branch"
hwaseongBranchContacts.address = "1101-1, 3.1 Manse-ro Hyangnam-eup, Hwaseong-si, Gyeonggi-do \n(Baran Market Place) \n 경기도 화성시 향남읍 3.1만세로 1101-1"
hwaseongBranchContacts.contactNumber = ["0313540450"]
let ansanBranchContacts = GmeContacts()
ansanBranchContacts.title = "Ansan Branch"
ansanBranchContacts.address = "2nd floor, 455, Jungang-daero, Danwon-gu, Ansan -si, Gyeonggi-do \n(Entrance of Asian Street) \n 경기도 안산시 단원구 중앙대로 455 2층"
ansanBranchContacts.contactNumber = ["0313626740"]
let gimhaeBranchContacts = GmeContacts()
gimhaeBranchContacts.title = "Gimhae Branch"
gimhaeBranchContacts.address = "84, Garak-ro, Gimhae-si, Gyeongsangnam-do,\n(Opposite to Top Mart) \n 경상남도 김해시 가락로 84 "
gimhaeBranchContacts.contactNumber = ["0553295559"]
let songuriBranchContacts = GmeContacts()
songuriBranchContacts.title = "Songu-ri Branch"
songuriBranchContacts.address = "91, Solmoru-ro, Soheul-eup, Pocheon-si, Gyeonggi-do, Korea\nNext to Nonghyub Bank) \n 경기도 포천시 소흘읍 솔모루로 91"
songuriBranchContacts.contactNumber = ["0315411856"]
let dongdaemunCisBranch = GmeContacts()
dongdaemunCisBranch.title = "Dongdaemun CIS Branch"
dongdaemunCisBranch.address = "2nd floor, 281, Changgyeonggunag-ro Jongno-gu, Seoul\n(Upper floor of Dongdaemun Mart) \n 서울 중구 을지로 42길 5 2층"
dongdaemunCisBranch.contactNumber = ["0221386429", "01030156864"]
let hyehwaBranch = GmeContacts()
hyehwaBranch.title = "Hyehwa Branch"
hyehwaBranch.address = "281, Changgyeonggung-ro, Jongno-gu, Seoul Hyehwa Rotary\n(Right across from Catholic Church) \n 서울특별시 종로구 창경궁로 281"
hyehwaBranch.contactNumber = ["0221386429", "01029706864"]
let gmeContacts = [dongdaemunCisBranch, dongdaemunBranchContacts, hwaseongBranchContacts, ansanBranchContacts, gimhaeBranchContacts, songuriBranchContacts, hyehwaBranch]
self.contacts = gmeContacts
}
private func call(number: String) {
let number = number.removeWhitespacesInBetween()
if let url = URL(string: "tel://\(number)") {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
}
}
override func setupTabItem() {
let image = UIImage.init(named: "ic-agent")
self.tabBarItem = UITabBarItem(title: "branch_text".localized(), image: image, selectedImage: nil)
self.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: UI_USER_INTERFACE_IDIOM() == .pad ? 2 : -6)
let songuriBranchContacts = GmeContacts()
songuriBranchContacts.title = "Songu-ri Branch"
songuriBranchContacts.address = "91, Solmoru-ro, Soheul-eup, Pocheon-si, Gyeonggi-do, Korea\nNext to Nonghyub Bank) \n 경기도 포천시 소흘읍 솔모루로 91"
songuriBranchContacts.contactNumber = ["0315411856"]
let dongdaemunCisBranch = GmeContacts()
dongdaemunCisBranch.title = "Dongdaemun CIS Branch"
dongdaemunCisBranch.address = "2nd floor, 281, Changgyeonggunag-ro Jongno-gu, Seoul\n(Upper floor of Dongdaemun Mart) \n 서울 중구 을지로 42길 5 2층"
dongdaemunCisBranch.contactNumber = ["0221386429", "01030156864"]
let hyehwaBranch = GmeContacts()
hyehwaBranch.title = "Hyehwa Branch"
hyehwaBranch.address = "281, Changgyeonggung-ro, Jongno-gu, Seoul Hyehwa Rotary\n(Right across from Catholic Church) \n 서울특별시 종로구 창경궁로 281"
hyehwaBranch.contactNumber = ["0221386429", "01029706864"]
let gmeContacts = [dongdaemunCisBranch, dongdaemunBranchContacts, hwaseongBranchContacts, ansanBranchContacts, gimhaeBranchContacts, songuriBranchContacts, hyehwaBranch]
self.contacts = gmeContacts
}
private func call(number: String) {
let number = number.removeWhitespacesInBetween()
if let url = URL(string: "tel://\(number)") {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
} }
}
override func setupTabItem() {
let image = UIImage.init(named: "ic-agent")
self.tabBarItem = UITabBarItem(title: "branch_text".localized(), image: image, selectedImage: nil)
self.tabBarItem.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: UI_USER_INTERFACE_IDIOM() == .pad ? 2 : -6)
}
} }
// MARK: GmeContactsViewInterface // MARK: GmeContactsViewInterface
extension GmeContactsViewController: GmeContactsViewInterface { extension GmeContactsViewController: GmeContactsViewInterface {
func setBranchModel(with model: [Branch]?) {
self.model = model
}
func setBranchesError(with error: Error){
alertWithOk(message: error.localizedDescription)
}
func startLoading(){
showProgressHud()
}
func endLoading(){
hideProgressHud()
}
} }
extension GmeContactsViewController { extension GmeContactsViewController {
func viperSetup() {
let service = GmeContactsService()
let interactor = GmeContactsInteractor(service: service)
let presenter = GmeContactsPresenter()
let wireframe = GmeContactsWireframe()
self.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = wireframe
presenter.view = self
wireframe.view = self
}
func viperSetup() {
let service = GmeContactsService()
let interactor = GmeContactsInteractor(service: service, model: nil)
let presenter = GmeContactsPresenter()
let wireframe = GmeContactsWireframe()
self.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = wireframe
presenter.view = self
wireframe.view = self
}
} }
extension GmeContactsViewController: UITableViewDelegate { extension GmeContactsViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
print(indexPath.row)
if indexPath.row == 0 {return 10}
return UITableViewAutomaticDimension
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
print(indexPath.row)
if indexPath.row == 0 {return 10}
return UITableViewAutomaticDimension
}
} }
extension GmeContactsViewController: UITableViewDataSource { extension GmeContactsViewController: UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return contacts.count + 1
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return contacts.count + 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "EmptyTableViewCell") as! EmptyTableViewCell
return cell
} }
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
let cell = tableView.dequeueReusableCell(withIdentifier: "EmptyTableViewCell") as! EmptyTableViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "GmeContactsTableViewCell") as! GmeContactsTableViewCell
cell.contact = self.contacts.elementAt(index: indexPath.row - 1)
cell.delegate = self
cell.index = indexPath.row - 1
cell.setup()
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "GmeContactsTableViewCell") as! GmeContactsTableViewCell
cell.contact = self.contacts.elementAt(index: indexPath.row - 1)
cell.delegate = self
cell.index = indexPath.row - 1
cell.setup()
return cell
}
} }
extension GmeContactsViewController: GmeContactCallDelegate { extension GmeContactsViewController: GmeContactCallDelegate {
func call(index: Int?) {
guard let index = index else {return}
if let contact = self.contacts.elementAt(index: index) {
let numbers = contact.contactNumber
let alert = UIAlertController(title:nil, message:"help_you_text".localized(), preferredStyle: .actionSheet)
numbers?.forEach({ number in
let action = UIAlertAction.init(title: "\(number)", style: UIAlertActionStyle.default, handler: { action in
self.call(number: number)
})
alert.addAction(action)
})
alert.view.tintColor = UIColor.darkGray
alert.addAction(UIAlertAction(title: "cancel_text".localized(), style: UIAlertActionStyle.cancel, handler: nil))
present(alert, animated: true, completion: nil)
}
func call(index: Int?) {
guard let index = index else {return}
if let contact = self.contacts.elementAt(index: index) {
let numbers = contact.contactNumber
let alert = UIAlertController(title:nil, message:"help_you_text".localized(), preferredStyle: .actionSheet)
numbers?.forEach({ number in
let action = UIAlertAction.init(title: "\(number)", style: UIAlertActionStyle.default, handler: { action in
self.call(number: number)
})
alert.addAction(action)
})
alert.view.tintColor = UIColor.darkGray
alert.addAction(UIAlertAction(title: "cancel_text".localized(), style: UIAlertActionStyle.cancel, handler: nil))
present(alert, animated: true, completion: nil)
} }
}
} }

6
GMERemittance/Module/GmeContacts/User Interface/View/GmeContactsViewInterface.swift

@ -7,5 +7,9 @@
// //
protocol GmeContactsViewInterface: class { protocol GmeContactsViewInterface: class {
func setBranchModel(with model: [Branch]?)
func setBranchesError(with error: Error)
func startLoading()
func endLoading()
} }

43
GMERemittance/Module/GmeContacts/User Interface/Wireframe/GmeContactsWireframe.swift

@ -9,26 +9,35 @@
import UIKit import UIKit
class GmeContactsWireframe { class GmeContactsWireframe {
weak var view: UIViewController!
weak var view: UIViewController!
private var model: [Branch]?
} }
extension GmeContactsWireframe: GmeContactsWireframeInput { extension GmeContactsWireframe: GmeContactsWireframeInput {
var storyboardName: String {return "GmeContacts"}
func getMainView() -> UIViewController {
let service = GmeContactsService()
let presenter = GmeContactsPresenter()
let viewController = viewControllerFromStoryboard(of: GmeContactsViewController.self)
let interactor = GmeContactsInteractor(service: service, model: model)
var storyboardName: String {return "GmeContacts"}
viewController.setupTabItem()
viewController.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = self
presenter.view = viewController
let _ = viewController.view
view = viewController
return viewController
}
func presentWithBranchModel(_ model: [Branch]?, on source: UIViewController){
self.model = model
let mainViewController = getMainView()
func getMainView() -> UIViewController {
let service = GmeContactsService()
let interactor = GmeContactsInteractor(service: service)
let presenter = GmeContactsPresenter()
let viewController = viewControllerFromStoryboard(of: GmeContactsViewController.self)
viewController.setupTabItem()
viewController.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = self
presenter.view = viewController
let _ = viewController.view
self.view = viewController
return viewController
}
openViewControllerWithNavigation(viewController: mainViewController, source: source)
}
} }

2
GMERemittance/Module/GmeContacts/User Interface/Wireframe/GmeContactsWireframeInput.swift

@ -9,5 +9,5 @@
import Foundation import Foundation
protocol GmeContactsWireframeInput: WireframeInput { protocol GmeContactsWireframeInput: WireframeInput {
func presentWithBranchModel(_ model: [Branch]?, on source: UIViewController)
} }

6
GMERemittance/Module/RewardModules/DetailOrder/User Interface/View/DetailOrderViewController.swift

@ -26,15 +26,15 @@ class DetailOrderViewController: UIViewController {
receiverNameLabel.text = order.recvName receiverNameLabel.text = order.recvName
mobileNumberLabel.text = order.recvPhoneNumber mobileNumberLabel.text = order.recvPhoneNumber
// pickupBranchLabel.text = order.recvType == "1" ? order.recvAddress : order.branchCode
pickupBranchLabel.text = order.branchName
productNameLabel.text = order.productName productNameLabel.text = order.productName
productPointLabel.text = order.usePoint productPointLabel.text = order.usePoint
orderStatusLabel.text = status.message orderStatusLabel.text = status.message
orderDateLabel.text = order.createdDate orderDateLabel.text = order.createdDate
//TODO:
// orderReceiveDateLabel.text = order.recvDate
orderReceiveDateLabel.text = order.recvDate
orderIDNumberLabel.text = order.orderID orderIDNumberLabel.text = order.orderID
orderTypeLabel.text = order.recvType == "1" ? "Deliver" : "pickup_from_branch".localized() orderTypeLabel.text = order.recvType == "1" ? "Deliver" : "pickup_from_branch".localized()
} }

24
GMERemittance/Module/RewardModules/OrderHistory/Application Logic/Interactor/OrderHistoryInteractor.swift

@ -29,31 +29,11 @@ class OrderHistoryInteractor {
extension OrderHistoryInteractor: OrderHistoryInteractorInput { extension OrderHistoryInteractor: OrderHistoryInteractorInput {
func fetchOrderHistory(from startDate: String, to endDate: String) { func fetchOrderHistory(from startDate: String, to endDate: String) {
let from: String
let to: String
if startDate == "" && endDate == "" {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
let monthsToAdd = -3
let currentDate = Date()
var dateComponent = DateComponents()
dateComponent.month = monthsToAdd
let futureDate = Calendar.current.date(byAdding: dateComponent, to: currentDate)
to = formatter.string(from: currentDate)
from = formatter.string(from: futureDate!)
} else {
from = startDate
to = endDate
}
service.fetchOrderHistory( service.fetchOrderHistory(
from: from,
to: to,
from: startDate,
to: endDate,
success: {[weak self] in success: {[weak self] in
guard let `self` = self else { guard let `self` = self else {
return return

5
GMERemittance/Module/RewardModules/OrderHistory/Application Logic/Model/Order.swift

@ -24,6 +24,8 @@ struct Order: Mappable {
var orderStatus: String? var orderStatus: String?
var createdDate: String? var createdDate: String?
var modifiedDate: String? var modifiedDate: String?
var branchName: String?
var recvDate: String?
init?(map: Map) { } init?(map: Map) { }
@ -42,6 +44,9 @@ struct Order: Mappable {
orderStatus <- map["orderStatus"] orderStatus <- map["orderStatus"]
createdDate <- map["createdDate"] createdDate <- map["createdDate"]
modifiedDate <- map["modifiedDate"] modifiedDate <- map["modifiedDate"]
recvDate <- map["recvDate"]
branchName <- map["branchName"]
} }
} }

81
GMERemittance/Module/RewardModules/OrderHistory/User Interface/View/OrderHistory.storyboard

@ -58,41 +58,66 @@
</constraints> </constraints>
</stackView> </stackView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="97g-ut-B3f"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="97g-ut-B3f">
<rect key="frame" x="0.0" y="76" width="375" height="35"/>
<rect key="frame" x="0.0" y="81" width="375" height="35"/>
<subviews> <subviews>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="PGn-S6-cUw">
<rect key="frame" x="125" y="-7.5" width="125" height="50"/>
<view clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jT4-tF-K3X">
<rect key="frame" x="10" y="1" width="355" height="33"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JNb-rQ-S60">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="16"/>
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="~" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VoE-31-HDw">
<rect key="frame" x="58" y="0.0" width="9" height="50"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="16"/>
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IfM-7I-OUY">
<rect key="frame" x="75" y="0.0" width="50" height="50"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="16"/>
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<stackView opaque="NO" contentMode="scaleToFill" spacing="8" translatesAutoresizingMaskIntoConstraints="NO" id="PGn-S6-cUw">
<rect key="frame" x="115" y="-8.5" width="125" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JNb-rQ-S60">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="16"/>
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="~" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VoE-31-HDw">
<rect key="frame" x="58" y="0.0" width="9" height="50"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="16"/>
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IfM-7I-OUY">
<rect key="frame" x="75" y="0.0" width="50" height="50"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="16"/>
<color key="textColor" red="0.2901960784" green="0.2901960784" blue="0.2901960784" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MsW-Cu-WAq">
<rect key="frame" x="330" y="9" width="15" height="15"/>
<constraints>
<constraint firstAttribute="height" constant="15" id="QEH-pM-M9B"/>
<constraint firstAttribute="width" constant="15" id="VaT-i2-nM8"/>
</constraints>
<state key="normal" title="Button" image="ic_error"/>
<connections>
<action selector="touchHidePerioidContentView:" destination="HSb-ou-7T5" eventType="touchUpInside" id="T9w-yA-L2x"/>
</connections>
</button>
</subviews> </subviews>
</stackView>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="PGn-S6-cUw" firstAttribute="centerX" secondItem="jT4-tF-K3X" secondAttribute="centerX" id="2tu-H9-Ogk"/>
<constraint firstItem="MsW-Cu-WAq" firstAttribute="centerY" secondItem="jT4-tF-K3X" secondAttribute="centerY" id="MoP-cW-gz4"/>
<constraint firstItem="PGn-S6-cUw" firstAttribute="centerY" secondItem="jT4-tF-K3X" secondAttribute="centerY" id="Sm7-eC-hTb"/>
<constraint firstAttribute="trailing" secondItem="MsW-Cu-WAq" secondAttribute="trailing" constant="10" id="mfx-lA-gcl"/>
</constraints>
</view>
</subviews> </subviews>
<color key="backgroundColor" red="0.90588235289999997" green="0.92941176469999998" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/> <color key="backgroundColor" red="0.90588235289999997" green="0.92941176469999998" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="calibratedRGB"/>
<constraints> <constraints>
<constraint firstItem="PGn-S6-cUw" firstAttribute="centerY" secondItem="97g-ut-B3f" secondAttribute="centerY" id="Pgj-sa-DAu"/>
<constraint firstItem="jT4-tF-K3X" firstAttribute="top" secondItem="97g-ut-B3f" secondAttribute="top" constant="1" id="1Td-qn-jSx"/>
<constraint firstItem="jT4-tF-K3X" firstAttribute="leading" secondItem="97g-ut-B3f" secondAttribute="leading" constant="10" id="5kQ-G9-uX0"/>
<constraint firstAttribute="bottom" secondItem="jT4-tF-K3X" secondAttribute="bottom" constant="1" id="P1B-IH-n80"/>
<constraint firstAttribute="height" constant="35" id="WwQ-Eb-nRV"/> <constraint firstAttribute="height" constant="35" id="WwQ-Eb-nRV"/>
<constraint firstItem="PGn-S6-cUw" firstAttribute="centerX" secondItem="97g-ut-B3f" secondAttribute="centerX" id="nsh-Ev-EJA"/>
<constraint firstAttribute="trailing" secondItem="jT4-tF-K3X" secondAttribute="trailing" constant="10" id="fIr-Rj-2P8"/>
</constraints> </constraints>
</view> </view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="IWs-Lw-Lzy"> <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="IWs-Lw-Lzy">
<rect key="frame" x="0.0" y="111" width="375" height="511"/>
<rect key="frame" x="0.0" y="121" width="375" height="501"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<view key="tableFooterView" contentMode="scaleToFill" id="2ni-7Z-yrb"> <view key="tableFooterView" contentMode="scaleToFill" id="2ni-7Z-yrb">
<rect key="frame" x="0.0" y="130" width="375" height="44"/> <rect key="frame" x="0.0" y="130" width="375" height="44"/>
@ -284,11 +309,11 @@
<constraint firstItem="qT6-24-ye4" firstAttribute="top" secondItem="IWs-Lw-Lzy" secondAttribute="bottom" constant="5" id="6Gr-8g-ThY"/> <constraint firstItem="qT6-24-ye4" firstAttribute="top" secondItem="IWs-Lw-Lzy" secondAttribute="bottom" constant="5" id="6Gr-8g-ThY"/>
<constraint firstItem="qT6-24-ye4" firstAttribute="trailing" secondItem="Zt6-f6-JOC" secondAttribute="trailing" id="6SQ-d1-pNh"/> <constraint firstItem="qT6-24-ye4" firstAttribute="trailing" secondItem="Zt6-f6-JOC" secondAttribute="trailing" id="6SQ-d1-pNh"/>
<constraint firstItem="SpX-eE-pj8" firstAttribute="top" secondItem="Zt6-f6-JOC" secondAttribute="top" id="AfL-1V-hq8"/> <constraint firstItem="SpX-eE-pj8" firstAttribute="top" secondItem="Zt6-f6-JOC" secondAttribute="top" id="AfL-1V-hq8"/>
<constraint firstItem="IWs-Lw-Lzy" firstAttribute="top" secondItem="97g-ut-B3f" secondAttribute="bottom" id="I5M-n1-3wt"/>
<constraint firstItem="IWs-Lw-Lzy" firstAttribute="top" secondItem="97g-ut-B3f" secondAttribute="bottom" constant="5" id="I5M-n1-3wt"/>
<constraint firstItem="97g-ut-B3f" firstAttribute="trailing" secondItem="Zt6-f6-JOC" secondAttribute="trailing" id="Szl-XX-RkQ"/> <constraint firstItem="97g-ut-B3f" firstAttribute="trailing" secondItem="Zt6-f6-JOC" secondAttribute="trailing" id="Szl-XX-RkQ"/>
<constraint firstItem="qT6-24-ye4" firstAttribute="leading" secondItem="Zt6-f6-JOC" secondAttribute="leading" id="U3v-v0-7CD"/> <constraint firstItem="qT6-24-ye4" firstAttribute="leading" secondItem="Zt6-f6-JOC" secondAttribute="leading" id="U3v-v0-7CD"/>
<constraint firstItem="SpX-eE-pj8" firstAttribute="trailing" secondItem="Zt6-f6-JOC" secondAttribute="trailing" id="Wr3-hw-cgh"/> <constraint firstItem="SpX-eE-pj8" firstAttribute="trailing" secondItem="Zt6-f6-JOC" secondAttribute="trailing" id="Wr3-hw-cgh"/>
<constraint firstItem="97g-ut-B3f" firstAttribute="top" secondItem="SpX-eE-pj8" secondAttribute="bottom" id="XtF-Gk-Jmv"/>
<constraint firstItem="97g-ut-B3f" firstAttribute="top" secondItem="SpX-eE-pj8" secondAttribute="bottom" constant="5" id="XtF-Gk-Jmv"/>
<constraint firstItem="Zt6-f6-JOC" firstAttribute="bottom" secondItem="qT6-24-ye4" secondAttribute="bottom" constant="5" id="ZGQ-mm-ztl"/> <constraint firstItem="Zt6-f6-JOC" firstAttribute="bottom" secondItem="qT6-24-ye4" secondAttribute="bottom" constant="5" id="ZGQ-mm-ztl"/>
<constraint firstItem="IWs-Lw-Lzy" firstAttribute="leading" secondItem="Zt6-f6-JOC" secondAttribute="leading" id="aZ7-QV-J08"/> <constraint firstItem="IWs-Lw-Lzy" firstAttribute="leading" secondItem="Zt6-f6-JOC" secondAttribute="leading" id="aZ7-QV-J08"/>
<constraint firstItem="SpX-eE-pj8" firstAttribute="leading" secondItem="Zt6-f6-JOC" secondAttribute="leading" id="icE-df-7bq"/> <constraint firstItem="SpX-eE-pj8" firstAttribute="leading" secondItem="Zt6-f6-JOC" secondAttribute="leading" id="icE-df-7bq"/>
@ -304,6 +329,7 @@
<outlet property="orderedColorLabel" destination="3zV-Rv-aOE" id="lpI-j3-fW1"/> <outlet property="orderedColorLabel" destination="3zV-Rv-aOE" id="lpI-j3-fW1"/>
<outlet property="periodView" destination="97g-ut-B3f" id="bD9-AR-f95"/> <outlet property="periodView" destination="97g-ut-B3f" id="bD9-AR-f95"/>
<outlet property="periodViewHeightConstraint" destination="WwQ-Eb-nRV" id="2cf-jr-nPf"/> <outlet property="periodViewHeightConstraint" destination="WwQ-Eb-nRV" id="2cf-jr-nPf"/>
<outlet property="perioidContentView" destination="jT4-tF-K3X" id="yJd-xC-pNR"/>
<outlet property="receivedColorLabel" destination="JUV-Fq-hn5" id="g5q-ih-wi4"/> <outlet property="receivedColorLabel" destination="JUV-Fq-hn5" id="g5q-ih-wi4"/>
<outlet property="searchBar" destination="iE7-rt-xwe" id="wIp-jg-NAz"/> <outlet property="searchBar" destination="iE7-rt-xwe" id="wIp-jg-NAz"/>
<outlet property="startDateLabel" destination="JNb-rQ-S60" id="AHq-zu-xBo"/> <outlet property="startDateLabel" destination="JNb-rQ-S60" id="AHq-zu-xBo"/>
@ -317,6 +343,7 @@
</scenes> </scenes>
<resources> <resources>
<image name="ic_calender" width="25" height="25"/> <image name="ic_calender" width="25" height="25"/>
<image name="ic_error" width="55" height="55"/>
</resources> </resources>
<color key="tintColor" red="0.78177064659999995" green="0.55228364470000002" blue="0.018981300289999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> <color key="tintColor" red="0.78177064659999995" green="0.55228364470000002" blue="0.018981300289999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</document> </document>

15
GMERemittance/Module/RewardModules/OrderHistory/User Interface/View/OrderHistoryViewController.swift

@ -17,6 +17,8 @@ class OrderHistoryViewController: UIViewController {
private lazy var refreshControl = UIRefreshControl() private lazy var refreshControl = UIRefreshControl()
private lazy var isSearch = false
// MARK: Computed Properties // MARK: Computed Properties
private var orders: [Order]? { private var orders: [Order]? {
@ -26,6 +28,7 @@ class OrderHistoryViewController: UIViewController {
orders.count != 0 orders.count != 0
else { else {
noOrderHistoryLabel.isHidden = false noOrderHistoryLabel.isHidden = false
noOrderHistoryLabel.text = isSearch ? "no_search_orders_message".localized() : "no_orders_message".localized()
tableView.reloadData() tableView.reloadData()
return return
} }
@ -40,6 +43,7 @@ class OrderHistoryViewController: UIViewController {
@IBOutlet private weak var tableView: UITableView! @IBOutlet private weak var tableView: UITableView!
@IBOutlet private weak var searchBar: UISearchBar! @IBOutlet private weak var searchBar: UISearchBar!
@IBOutlet private weak var periodView: UIView! @IBOutlet private weak var periodView: UIView!
@IBOutlet private weak var perioidContentView: UIView!
@IBOutlet private weak var noOrderHistoryLabel: UILabel! @IBOutlet private weak var noOrderHistoryLabel: UILabel!
@IBOutlet private weak var startDateLabel: UILabel! @IBOutlet private weak var startDateLabel: UILabel!
@ -63,6 +67,7 @@ class OrderHistoryViewController: UIViewController {
super.viewWillAppear(animated) super.viewWillAppear(animated)
if searchBar.text == "" && startDateLabel.text == ""{ if searchBar.text == "" && startDateLabel.text == ""{
isSearch = false
presenter?.fetchOrders(from: "", to: "") presenter?.fetchOrders(from: "", to: "")
} }
} }
@ -89,10 +94,15 @@ class OrderHistoryViewController: UIViewController {
self.setPeriodViewStatus(isHidden: false) self.setPeriodViewStatus(isHidden: false)
self.searchBar.text?.removeAll() self.searchBar.text?.removeAll()
self.isSearch = true
self.presenter?.fetchOrders(from: startDate, to: endDate) self.presenter?.fetchOrders(from: startDate, to: endDate)
} }
} }
@IBAction func touchHidePerioidContentView(_ sender: Any) {
refresh()
}
} }
// MARK: OrderHistoryViewInterface // MARK: OrderHistoryViewInterface
@ -135,6 +145,8 @@ extension OrderHistoryViewController {
orderedColorLabel.layer.cornerRadius = 5 orderedColorLabel.layer.cornerRadius = 5
receivedColorLabel.layer.cornerRadius = 5 receivedColorLabel.layer.cornerRadius = 5
canceledColorLabel.layer.cornerRadius = 5 canceledColorLabel.layer.cornerRadius = 5
perioidContentView.layer.cornerRadius = 10
} }
private func setMultiLanguage(){ private func setMultiLanguage(){
@ -184,7 +196,7 @@ extension OrderHistoryViewController {
private func refresh() { private func refresh() {
setPeriodViewStatus(isHidden: true) setPeriodViewStatus(isHidden: true)
searchBar.text?.removeAll() searchBar.text?.removeAll()
isSearch = false
presenter?.fetchOrders(from: "", to: "") presenter?.fetchOrders(from: "", to: "")
} }
@ -232,6 +244,7 @@ extension OrderHistoryViewController: UITableViewDelegate {
// MARK: - UISearchBarDelegate // MARK: - UISearchBarDelegate
extension OrderHistoryViewController: UISearchBarDelegate { extension OrderHistoryViewController: UISearchBarDelegate {
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
isSearch = true
presenter?.fetchFilteredOrders(by: searchText) presenter?.fetchFilteredOrders(by: searchText)
} }

82
GMERemittance/Module/RewardModules/Redeem/Application Logic/Interactor/RedeemInteractor.swift

@ -9,53 +9,53 @@
import Foundation import Foundation
class RedeemInteractor { class RedeemInteractor {
// MARK: Properties
weak var output: RedeemInteractorOutput?
private let service: RedeemServiceType
// MARK: Initialization
init(service: RedeemServiceType) {
self.service = service
}
// MARK: Converting entities
// MARK: Properties
weak var output: RedeemInteractorOutput?
private let service: RedeemServiceType
// MARK: Initialization
init(service: RedeemServiceType) {
self.service = service
}
// MARK: Converting entities
} }
// MARK: Redeem interactor input interface // MARK: Redeem interactor input interface
extension RedeemInteractor: RedeemInteractorInput { extension RedeemInteractor: RedeemInteractorInput {
func fetchBranches() {
self.service.fetchBranches(
success: {
self.output?.setBranches(with: $0)
}){
self.output?.setBranchesError(with: $0)
}
}
func viewIsReady(model: RewardProduct?) {
self.output?.result(model: model)
func fetchBranches() {
service.fetchBranches(
success: {
self.output?.setBranches(with: $0)
}){
self.output?.setBranchesError(with: $0)
} }
func submit(with model: Redeem?) {
self.service.submit(
with: model,
success: {
self.output?.submitSuccess()
}) {
self.output?.submitFailure(with: $0)
}
}
func viewIsReady(model: RewardProduct?) {
self.output?.result(model: model)
}
func submit(with model: Redeem?) {
self.service.submit(
with: model,
success: {
self.output?.submitSuccess()
}) {
self.output?.submitFailure(with: $0)
} }
func refreshRewardPoint() {
self.service.fetchUserInfo(success: {
Utility.save(user: $0)
self.output?.successRefreshRewardPoint()
}){
self.output?.failureRefreshRewardPoint(with: $0)
}
}
func refreshRewardPoint() {
self.service.fetchUserInfo(success: {
Utility.save(user: $0)
self.output?.successRefreshRewardPoint()
}){
self.output?.failureRefreshRewardPoint(with: $0)
} }
}
} }

26
GMERemittance/Module/RewardModules/Redeem/Application Logic/Interactor/RedeemInteractorIO.swift

@ -7,20 +7,20 @@
// //
protocol RedeemInteractorInput: class { protocol RedeemInteractorInput: class {
func viewIsReady(model: RewardProduct?)
func fetchBranches()
func submit(with model: Redeem?)
func refreshRewardPoint()
func viewIsReady(model: RewardProduct?)
func fetchBranches()
func submit(with model: Redeem?)
func refreshRewardPoint()
} }
protocol RedeemInteractorOutput: class { protocol RedeemInteractorOutput: class {
func result(model: RewardProduct?)
func setBranches(with model: [Branch]?)
func setBranchesError(with error: Error)
func submitSuccess()
func submitFailure(with error: Error)
func successRefreshRewardPoint()
func failureRefreshRewardPoint(with error: Error)
func result(model: RewardProduct?)
func setBranches(with model: [Branch]?)
func setBranchesError(with error: Error)
func submitSuccess()
func submitFailure(with error: Error)
func successRefreshRewardPoint()
func failureRefreshRewardPoint(with error: Error)
} }

33
GMERemittance/Module/RewardModules/Redeem/Application Logic/Model/Branch.swift

@ -10,17 +10,26 @@ import Foundation
import ObjectMapper import ObjectMapper
struct Branch: Mappable { struct Branch: Mappable {
var agentID: String?
var agentName: String?
init?(map: Map) {
}
mutating func mapping(map: Map) {
self.agentID <- map["agentId"]
self.agentName <- map["agentName"]
}
var agentID: String?
var agentName: String?
var agentPhone1: String?
var agentAddress: String?
var agentZip: String?
var agentState: String?
var agentCity: String?
init?(map: Map) {
}
mutating func mapping(map: Map) {
agentID <- map["agentId"]
agentName <- map["agentName"]
agentPhone1 <- map["agentPhone1"]
agentAddress <- map["agentAddress"]
agentZip <- map["agentZip"]
agentState <- map["agentState"]
agentCity <- map["agentCity"]
}
} }

36
GMERemittance/Module/RewardModules/Redeem/Application Logic/Model/BranchContainer.swift

@ -10,23 +10,23 @@ import Foundation
import ObjectMapper import ObjectMapper
struct BranchContainer: Mappable { struct BranchContainer: Mappable {
var errorCode: String?
var message: String?
var id: String?
var extra: String?
var extra2: String?
var data: [Branch]?
var errorCode: String?
var message: String?
var id: String?
var extra: String?
var extra2: String?
var data: [Branch]?
init?(map: Map) {
init?(map: Map) {
}
mutating func mapping(map: Map) {
self.errorCode <- map["ErrorCode"]
self.message <- map["Msg"]
self.id <- map["Id"]
self.extra <- map["Extra"]
self.extra2 <- map["Extra2"]
self.data <- map["Data"]
}
}
mutating func mapping(map: Map) {
errorCode <- map["ErrorCode"]
message <- map["Msg"]
id <- map["Id"]
extra <- map["Extra"]
extra2 <- map["Extra2"]
data <- map["Data"]
}
} }

20
GMERemittance/Module/RewardModules/Redeem/Application Logic/Model/Redeem.swift

@ -9,14 +9,14 @@
import Foundation import Foundation
struct Redeem { struct Redeem {
let userID: String?
let productCode: String?
let usePoint: String?
let orderType: String?
let recvType: String?
let branchCode: String?
let recvAddress: String?
let recvZipCode: String?
let recvPhoneNumber: String?
let recvName: String?
let userID: String?
let productCode: String?
let usePoint: String?
let orderType: String?
let recvType: String?
let branchCode: String?
let recvAddress: String?
let recvZipCode: String?
let recvPhoneNumber: String?
let recvName: String?
} }

172
GMERemittance/Module/RewardModules/Redeem/Application Logic/Service/RedeemService.swift

@ -10,98 +10,98 @@ import Foundation
import FirebaseInstanceID import FirebaseInstanceID
class RedeemService: RedeemServiceType { class RedeemService: RedeemServiceType {
// MARK: Properties
// MARK: Initialization
// MARK: Data management
func fetchBranches(
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
) {
// MARK: Properties
// MARK: Initialization
// MARK: Data management
let url = baseUrlWithoutVersion + "/v2/reward/branchInfo"
// let url = "http://gmeuat.gmeremit.com:5018/api/v2/reward/branchInfo"
func fetchBranches(
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
) {
let url = baseUrlWithoutVersion + "/v2/reward/branchInfo"
// let url = "http://gmeuat.gmeremit.com:5018/api/v2/reward/branchInfo"
auth.request(
method: .post,
url: url,
params: nil,
success: { (response: BranchContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(
domain: "Network",
code: 0,
userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
)
failure(error)
}else {
success(response.data)
}
}) { (error) in
failure(error)
auth.request(
method: .post,
url: url,
params: nil,
success: { (response: BranchContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(
domain: "Network",
code: 0,
userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
)
failure(error)
}else {
success(response.data)
} }
}) { (error) in
failure(error)
} }
func submit(
with model: Redeem?,
success: @escaping () -> Void,
failure: @escaping (Error) -> Void
}
func submit(
with model: Redeem?,
success: @escaping () -> Void,
failure: @escaping (Error) -> Void
) { ) {
// let url = baseUrl + "/reward/productBuy"
let url = baseUrlWithoutVersion + "/v2/reward/productBuy"
// let url = "http://gmeuat.gmeremit.com:5018/api/v2/reward/productBuy"
let params: [String: String] = [
"userId": model?.userID ?? "",
"productCode": model?.productCode ?? "",
"usePoint": model?.usePoint ?? "",
"orderType": model?.orderType ?? "",
"recvType": model?.recvType ?? "",
"branchCode": model?.branchCode ?? "",
"recvAddress": model?.recvAddress ?? "",
"recvZipCode": model?.recvZipCode ?? "",
"recvPhoneNumber": model?.recvPhoneNumber ?? "",
"recvName": model?.recvName ?? "",
]
auth.request(
method: .post,
url: url,
params: params,
success: { (response: ResponseMessage) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(
domain: "Network",
code: 0,
userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
)
failure(error)
}else {
success()
}
}) { (error) in
failure(error)
// let url = baseUrl + "/reward/productBuy"
let url = baseUrlWithoutVersion + "/v2/reward/productBuy"
// let url = "http://gmeuat.gmeremit.com:5018/api/v2/reward/productBuy"
let params: [String: String] = [
"userId": model?.userID ?? "",
"productCode": model?.productCode ?? "",
"usePoint": model?.usePoint ?? "",
"orderType": model?.orderType ?? "",
"recvType": model?.recvType ?? "",
"branchCode": model?.branchCode ?? "",
"recvAddress": model?.recvAddress ?? "",
"recvZipCode": model?.recvZipCode ?? "",
"recvPhoneNumber": model?.recvPhoneNumber ?? "",
"recvName": model?.recvName ?? "",
]
auth.request(
method: .post,
url: url,
params: params,
success: { (response: ResponseMessage) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(
domain: "Network",
code: 0,
userInfo: [NSLocalizedDescriptionKey : response.message ?? ""]
)
failure(error)
}else {
success()
} }
}) { (error) in
failure(error)
} }
}
func fetchUserInfo(success: @escaping (User) -> (), failure: @escaping (Error) -> ()) {
let service = HomeService()
func fetchUserInfo(success: @escaping (User) -> (), failure: @escaping (Error) -> ()) {
let service = HomeService()
let param = [
"userId" : Utility.getMyUserName(),
"uuid": Utility.getUUid() ?? "",
"appVersion": Utility.getAppVersion() ?? "",
"phoneBrand": Utility.getPhoneBrand(),
"phoneOs": Utility.getPhoneOs(),
"fcmId": InstanceID.instanceID().token() ?? "",
"osVersion": Utility.getOsVersion()
]
service.fetchUserInfo(param: param, success: success, failure: failure)
}
let param = [
"userId" : Utility.getMyUserName(),
"uuid": Utility.getUUid() ?? "",
"appVersion": Utility.getAppVersion() ?? "",
"phoneBrand": Utility.getPhoneBrand(),
"phoneOs": Utility.getPhoneOs(),
"fcmId": InstanceID.instanceID().token() ?? "",
"osVersion": Utility.getOsVersion()
]
service.fetchUserInfo(param: param, success: success, failure: failure)
}
} }

28
GMERemittance/Module/RewardModules/Redeem/Application Logic/Service/RedeemServiceType.swift

@ -9,18 +9,18 @@
import Foundation import Foundation
protocol RedeemServiceType: class, ApiServiceType { protocol RedeemServiceType: class, ApiServiceType {
func fetchBranches(
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
)
func submit(
with model: Redeem?,
success: @escaping () -> Void,
failure: @escaping (Error) -> Void
)
func fetchUserInfo(
success: @escaping (User) -> (),
failure: @escaping (Error) -> ())
func fetchBranches(
success: @escaping ([Branch]?) -> Void,
failure: @escaping (Error) -> Void
)
func submit(
with model: Redeem?,
success: @escaping () -> Void,
failure: @escaping (Error) -> Void
)
func fetchUserInfo(
success: @escaping (User) -> (),
failure: @escaping (Error) -> ())
} }

16
GMERemittance/Module/RewardModules/Redeem/Module Interface/RedeemModuleInterface.swift

@ -7,12 +7,12 @@
// //
protocol RedeemModuleInterface: class { protocol RedeemModuleInterface: class {
func viewIsReady()
func showSearchAddressVC()
func fetchBranches()
func showBranchesVC()
func submit(with model: Redeem?)
func goRewardHome()
func refreshRewardPoint()
func viewIsReady()
func showSearchAddressVC()
func fetchBranches()
func showBranchesVC()
func submit(with model: Redeem?)
func goRewardHome()
func refreshRewardPoint()
} }

160
GMERemittance/Module/RewardModules/Redeem/User Interface/Presenter/RedeemPresenter.swift

@ -9,94 +9,94 @@
import Foundation import Foundation
class RedeemPresenter { class RedeemPresenter {
// MARK: Properties
weak var view: RedeemViewInterface?
var interactor: RedeemInteractorInput?
var wireframe: RedeemWireframeInput?
private var model: RewardProduct?
init(with model: RewardProduct?){
self.model = model
}
// MARK: Converting entities
// MARK: Properties
weak var view: RedeemViewInterface?
var interactor: RedeemInteractorInput?
var wireframe: RedeemWireframeInput?
private var model: RewardProduct?
init(with model: RewardProduct?){
self.model = model
}
// MARK: Converting entities
} }
// MARK: Redeem module interface // MARK: Redeem module interface
extension RedeemPresenter: RedeemModuleInterface { extension RedeemPresenter: RedeemModuleInterface {
func viewIsReady() {
self.view?.startLoading()
self.interactor?.viewIsReady(model: self.model)
}
func showSearchAddressVC() {
self.wireframe?.showSearchAddressVC()
}
func fetchBranches() {
self.view?.startLoading()
self.interactor?.fetchBranches()
}
func showBranchesVC() {
self.wireframe?.showBranchesVC()
}
func submit(with model: Redeem?) {
self.view?.startLoading()
self.interactor?.submit(with: model)
}
func goRewardHome() {
self.wireframe?.goRewardVC()
}
func refreshRewardPoint() {
self.view?.startLoading()
self.interactor?.refreshRewardPoint()
}
func viewIsReady() {
view?.startLoading()
interactor?.viewIsReady(model: model)
}
func showSearchAddressVC() {
wireframe?.showSearchAddressVC()
}
func fetchBranches() {
view?.startLoading()
interactor?.fetchBranches()
}
func showBranchesVC(){
wireframe?.showBranchesVC()
}
func submit(with model: Redeem?) {
view?.startLoading()
interactor?.submit(with: model)
}
func goRewardHome() {
wireframe?.goRewardVC()
}
func refreshRewardPoint() {
view?.startLoading()
interactor?.refreshRewardPoint()
}
} }
// MARK: Redeem interactor output interface // MARK: Redeem interactor output interface
extension RedeemPresenter: RedeemInteractorOutput { extension RedeemPresenter: RedeemInteractorOutput {
func successRefreshRewardPoint() {
self.view?.endLoading()
self.view?.successRefreshRewardPoint()
}
func failureRefreshRewardPoint(with error: Error) {
self.view?.endLoading()
self.view?.failureRefreshRewardPoint(with: error)
}
func result(model: RewardProduct?) {
self.view?.endLoading()
self.view?.setModel(model: model)
}
func setBranches(with model: [Branch]?) {
self.view?.endLoading()
self.view?.setBranches(with: model)
}
func setBranchesError(with error: Error) {
self.view?.endLoading()
self.view?.setBranchesError(with: error)
}
func submitSuccess() {
self.view?.endLoading()
self.view?.submitSuccess()
}
func submitFailure(with error: Error) {
self.view?.endLoading()
self.view?.submitFailure(with: error)
}
func successRefreshRewardPoint() {
view?.endLoading()
view?.successRefreshRewardPoint()
}
func failureRefreshRewardPoint(with error: Error) {
view?.endLoading()
view?.failureRefreshRewardPoint(with: error)
}
func result(model: RewardProduct?) {
view?.endLoading()
view?.setModel(model: model)
}
func setBranches(with model: [Branch]?) {
view?.endLoading()
view?.setBranches(with: model)
}
func setBranchesError(with error: Error) {
view?.endLoading()
view?.setBranchesError(with: error)
}
func submitSuccess() {
view?.endLoading()
view?.submitSuccess()
}
func submitFailure(with error: Error) {
view?.endLoading()
view?.submitFailure(with: error)
}
} }

2
GMERemittance/Module/RewardModules/Redeem/User Interface/View/Redeem.storyboard

@ -407,6 +407,7 @@
<outlet property="phoneNumberTitleLabel" destination="4eh-w1-tJj" id="NIt-wL-IVS"/> <outlet property="phoneNumberTitleLabel" destination="4eh-w1-tJj" id="NIt-wL-IVS"/>
<outlet property="pointsWillBeDeductedLabel" destination="R1n-RO-MXZ" id="fA9-sh-nSg"/> <outlet property="pointsWillBeDeductedLabel" destination="R1n-RO-MXZ" id="fA9-sh-nSg"/>
<outlet property="receiverTitleLabel" destination="AlI-iJ-Bev" id="KVi-jO-AFA"/> <outlet property="receiverTitleLabel" destination="AlI-iJ-Bev" id="KVi-jO-AFA"/>
<outlet property="redeemTitleLabel" destination="9kj-0f-kjr" id="pEW-pa-cBa"/>
<outlet property="scrollView" destination="UhJ-s4-o3M" id="9LP-tA-gpW"/> <outlet property="scrollView" destination="UhJ-s4-o3M" id="9LP-tA-gpW"/>
<outlet property="searchButton" destination="YWl-Z0-qfz" id="c9u-Tu-un1"/> <outlet property="searchButton" destination="YWl-Z0-qfz" id="c9u-Tu-un1"/>
<outlet property="selectAddressInfoLabel" destination="djo-b7-Gp6" id="lHg-pi-ek3"/> <outlet property="selectAddressInfoLabel" destination="djo-b7-Gp6" id="lHg-pi-ek3"/>
@ -414,7 +415,6 @@
<outlet property="selectedItemImageView" destination="mT2-re-Yo2" id="kht-Qe-kh3"/> <outlet property="selectedItemImageView" destination="mT2-re-Yo2" id="kht-Qe-kh3"/>
<outlet property="selectedItemNameLabel" destination="CQg-Ax-AVy" id="0GO-Fk-X5a"/> <outlet property="selectedItemNameLabel" destination="CQg-Ax-AVy" id="0GO-Fk-X5a"/>
<outlet property="selectedItemPriceLabel" destination="oPo-Sf-m2V" id="wHe-Zr-io7"/> <outlet property="selectedItemPriceLabel" destination="oPo-Sf-m2V" id="wHe-Zr-io7"/>
<outlet property="selectedProductTitleLabel" destination="9kj-0f-kjr" id="ffU-5v-88a"/>
<outlet property="submitButton" destination="Eqf-wL-rV9" id="8KL-gZ-lKH"/> <outlet property="submitButton" destination="Eqf-wL-rV9" id="8KL-gZ-lKH"/>
<outlet property="userInfoSegmentedControl" destination="O3s-cM-BFw" id="bYz-uy-lwU"/> <outlet property="userInfoSegmentedControl" destination="O3s-cM-BFw" id="bYz-uy-lwU"/>
<outlet property="userInfoView" destination="Diw-ue-AMa" id="U0x-Wq-CeQ"/> <outlet property="userInfoView" destination="Diw-ue-AMa" id="U0x-Wq-CeQ"/>

32
GMERemittance/Module/RewardModules/Redeem/User Interface/View/RedeemViewController.swift

@ -17,18 +17,12 @@ class RedeemViewController: UIViewController {
private var model: RewardProduct? { private var model: RewardProduct? {
didSet { didSet {
//TODO: //TODO:
// guard
// let newModel = model,
// let imageData = newModel.imageData,
// let data = Data(base64Encoded: imageData) else { return }
// selectedItemImageView.image = UIImage(data: data)
guard
let newModel = model
else { return }
selectedItemNameLabel.text = newModel.productName
selectedItemPriceLabel.text = newModel.pointPrice
if let imageData = model?.productImgPath,
let data = Data(base64Encoded: imageData) {
selectedItemImageView.image = UIImage(data: data)
}
selectedItemNameLabel.text = model?.productName
selectedItemPriceLabel.text = model?.pointPrice
} }
} }
@ -79,7 +73,7 @@ class RedeemViewController: UIViewController {
self.userInfoView.alpha = 1 self.userInfoView.alpha = 1
self.selectAddressInfoLabel.alpha = 1 self.selectAddressInfoLabel.alpha = 1
self.addressSegmentView.alpha = 1 self.addressSegmentView.alpha = 1
}, completion: nil)
}, completion: nil)
} }
} }
@ -97,7 +91,7 @@ class RedeemViewController: UIViewController {
self.branchesView.alpha = 1 self.branchesView.alpha = 1
self.addressView.alpha = 0 self.addressView.alpha = 0
}, completion: nil)
}, completion: nil)
case .custom: case .custom:
selectedBranch = nil selectedBranch = nil
@ -109,7 +103,7 @@ class RedeemViewController: UIViewController {
self.branchesView.alpha = 0 self.branchesView.alpha = 0
self.addressView.alpha = 1 self.addressView.alpha = 1
}, completion: nil)
}, completion: nil)
} }
submitButton.isHidden = false submitButton.isHidden = false
@ -168,7 +162,7 @@ class RedeemViewController: UIViewController {
@IBOutlet private weak var scrollView: UIScrollView! @IBOutlet private weak var scrollView: UIScrollView!
@IBOutlet weak var closeBarButton: UIBarButtonItem! @IBOutlet weak var closeBarButton: UIBarButtonItem!
@IBOutlet weak var selectedProductTitleLabel: UILabel!
@IBOutlet weak var redeemTitleLabel: UILabel!
@IBOutlet weak var pointsWillBeDeductedLabel: UILabel! @IBOutlet weak var pointsWillBeDeductedLabel: UILabel!
@IBOutlet weak var fromTourRewardPointLabel: UILabel! @IBOutlet weak var fromTourRewardPointLabel: UILabel!
@IBOutlet weak var receiverTitleLabel: UILabel! @IBOutlet weak var receiverTitleLabel: UILabel!
@ -246,7 +240,7 @@ class RedeemViewController: UIViewController {
setCoverView() setCoverView()
setButton() setButton()
setSegmentedControl() setSegmentedControl()
// self.setDefaultState()
// self.setDefaultState()
setOnlyBranchMode() setOnlyBranchMode()
setMultiLanguage() setMultiLanguage()
@ -403,7 +397,7 @@ extension RedeemViewController {
} }
private func setMultiLanguage(){ private func setMultiLanguage(){
selectedProductTitleLabel.text = "selected_product".localized()
redeemTitleLabel.text = "redeem".localized()
pointsWillBeDeductedLabel.text = "points_deducted".localized() pointsWillBeDeductedLabel.text = "points_deducted".localized()
fromTourRewardPointLabel.text = "from_your_reward_point".localized() fromTourRewardPointLabel.text = "from_your_reward_point".localized()
@ -471,7 +465,7 @@ extension RedeemViewController: ConfirmViewControllerDelegate {
ordered = Redeem( ordered = Redeem(
userID: UserDefaults.standard.string(forKey: UserKeys.email), userID: UserDefaults.standard.string(forKey: UserKeys.email),
productCode: model?.productNumber,
productCode: model?.productCode,
usePoint: model?.pointPrice, usePoint: model?.pointPrice,
orderType: "1", orderType: "1",
recvType: recvType, recvType: recvType,

24
GMERemittance/Module/RewardModules/Redeem/User Interface/View/RedeemViewInterface.swift

@ -7,16 +7,16 @@
// //
protocol RedeemViewInterface: class { protocol RedeemViewInterface: class {
func setModel(model: RewardProduct?)
func setBranches(with model: [Branch]?)
func setBranchesError(with error: Error)
func submitSuccess()
func submitFailure(with error: Error)
func startLoading()
func endLoading()
func failureRefreshRewardPoint(with error: Error)
func successRefreshRewardPoint()
func setModel(model: RewardProduct?)
func setBranches(with model: [Branch]?)
func setBranchesError(with error: Error)
func submitSuccess()
func submitFailure(with error: Error)
func startLoading()
func endLoading()
func failureRefreshRewardPoint(with error: Error)
func successRefreshRewardPoint()
} }

88
GMERemittance/Module/RewardModules/Redeem/User Interface/Wireframe/RedeemWireframe.swift

@ -9,56 +9,56 @@
import UIKit import UIKit
class RedeemWireframe { class RedeemWireframe {
weak var view: UIViewController!
private var model: RewardProduct?
weak var view: UIViewController!
private var model: RewardProduct?
} }
extension RedeemWireframe: RedeemWireframeInput { extension RedeemWireframe: RedeemWireframeInput {
var storyboardName: String {return "Redeem"}
func getMainView() -> UIViewController {
let service = RedeemService()
let interactor = RedeemInteractor(service: service)
let presenter = RedeemPresenter(with: self.model)
let viewController = viewControllerFromStoryboard(of: RedeemViewController.self)
var storyboardName: String {return "Redeem"}
viewController.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = self
presenter.view = viewController
func getMainView() -> UIViewController {
let service = RedeemService()
let interactor = RedeemInteractor(service: service)
let presenter = RedeemPresenter(with: self.model)
let viewController = viewControllerFromStoryboard(of: RedeemViewController.self)
viewController.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = self
presenter.view = viewController
self.view = viewController
return viewController
}
view = viewController
return viewController
}
func pushMainViewWithModel(with model: RewardProduct?, in source: UINavigationController) {
self.model = model
pushMainView(in: source)
}
func showSearchAddressVC(){
let wireframe = SearchAddressWireframe()
guard let delegate = view as? SearchAddressDelegate else {return}
func pushMainViewWithModel(with model: RewardProduct?, in source: UINavigationController) {
self.model = model
self.pushMainView(in: source)
}
func showSearchAddressVC(){
let wireframe = SearchAddressWireframe()
guard let delegate = self.view as? SearchAddressDelegate else {return}
wireframe.openViewControllerWithNavigationWithDelegate(
delegate: delegate,
viewController: wireframe.getMainView(),
source: self.view
)
}
func showBranchesVC() {
let wireframe = GmeContactsWireframe()
let vc = wireframe.getMainView()
wireframe.openViewControllerWithNavigation(viewController: vc, source: self.view)
}
func goRewardVC() {
self.view.navigationController?.popToRootViewController(animated: true)
}
wireframe.openViewControllerWithNavigationWithDelegate(
delegate: delegate,
viewController: wireframe.getMainView(),
source: view
)
}
func showBranchesVC(){
let wireframe = GmeContactsWireframe()
let vc = wireframe.getMainView()
wireframe.openViewControllerWithNavigation(viewController: vc, source: view)
}
func goRewardVC() {
view.navigationController?.popToRootViewController(animated: true)
}
} }

8
GMERemittance/Module/RewardModules/Redeem/User Interface/Wireframe/RedeemWireframeInput.swift

@ -9,8 +9,8 @@
import Foundation import Foundation
protocol RedeemWireframeInput: WireframeInput { protocol RedeemWireframeInput: WireframeInput {
func pushMainViewWithModel(with model: RewardProduct?, in source: UINavigationController)
func showSearchAddressVC()
func showBranchesVC()
func goRewardVC()
func pushMainViewWithModel(with model: RewardProduct?, in source: UINavigationController)
func showSearchAddressVC()
func showBranchesVC()
func goRewardVC()
} }

40
GMERemittance/Module/RewardModules/Reward/Application Logic/Interactor/RewardInteractor.swift

@ -9,30 +9,30 @@
import Foundation import Foundation
class RewardInteractor { class RewardInteractor {
// MARK: Properties
weak var output: RewardInteractorOutput?
private let service: RewardServiceType
// MARK: Initialization
init(service: RewardServiceType) {
self.service = service
}
// MARK: Converting entities
// MARK: Properties
weak var output: RewardInteractorOutput?
private let service: RewardServiceType
// MARK: Initialization
init(service: RewardServiceType) {
self.service = service
}
// MARK: Converting entities
} }
// MARK: Reward interactor input interface // MARK: Reward interactor input interface
extension RewardInteractor: RewardInteractorInput { extension RewardInteractor: RewardInteractorInput {
func viewIsReady() {
service.fetchProductList(
success: {
self.output?.setRewardProducts(models: $0)
}) {
self.output?.failure(error: $0)
}
func viewIsReady() {
service.fetchProductList(
success: {
self.output?.setRewardProducts(models: $0)
}) {
self.output?.failure(error: $0)
} }
}
} }

6
GMERemittance/Module/RewardModules/Reward/Application Logic/Interactor/RewardInteractorIO.swift

@ -7,10 +7,10 @@
// //
protocol RewardInteractorInput: class { protocol RewardInteractorInput: class {
func viewIsReady()
func viewIsReady()
} }
protocol RewardInteractorOutput: class { protocol RewardInteractorOutput: class {
func setRewardProducts(models: [RewardProduct]?)
func failure(error: Error)
func setRewardProducts(models: [RewardProduct]?)
func failure(error: Error)
} }

30
GMERemittance/Module/RewardModules/Reward/Application Logic/Model/RewardProduct.swift

@ -10,20 +10,20 @@ import Foundation
import ObjectMapper import ObjectMapper
struct RewardProduct: Mappable { struct RewardProduct: Mappable {
var productNumber: String? //productNumber
var productName: String? //productName,
var pointPrice: String? //pointPrice
var deliveryYN: String? //deliveryYN
var imageData: String? //imageData
init?(map: Map) {
}
var productCode: String? //productNumber
var productName: String? //productName,
var pointPrice: String? //pointPrice
var deliverYN: String? //deliveryYN
var productImgPath: String? //imageData
init?(map: Map) {
mutating func mapping(map: Map) {
self.productNumber <- map["productNumber"]
self.productName <- map["productName"]
self.pointPrice <- map["pointPrice"]
self.deliveryYN <- map["deliveryYN"]
self.imageData <- map["imageData"]
}
}
mutating func mapping(map: Map) {
productCode <- map["productCode"]
productName <- map["productName"]
pointPrice <- map["pointPrice"]
deliverYN <- map["deliverYN"]
productImgPath <- map["productImgPath"]
}
} }

38
GMERemittance/Module/RewardModules/Reward/Application Logic/Model/RewardProductContainer.swift

@ -10,24 +10,24 @@ import Foundation
import ObjectMapper import ObjectMapper
struct RewardProductContainer: Mappable { struct RewardProductContainer: Mappable {
var errorCode: String? //ErrorCode
var msg: String? //Msg
var id: String? //Id
var extra: String? //Extra
var extra2: String? //Extra2
var data: [RewardProduct]? // Data
init?(map: Map) {
}
mutating func mapping(map: Map) {
errorCode <- map["ErrorCode"]
msg <- map["Msg"]
id <- map["Id"]
extra <- map["Extra"]
extra2 <- map["Extra2"]
data <- map["Data"]
}
var errorCode: String? //ErrorCode
var msg: String? //Msg
var id: String? //Id
var extra: String? //Extra
var extra2: String? //Extra2
var data: [RewardProduct]? // Data
init?(map: Map) {
}
mutating func mapping(map: Map) {
errorCode <- map["ErrorCode"]
msg <- map["Msg"]
id <- map["Id"]
extra <- map["Extra"]
extra2 <- map["Extra2"]
data <- map["Data"]
}
} }

52
GMERemittance/Module/RewardModules/Reward/Application Logic/Service/RewardService.swift

@ -9,32 +9,32 @@
import Foundation import Foundation
class RewardService: RewardServiceType { class RewardService: RewardServiceType {
// MARK: Properties
// MARK: Initialization
// MARK: Data management
// /api/v2/reward/productList
func fetchProductList(
success: @escaping ([RewardProduct]?) -> (),
failure: @escaping (Error) -> ()
// MARK: Properties
// MARK: Initialization
// MARK: Data management
// /api/v2/reward/productList
func fetchProductList(
success: @escaping ([RewardProduct]?) -> (),
failure: @escaping (Error) -> ()
) { ) {
// let url = baseUrl + "/reward/productList"
// let url = "http://gmeuat.gmeremit.com:5018/api/v2/reward/productList"
let url = baseUrlWithoutVersion + "/v2/reward/productList"
auth.request(method: .post, url: url, params: nil, success: { (response: RewardProductContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.msg ?? ""])
failure(error)
}else {
let model = response.data
success(model)
}
}) { (error) in
failure(error)
}
// let url = baseUrl + "/reward/productList"
// let url = "http://gmeuat.gmeremit.com:5018/api/v2/reward/productList"
let url = baseUrlWithoutVersion + "/v2/reward/productList"
auth.request(method: .post, url: url, params: nil, success: { (response: RewardProductContainer) in
if (response.errorCode ?? "") == "1" {
let error = NSError.init(domain: "Network", code: 0, userInfo: [NSLocalizedDescriptionKey : response.msg ?? ""])
failure(error)
}else {
let model = response.data
success(model)
}
}) { (error) in
failure(error)
} }
}
} }

12
GMERemittance/Module/RewardModules/Reward/Application Logic/Service/RewardServiceType.swift

@ -9,10 +9,10 @@
import Foundation import Foundation
protocol RewardServiceType: class, ApiServiceType { protocol RewardServiceType: class, ApiServiceType {
func fetchProductList(
success: @escaping ([RewardProduct]?) -> (),
failure: @escaping (Error) -> ()
)
func fetchProductList(
success: @escaping ([RewardProduct]?) -> (),
failure: @escaping (Error) -> ()
)
} }

4
GMERemittance/Module/RewardModules/Reward/Module Interface/RewardModuleInterface.swift

@ -7,6 +7,6 @@
// //
protocol RewardModuleInterface: class { protocol RewardModuleInterface: class {
func viewIsReady()
func goRedeemViewController(with model: RewardProduct?)
func viewIsReady()
func goRedeemViewController(with model: RewardProduct?)
} }

50
GMERemittance/Module/RewardModules/Reward/User Interface/Presenter/RewardPresenter.swift

@ -9,39 +9,39 @@
import Foundation import Foundation
class RewardPresenter { class RewardPresenter {
// MARK: Properties
weak var view: RewardViewInterface?
var interactor: RewardInteractorInput?
var wireframe: RewardWireframeInput?
// MARK: Converting entities
// MARK: Properties
weak var view: RewardViewInterface?
var interactor: RewardInteractorInput?
var wireframe: RewardWireframeInput?
// MARK: Converting entities
} }
// MARK: Reward module interface // MARK: Reward module interface
extension RewardPresenter: RewardModuleInterface { extension RewardPresenter: RewardModuleInterface {
func viewIsReady() {
self.view?.startLoading()
self.interactor?.viewIsReady()
}
func goRedeemViewController(with model: RewardProduct?) {
self.wireframe?.goRedeemViewController(with: model)
}
func viewIsReady() {
view?.startLoading()
interactor?.viewIsReady()
}
func goRedeemViewController(with model: RewardProduct?) {
wireframe?.goRedeemViewController(with: model)
}
} }
// MARK: Reward interactor output interface // MARK: Reward interactor output interface
extension RewardPresenter: RewardInteractorOutput { extension RewardPresenter: RewardInteractorOutput {
func setRewardProducts(models: [RewardProduct]?) {
self.view?.endLoading()
self.view?.setRewardProducts(models: models)
}
func failure(error: Error) {
self.view?.endLoading()
self.view?.failure(error: error)
}
func setRewardProducts(models: [RewardProduct]?) {
view?.endLoading()
view?.setRewardProducts(models: models)
}
func failure(error: Error) {
view?.endLoading()
view?.failure(error: error)
}
} }

25
GMERemittance/Module/RewardModules/Reward/User Interface/View/Cell/RewardItemCollectionViewCell.swift

@ -21,22 +21,15 @@ class RewardItemCollectionViewCell: UICollectionViewCell {
var delegate: RewardViewInterface? var delegate: RewardViewInterface?
func setModel(with model: RewardProduct?, delegate: RewardViewInterface?){ func setModel(with model: RewardProduct?, delegate: RewardViewInterface?){
// TODO:
// guard
// let product = model,
// let imageData = model?.imageData,
// let url = URL(string: imageData),
// let data = try? Data(contentsOf: url)
// else { return }
// self.itemImage.image = UIImage(data: data)
guard
let product = model
else { return }
if let imageData = model?.productImgPath,
let url = URL(string: imageData),
let data = try? Data(contentsOf: url) {
self.itemImage.image = UIImage(data: data)
}
self.itemNameLabel.text = model?.productName
self.itemPriceLabel.text = model?.pointPrice
self.itemNameLabel.text = product.productName
self.itemPriceLabel.text = product.pointPrice
self.model = product
self.model = model
self.delegate = delegate self.delegate = delegate
self.setUI() self.setUI()
@ -49,7 +42,7 @@ class RewardItemCollectionViewCell: UICollectionViewCell {
} }
func setButton(){ func setButton(){
self.redeemButton.rounded()
self.redeemButton.layer.cornerRadius = 10
self.redeemButton.addTarget(self, action: #selector(redeemButtonTouch), for: .touchUpInside) self.redeemButton.addTarget(self, action: #selector(redeemButtonTouch), for: .touchUpInside)
let totalPoint = UserDefaults.standard.integer(forKey: UserKeys.rewardPoint) let totalPoint = UserDefaults.standard.integer(forKey: UserKeys.rewardPoint)

11
GMERemittance/Module/RewardModules/Reward/User Interface/View/Reward.storyboard

@ -106,7 +106,7 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gXS-zt-2Em" userLabel="Image"> <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="gXS-zt-2Em" userLabel="Image">
<rect key="frame" x="45" y="9.5" width="60" height="68"/> <rect key="frame" x="45" y="9.5" width="60" height="68"/>
<subviews> <subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_cap" translatesAutoresizingMaskIntoConstraints="NO" id="yBC-h9-W9V">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="yBC-h9-W9V">
<rect key="frame" x="0.0" y="0.0" width="60" height="68"/> <rect key="frame" x="0.0" y="0.0" width="60" height="68"/>
</imageView> </imageView>
</subviews> </subviews>
@ -118,8 +118,8 @@
<constraint firstItem="yBC-h9-W9V" firstAttribute="leading" secondItem="gXS-zt-2Em" secondAttribute="leading" id="wTT-Sp-Zie"/> <constraint firstItem="yBC-h9-W9V" firstAttribute="leading" secondItem="gXS-zt-2Em" secondAttribute="leading" id="wTT-Sp-Zie"/>
</constraints> </constraints>
</view> </view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Cap" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BqF-5D-gKI">
<rect key="frame" x="62" y="79.5" width="26" height="20"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="N/A" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BqF-5D-gKI">
<rect key="frame" x="63" y="79.5" width="24" height="20"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="20" id="Z1S-OD-hnG"/> <constraint firstAttribute="height" constant="20" id="Z1S-OD-hnG"/>
</constraints> </constraints>
@ -151,9 +151,9 @@
<constraint firstAttribute="height" constant="1" id="aIU-fW-HwS"/> <constraint firstAttribute="height" constant="1" id="aIU-fW-HwS"/>
</constraints> </constraints>
</view> </view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qou-YC-598">
<button opaque="NO" contentMode="scaleToFill" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qou-YC-598">
<rect key="frame" x="45" y="136.5" width="60" height="28.5"/> <rect key="frame" x="45" y="136.5" width="60" height="28.5"/>
<color key="backgroundColor" red="0.92941176469999998" green="0.10980392160000001" blue="0.14117647059999999" alpha="1" colorSpace="calibratedRGB"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="13"/> <fontDescription key="fontDescription" name="SanFranciscoDisplay-Medium" family="San Francisco Display" pointSize="13"/>
<state key="normal" title="Redeem"> <state key="normal" title="Redeem">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
@ -233,7 +233,6 @@
</scene> </scene>
</scenes> </scenes>
<resources> <resources>
<image name="ic_cap" width="61" height="61"/>
<image name="ic_reward" width="74" height="74"/> <image name="ic_reward" width="74" height="74"/>
<image name="starredBackground" width="355" height="132"/> <image name="starredBackground" width="355" height="132"/>
</resources> </resources>

70
GMERemittance/Module/RewardModules/Reward/User Interface/View/RewardViewController.swift

@ -17,13 +17,13 @@ class RewardViewController: UIViewController {
private var models: [RewardProduct]? { private var models: [RewardProduct]? {
didSet { didSet {
self.collectionView.reloadData()
collectionView.reloadData()
} }
} }
private var rewardPoint: String? { private var rewardPoint: String? {
didSet { didSet {
self.rewardPointLabel.text = self.rewardPoint
rewardPointLabel.text = rewardPoint
} }
} }
@ -40,19 +40,19 @@ class RewardViewController: UIViewController {
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.setup()
setup()
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated) super.viewWillAppear(animated)
title = "reward_group_title".localized() title = "reward_group_title".localized()
self.presenter?.viewIsReady()
self.rewardPoint = UserDefaults.standard.string(forKey: UserKeys.rewardPoint)
presenter?.viewIsReady()
rewardPoint = UserDefaults.standard.string(forKey: UserKeys.rewardPoint)
} }
override func viewWillDisappear(_ animated: Bool) { override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated) super.viewWillDisappear(animated)
self.navigationItem.title = ""
navigationItem.title = ""
} }
// MARK: IBActions // MARK: IBActions
@ -62,15 +62,15 @@ class RewardViewController: UIViewController {
private func setup() { private func setup() {
// all setup should be done here // all setup should be done here
self.setDelegate()
self.setCollectionViewLayout()
self.addRefreshControlCollectionView()
setDelegate()
setCollectionViewLayout()
addRefreshControlCollectionView()
setMultiLanguage() setMultiLanguage()
} }
private func setDelegate(){ private func setDelegate(){
self.collectionView.delegate = self
self.collectionView.dataSource = self
collectionView.delegate = self
collectionView.dataSource = self
} }
private func setMultiLanguage() { private func setMultiLanguage() {
@ -80,8 +80,8 @@ class RewardViewController: UIViewController {
private func setCollectionViewLayout() { private func setCollectionViewLayout() {
let cellSize = CGSize( let cellSize = CGSize(
width: (self.view.frame.width - 20) / 2 - 3.5,
height: (self.view.frame.width - 20) / 2 - 3.5
width: (view.frame.width - 20) / 2 - 3.5,
height: (view.frame.width - 20) / 2 - 3.5
) )
let layout = UICollectionViewFlowLayout() let layout = UICollectionViewFlowLayout()
@ -91,8 +91,8 @@ class RewardViewController: UIViewController {
layout.minimumLineSpacing = 5.0 layout.minimumLineSpacing = 5.0
layout.minimumInteritemSpacing = 5.0 layout.minimumInteritemSpacing = 5.0
self.collectionView.setCollectionViewLayout(layout, animated: true)
self.collectionView.reloadData()
collectionView.setCollectionViewLayout(layout, animated: true)
collectionView.reloadData()
} }
private func addRefreshControlCollectionView() { private func addRefreshControlCollectionView() {
@ -100,14 +100,14 @@ class RewardViewController: UIViewController {
let title = NSAttributedString(string: "pull to refresh", attributes: colorOption) let title = NSAttributedString(string: "pull to refresh", attributes: colorOption)
self.refreshControl.attributedTitle = title
self.refreshControl.backgroundColor = AppConstants.themeBlueColor
self.refreshControl.tintColor = AppConstants.themWhiteColor
self.refreshControl.addTarget(self, action: #selector(self.refresh), for: .valueChanged)
refreshControl.attributedTitle = title
refreshControl.backgroundColor = AppConstants.themeBlueColor
refreshControl.tintColor = AppConstants.themWhiteColor
refreshControl.addTarget(self, action: #selector(refresh), for: .valueChanged)
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
self.collectionView.refreshControl = self.refreshControl
collectionView.refreshControl = refreshControl
} else { } else {
self.collectionView.addSubview(self.refreshControl)
collectionView.addSubview(refreshControl)
} }
} }
@ -115,7 +115,9 @@ class RewardViewController: UIViewController {
private func refresh() { private func refresh() {
self.presenter?.viewIsReady() self.presenter?.viewIsReady()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0){
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0){[weak self] in
guard let `self` = self else {return}
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
self.collectionView.refreshControl?.endRefreshing() self.collectionView.refreshControl?.endRefreshing()
} else { } else {
@ -133,19 +135,19 @@ extension RewardViewController: RewardViewInterface {
} }
func failure(error: Error) { func failure(error: Error) {
self.alertWithOk(message: error.localizedDescription)
alertWithOk(message: error.localizedDescription)
} }
func goRedeemViewController(with model: RewardProduct?) { func goRedeemViewController(with model: RewardProduct?) {
self.presenter?.goRedeemViewController(with: model)
presenter?.goRedeemViewController(with: model)
} }
func startLoading() { func startLoading() {
self.showProgressHud()
showProgressHud()
} }
func endLoading() { func endLoading() {
self.hideProgressHud()
hideProgressHud()
} }
} }
@ -155,23 +157,17 @@ extension RewardViewController: UICollectionViewDelegate {
} }
extension RewardViewController: UICollectionViewDataSource { extension RewardViewController: UICollectionViewDataSource {
func collectionView(
_ collectionView: UICollectionView,
numberOfItemsInSection section: Int
) -> Int {
return self.models?.count ?? 0
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return models?.count ?? 0
} }
func collectionView(
_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath
) -> UICollectionViewCell {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell( let cell = collectionView.dequeueReusableCell(
withReuseIdentifier: "RewardItemCollectionViewCell", withReuseIdentifier: "RewardItemCollectionViewCell",
for: indexPath for: indexPath
) as! RewardItemCollectionViewCell
) as! RewardItemCollectionViewCell
cell.setModel(with: self.models?[indexPath.row], delegate: self)
cell.setModel(with: models?[indexPath.row], delegate: self)
return cell return cell
} }

12
GMERemittance/Module/RewardModules/Reward/User Interface/View/RewardViewInterface.swift

@ -7,10 +7,10 @@
// //
protocol RewardViewInterface: class { protocol RewardViewInterface: class {
func setRewardProducts(models: [RewardProduct]?)
func failure(error: Error)
func goRedeemViewController(with model: RewardProduct?)
func startLoading()
func endLoading()
func setRewardProducts(models: [RewardProduct]?)
func failure(error: Error)
func goRedeemViewController(with model: RewardProduct?)
func startLoading()
func endLoading()
} }

48
GMERemittance/Module/RewardModules/Reward/User Interface/Wireframe/RewardWireframe.swift

@ -9,35 +9,35 @@
import UIKit import UIKit
class RewardWireframe { class RewardWireframe {
weak var view: UIViewController!
weak var view: UIViewController!
} }
extension RewardWireframe: RewardWireframeInput { extension RewardWireframe: RewardWireframeInput {
var storyboardName: String {return "Reward"}
func getMainView() -> UIViewController {
let service = RewardService()
let interactor = RewardInteractor(service: service)
let presenter = RewardPresenter()
let viewController = viewControllerFromStoryboard(of: RewardViewController.self)
var storyboardName: String {return "Reward"}
viewController.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = self
presenter.view = viewController
func getMainView() -> UIViewController {
let service = RewardService()
let interactor = RewardInteractor(service: service)
let presenter = RewardPresenter()
let viewController = viewControllerFromStoryboard(of: RewardViewController.self)
viewController.presenter = presenter
interactor.output = presenter
presenter.interactor = interactor
presenter.wireframe = self
presenter.view = viewController
self.view = viewController
return viewController
}
func goRedeemViewController(with model: RewardProduct?){
let redeemWireframe = RedeemWireframe()
guard let navigationVC = self.view.navigationController else { return }
redeemWireframe.pushMainViewWithModel(with: model, in: navigationVC)
}
view = viewController
return viewController
}
func goRedeemViewController(with model: RewardProduct?){
let redeemWireframe = RedeemWireframe()
guard let navigationVC = view.navigationController else { return }
redeemWireframe.pushMainViewWithModel(with: model, in: navigationVC)
}
} }

2
GMERemittance/Module/RewardModules/Reward/User Interface/Wireframe/RewardWireframeInput.swift

@ -9,5 +9,5 @@
import Foundation import Foundation
protocol RewardWireframeInput: WireframeInput { protocol RewardWireframeInput: WireframeInput {
func goRedeemViewController(with model: RewardProduct?)
func goRedeemViewController(with model: RewardProduct?)
} }

4
en.lproj/Localizable.strings

@ -423,7 +423,6 @@
// RedeemViewContoller // RedeemViewContoller
"redeem" = "Redeem"; "redeem" = "Redeem";
"selected_product" = "Selected reward: ";
"points_deducted" = "Points will be deducted"; "points_deducted" = "Points will be deducted";
"from_your_reward_point" = "from your reward point"; "from_your_reward_point" = "from your reward point";
"receiver" = "Receiver"; "receiver" = "Receiver";
@ -457,7 +456,8 @@
"ordered" = "ORDERED"; "ordered" = "ORDERED";
"received" = "RECEIVED"; "received" = "RECEIVED";
"canceled" = "CANCELED"; "canceled" = "CANCELED";
"no_orders_message" = "There are no orders for the three month.";
"no_search_orders_message" = "There are no result for search.";
"no_orders_message" = "There are no orders for last a week.";
// OrderCell // OrderCell
"your_order_canceled" = "Your order canceled"; "your_order_canceled" = "Your order canceled";

Loading…
Cancel
Save