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.

109 lines
3.8 KiB

6 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
  1. import UIKit
  2. import Localize_Swift
  3. class ProfileViewController: UIViewController {
  4. struct StringConstants {
  5. let changePasswordText = "change_password_text".localized()
  6. let gmeWalletNotText = "gme_wallet_no_text".localized()
  7. let yourAvailableBalanceText = "available_balance_text".localized()
  8. let profileText = "profile_text".localized()
  9. let withdrawButtonText = "withdraw_text".localized()
  10. }
  11. @IBOutlet weak var labelUserProfileName: UILabel!
  12. @IBOutlet weak var imageViewUserProfile: UIImageView!
  13. @IBOutlet weak var gmeWalletNumber: UILabel!
  14. @IBOutlet weak var buttonEdit: UIButton!
  15. @IBOutlet weak var labelUserName: UILabel?
  16. @IBOutlet weak var labelEmail: UILabel!
  17. @IBOutlet weak var labelMobileNumber: UILabel!
  18. @IBOutlet weak var labelBalance: UILabel!
  19. @IBOutlet weak var withdrawButton: UIButton!
  20. @IBOutlet weak var changePasswordButton: UIButton!
  21. @IBOutlet weak var bankNameLabel: UILabel!
  22. // titles
  23. @IBOutlet weak var availableBalancetTitleLabel: UILabel!
  24. @IBOutlet weak var gmeWalletNoTitle: UILabel!
  25. var profileImage: UIImage!
  26. public static var profileConnectionTimeOutCheck = 0
  27. override func viewWillAppear(_ animated: Bool) {
  28. super.viewWillDisappear(animated)
  29. self.configureLanguage()
  30. self.setupNormalNavigation()
  31. self.navigationItem.title = StringConstants().profileText
  32. self.withdrawButton.isHidden = !Utility.pennyTestVerified()
  33. show()
  34. }
  35. override func viewWillDisappear(_ animated: Bool) {
  36. super.viewWillDisappear(animated)
  37. self.navigationItem.title = ""
  38. }
  39. override func viewDidLoad() {
  40. super.viewDidLoad()
  41. NotificationCenter.default.addObserver(
  42. self,
  43. selector: #selector(setupTabItem),
  44. name: NSNotification.Name(LCLLanguageChangeNotification),
  45. object: nil
  46. )
  47. labelBalance.textColor = .themeRed
  48. }
  49. func configureLanguage() {
  50. self.availableBalancetTitleLabel.text = StringConstants().yourAvailableBalanceText
  51. self.gmeWalletNoTitle.text = "gme_wallet_no_text".localized()
  52. self.withdrawButton.setTitle(StringConstants().withdrawButtonText, for: UIControl.State.normal)
  53. self.changePasswordButton.setTitle(StringConstants().changePasswordText, for: UIControl.State.normal)
  54. withdrawButton.layer.cornerRadius = 5
  55. }
  56. override func setupTabItem() {
  57. let image = UIImage.init(named: "ic-profile")
  58. self.tabBarItem = UITabBarItem(title: "profile_text".localized(), image: image, selectedImage: nil)
  59. self.tabBarItem.titlePositionAdjustment = UIOffset(
  60. horizontal: 0,
  61. vertical: UI_USER_INTERFACE_IDIOM() == .pad ? 2 : -6
  62. )
  63. }
  64. @IBAction func withdraw(_ sender: UIButton) {
  65. guard let vc = UIStoryboard(
  66. name: "autoRefund",
  67. bundle: nil
  68. ).instantiateViewController(withIdentifier: "AutoRefundsViewController") as? AutoRefundsViewController
  69. else {
  70. return
  71. }
  72. self.navigationController?.pushViewController(vc, animated: true)
  73. }
  74. func getWithdrawNotificationName() -> Notification.Name {
  75. return Notification.Name.init(SideMenuNavigationNotifications.withdraw)
  76. }
  77. func show() {
  78. let name = GMEDB.shared.user.string(.firstName)
  79. self.labelUserName?.text = name?.capitalized
  80. self.labelMobileNumber.text = GMEDB.shared.user.string(.mobileNumber)
  81. self.labelEmail.text = GMEDB.shared.user.string(.email)
  82. self.labelBalance.text = GMEDB.shared.user.string(.availableBalance)
  83. let walletNum = GMEDB.shared.user.string(.walletNumber)
  84. let bankName = GMEDB.shared.user.string(.primaryBankName)
  85. bankNameLabel.text = bankName
  86. gmeWalletNumber.text = walletNum
  87. labelUserProfileName.layer.backgroundColor = UIColor(hex: 0x2e3192).cgColor
  88. labelUserProfileName.layer.cornerRadius = labelUserProfileName.frame.height / 2
  89. labelUserProfileName.text = labelUserName?.text?.prefix(1).uppercased()
  90. }
  91. }