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.

56 lines
1.7 KiB

6 years ago
  1. //
  2. // HomeRemainingLimitTableViewCell.swift
  3. // GMERemittance
  4. //
  5. // Created by gme_2 on 21/09/2018.
  6. // Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class HomeRemainingLimitTableViewCell: UITableViewCell {
  10. struct StringConstant {
  11. let yearlyLimit = "remaining_limit_text".localized()
  12. }
  13. @IBOutlet weak var pointBackgroundView: UIView!
  14. @IBOutlet weak var amountLabel: UILabel!
  15. @IBOutlet weak var rewardPointAmountLabel: UILabel!
  16. @IBOutlet weak var userNameLabel: UILabel!
  17. @IBOutlet weak var remainingYearlyLabel: UILabel!
  18. var user: User?
  19. override func awakeFromNib() {
  20. super.awakeFromNib()
  21. // Initialization code
  22. NotificationCenter.default.addObserver(self, selector: #selector(self.getYearlyLimitNotificationName), name: self.getYearlyLimitNotificationName(), object: nil)
  23. }
  24. func setup() {
  25. let limits = UserDefaults.standard.string(forKey: UserKeys.yearlyLimit)
  26. self.amountLabel.text = limits
  27. self.userNameLabel.text = user?.firstName?.capitalized
  28. configureText()
  29. }
  30. private func configureText() {
  31. let text = "remaining_limit_text".localized()
  32. self.remainingYearlyLabel.text = text
  33. }
  34. @objc private func getYearlyLimitNotificationName() -> Notification.Name {
  35. return Notification.Name.init(AppConstants.yearlyLimitNotification)
  36. }
  37. private func updateYearlyLimit(sender: Notification) {
  38. if let amount = sender.userInfo?[AppConstants.yearlyLimitNotification] as? String {
  39. self.amountLabel.text
  40. = amount
  41. }
  42. }
  43. }