Browse Source

payment mode shown

pull/1/head
gme_2 6 years ago
parent
commit
7e7117ac31
  1. 4
      GMERemittance/Module/Cell/ExchangeRateCollectionViewCell.swift
  2. 55
      GMERemittance/Module/ExchangeRateViewControllerV2.swift

4
GMERemittance/Module/Cell/ExchangeRateCollectionViewCell.swift

@ -19,10 +19,12 @@ class ExchangeRateCollectionViewCell: UICollectionViewCell {
var cellSelected = false var cellSelected = false
var title: String? var title: String?
var subtitle: String? var subtitle: String?
var image: UIImage?
var paymentMode: PaymentMode? var paymentMode: PaymentMode?
func setup() { func setup() {
self.imageview.image = #imageLiteral(resourceName: "ic_bank")
self.imageview.image = image
self.paymentLabel.text = "Cash Payment" self.paymentLabel.text = "Cash Payment"
cellBackgroundview.layer.cornerRadius = 10 cellBackgroundview.layer.cornerRadius = 10
cellSelected ? showBorderColor() : hideBorderColor() cellSelected ? showBorderColor() : hideBorderColor()

55
GMERemittance/Module/ExchangeRateViewControllerV2.swift

@ -9,10 +9,10 @@
import UIKit import UIKit
import Hex import Hex
enum PaymentMode: Int {
case cashDelivery = 0
case bankDeposite
case homeDelivery
enum PaymentMode: String {
case cashDelivery = "cash"
case bankDeposite = "bank"
case homeDelivery = "home"
} }
class ExchangeRateViewControllerV2: UIViewController { class ExchangeRateViewControllerV2: UIViewController {
@ -43,6 +43,7 @@ class ExchangeRateViewControllerV2: UIViewController {
if let image = CountryFlag().getFlagfor(countryCode: self.selectedExchageRateModel?.countryCode ?? "") { if let image = CountryFlag().getFlagfor(countryCode: self.selectedExchageRateModel?.countryCode ?? "") {
self.countryFlagImage.image = image self.countryFlagImage.image = image
} }
self.collectionView.reloadData()
} }
} }
@ -141,28 +142,45 @@ extension ExchangeRateViewControllerV2: UICollectionViewDelegate {
extension ExchangeRateViewControllerV2: UICollectionViewDataSource { extension ExchangeRateViewControllerV2: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 3
return self.selectedExchageRateModel?.availableServices?.count ?? 0
} }
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let index = PaymentMode.init(rawValue: indexPath.row) else {return UICollectionViewCell()}
let service = self.selectedExchageRateModel?.availableServices?.elementAt(index: indexPath.row)
guard let index = PaymentMode.init(rawValue: service?.type ?? "") else {
return UICollectionViewCell()
}
switch index { switch index {
case .bankDeposite: case .bankDeposite:
break
return configureBankDepositeCell(collectionView: collectionView, indexPath: indexPath)
case .cashDelivery: case .cashDelivery:
break
return configureCashDeliveryCell(collectionView: collectionView, indexPath: indexPath)
case .homeDelivery: case .homeDelivery:
break
return configureHomeDeliveryCell(collectionView: collectionView, indexPath: indexPath)
} }
}
func configureBankDepositeCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell
cell.cellSelected = self.selectedPaymentIndex == indexPath cell.cellSelected = self.selectedPaymentIndex == indexPath
cell.image = #imageLiteral(resourceName: "ic_bank")
cell.setup() cell.setup()
return cell return cell
} }
func configureBankDepositeCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
func configureCashDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell
cell.cellSelected = self.selectedPaymentIndex == indexPath cell.cellSelected = self.selectedPaymentIndex == indexPath
cell.image = #imageLiteral(resourceName: "ic_cash")
cell.setup()
return cell
}
func configureHomeDeliveryCell(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ExchangeRateCollectionViewCell", for: indexPath) as! ExchangeRateCollectionViewCell
cell.cellSelected = self.selectedPaymentIndex == indexPath
cell.image = #imageLiteral(resourceName: "ic_homeDelivery")
cell.setup() cell.setup()
return cell return cell
} }
@ -171,30 +189,47 @@ extension ExchangeRateViewControllerV2: UICollectionViewDataSource {
extension ExchangeRateViewControllerV2 { extension ExchangeRateViewControllerV2 {
func createTestModel() { func createTestModel() {
let service1 = PaymentServiceType()
service1.type = "cash"
service1.subtitle = "1 business day"
let service2 = PaymentServiceType()
service2.type = "bank"
service2.subtitle = "2 hour"
let service3 = PaymentServiceType()
service3.type = "home"
service3.subtitle = "5 business day"
let model = ExchangeRateModel() let model = ExchangeRateModel()
model.country = "Nepal" model.country = "Nepal"
model.countryCode = "Np" model.countryCode = "Np"
model.currency = "NRS" model.currency = "NRS"
model.availableServices = [service2, service1]
let model1 = ExchangeRateModel() let model1 = ExchangeRateModel()
model1.country = "Kore" model1.country = "Kore"
model1.countryCode = "krw" model1.countryCode = "krw"
model1.currency = "NRS" model1.currency = "NRS"
model1.availableServices = [service2, service1, service3]
let model2 = ExchangeRateModel() let model2 = ExchangeRateModel()
model2.country = "India" model2.country = "India"
model2.countryCode = "in" model2.countryCode = "in"
model2.currency = "NRS" model2.currency = "NRS"
model2.availableServices = [service2]
let model3 = ExchangeRateModel() let model3 = ExchangeRateModel()
model3.country = "China" model3.country = "China"
model3.countryCode = "cn" model3.countryCode = "cn"
model3.currency = "NRS" model3.currency = "NRS"
model3.availableServices = [service2, service1, service3]
let model4 = ExchangeRateModel() let model4 = ExchangeRateModel()
model4.country = "Cambodia" model4.country = "Cambodia"
model4.countryCode = "Kh" model4.countryCode = "Kh"
model4.currency = "NRS" model4.currency = "NRS"
model4.availableServices = [service2, service1, service3]
self.exchangeRateModels = [model, model1, model2, model3, model4] self.exchangeRateModels = [model, model1, model2, model3, model4]
} }

Loading…
Cancel
Save