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.

84 lines
2.3 KiB

  1. //
  2. // AppUpdateViewController.swift
  3. // GME Remit
  4. //
  5. // Created by shishir sapkota on 12/11/18.
  6. //Copyright © 2018 Gobal Money Express Co. Ltd. All rights reserved.
  7. //
  8. import UIKit
  9. class AppUpdateViewController: UIViewController {
  10. struct StringConstants {
  11. let updateMessageText = "new_update_is_available_text".localized()
  12. let updateText = "update_text".localized()
  13. let notNowText = "not_now_text".localized()
  14. }
  15. // MARK: Properties
  16. @IBOutlet weak var updateButton: UIButton!
  17. @IBOutlet weak var updateMessageLabel: UILabel!
  18. @IBOutlet weak var updateMessageTextLabel: UILabel!
  19. @IBOutlet weak var notNowButton: UIButton!
  20. var presenter: AppUpdateModuleInterface?
  21. // MARK: IBOutlets
  22. // MARK: VC's Life cycle
  23. var messageText: String = ""
  24. override func viewDidLoad() {
  25. super.viewDidLoad()
  26. self.setup()
  27. self.updateMessageLabel.text = messageText
  28. }
  29. // MARK: IBActions
  30. @IBAction func dismiss(_ sender: Any) {
  31. self.dismiss()
  32. }
  33. @IBAction func update(_ sender: UIButton) {
  34. self.update()
  35. }
  36. @IBAction func backButtonPressed(_ sender: Any) {
  37. self.dismiss(animated: true, completion: nil)
  38. }
  39. // MARK: Other Functions
  40. private func setup() {
  41. let shouldHideDismiss = Utility.isCriticalUpdate()
  42. self.notNowButton.isHidden = shouldHideDismiss
  43. configureUpdateButton()
  44. configureText()
  45. }
  46. private func configureText() {
  47. self.updateMessageTextLabel.text = StringConstants().updateMessageText
  48. self.updateButton.setTitle(StringConstants().updateText, for: UIControl.State.normal)
  49. self.notNowButton.setTitle(StringConstants().notNowText, for: UIControl.State.normal)
  50. }
  51. func configureUpdateButton() {
  52. self.updateButton.layer.borderColor = UIColor.white.cgColor
  53. self.updateButton.layer.borderWidth = 1
  54. self.updateButton.layer.cornerRadius = 25
  55. self.updateButton.layer.addShadow(offset: CGSize.init(width: -1, height: 1))
  56. }
  57. func dismiss() {
  58. self.dismiss(animated: true, completion: nil)
  59. }
  60. func update() {
  61. let urlStr = "itms-apps://itunes.apple.com/gh/app/jme-remittance/id1561903311"
  62. UIApplication.tryURL(url: urlStr)
  63. }
  64. }
  65. // MARK: AppUpdateViewInterface
  66. extension AppUpdateViewController: AppUpdateViewInterface {}