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.

79 lines
2.0 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 updateMessageTextLabel: UILabel!
  18. @IBOutlet weak var notNowButton: UIButton!
  19. var presenter: AppUpdateModuleInterface?
  20. // MARK: IBOutlets
  21. // MARK: VC's Life cycle
  22. override func viewDidLoad() {
  23. super.viewDidLoad()
  24. self.setup()
  25. }
  26. // MARK: IBActions
  27. @IBAction func dismiss(_ sender: Any) {
  28. self.dismiss()
  29. }
  30. @IBAction func update(_ sender: UIButton) {
  31. self.update()
  32. }
  33. // MARK: Other Functions
  34. private func setup() {
  35. let shouldHideDismiss = Utility.isCriticalUpdate()
  36. self.notNowButton.isHidden = shouldHideDismiss
  37. configureUpdateButton()
  38. configureText()
  39. }
  40. private func configureText() {
  41. self.updateMessageTextLabel.text = StringConstants().updateMessageText
  42. self.updateButton.setTitle(StringConstants().updateText, for: UIControl.State.normal)
  43. self.notNowButton.setTitle(StringConstants().notNowText, for: UIControl.State.normal)
  44. }
  45. func configureUpdateButton() {
  46. self.updateButton.layer.borderColor = UIColor.white.cgColor
  47. self.updateButton.layer.borderWidth = 1
  48. self.updateButton.layer.addShadow(offset: CGSize.init(width: -1, height: 1))
  49. }
  50. func dismiss() {
  51. self.dismiss(animated: true, completion: nil)
  52. }
  53. func update() {
  54. let urlStr = "itms-apps://itunes.apple.com/gh/app/gme-remit/id1439161261?mt=8"
  55. UIApplication.tryURL(url: urlStr)
  56. }
  57. }
  58. // MARK: AppUpdateViewInterface
  59. extension AppUpdateViewController: AppUpdateViewInterface {}