| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- //
- // TarifSertifikatCell.swift
- // Sirani
- //
- // Created by Anhar Solehudin on 31/03/19.
- // Copyright © 2019 Anhar Solehudin. All rights reserved.
- //
- import UIKit
- import MaterialComponents.MaterialCards
- import SkeletonView
- class TarifSertifikatCell: UITableViewCell {
- @IBOutlet weak var card: MDCCard!
- @IBOutlet weak var lblNamaTarif: UILabel!
- @IBOutlet weak var lblBiaya: UILabel!
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- self.selectionStyle = .none
- self.backgroundColor = .clear
-
- // Native MDCCard styling
- card.cornerRadius = 16
- card.setShadowElevation(ShadowElevation(rawValue: 2), for: .normal)
- card.setShadowColor(UIColor.black.withAlphaComponent(0.08), for: .normal)
- card.layer.borderColor = UIColor(red: 232/255, green: 238/255, blue: 248/255, alpha: 1.0).cgColor
- card.layer.borderWidth = 1
-
- // Typography styling
- lblNamaTarif.font = UIFont.systemFont(ofSize: 15, weight: .bold)
- lblNamaTarif.textColor = UIColor.siraniTextPrimary
-
- lblBiaya.font = UIFont.systemFont(ofSize: 15, weight: .bold)
- lblBiaya.textColor = UIColor.siraniPrimaryBlue
-
- self.isSkeletonable = true
- card.isSkeletonable = true
- lblNamaTarif.isSkeletonable = true
- lblBiaya.isSkeletonable = true
- }
-
- func updateViews(tarifSertifikat: TarifSertifikat) {
- card.isInteractable = false
- card.isUserInteractionEnabled = false
-
- lblNamaTarif.text = tarifSertifikat.keterangan
-
- if let tarifValue = Double(tarifSertifikat.tarif) {
- let formatter = NumberFormatter()
- formatter.numberStyle = .currency
- formatter.locale = Locale(identifier: "id_ID")
- formatter.currencySymbol = "Rp "
- formatter.maximumFractionDigits = 0
-
- if let formattedString = formatter.string(from: NSNumber(value: tarifValue)) {
- lblBiaya.text = formattedString
- } else {
- lblBiaya.text = tarifSertifikat.tarif
- }
- } else {
- lblBiaya.text = tarifSertifikat.tarif
- }
- }
- }
|