You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

70 lines
2.1 KiB

//
// WalletStatementTableViewCell.swift
// GMERemittance
//
// Created by gme_2 on 03/10/2018.
// Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
//
import UIKit
class WalletStatementTableViewCell: UITableViewCell {
struct StringConstants {
let `in` = "in_text".localized()
let out = "out_text".localized()
let closingBalanceText = "closing_balance_text".localized()
}
enum WalletInOutType: String {
case walletIn = "WalletIn"
case walletOut = "WalletOut"
case closingAmount = "ClosingAmount"
}
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var particularLabel: UILabel!
@IBOutlet weak var closingAmountLabel: UILabel!
@IBOutlet weak var amtLabelStackView: UIStackView!
@IBOutlet weak var closingBalanceTitleLabel: UILabel!
@IBOutlet weak var walletAmountLabel: UILabel!
var model: WalletStatement?
func getType() -> WalletInOutType {
if (model?.particular ?? "").lowercased() == "Balance Brought Forward".lowercased() {
return .closingAmount
}
return (model?.walletOut ?? "") == "₩0" ? .walletIn : .walletOut
}
func setup() {
configureText()
self.dateLabel.text = model?.transactionDate
self.particularLabel.text = model?.particular
self.closingAmountLabel.text = model?.closingAmount
let type: WalletInOutType = getType()
self.walletAmountLabel.layer.cornerRadius = 4
self.walletAmountLabel.clipsToBounds = true
walletAmountLabel.textColor = .white
switch type {
case .walletIn:
self.walletAmountLabel.backgroundColor = .themeBlue
self.walletAmountLabel.text = "\(StringConstants().in): \(self.model?.walletIn ?? "")"
case .walletOut:
self.walletAmountLabel.backgroundColor = .themeRed
self.walletAmountLabel.text = "\(StringConstants().out): \(model?.walletOut ?? "")"
case .closingAmount:
self.walletAmountLabel.text = ""
self.walletAmountLabel.backgroundColor = .themeWhite
}
}
func configureText() {
self.closingBalanceTitleLabel.text = StringConstants().closingBalanceText
}
}