HCTrial.swift 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // HCTrial.swift
  3. // HandwerkCloud
  4. //
  5. // Created by Marino Faggiana on 28/04/2019.
  6. // Copyright © 2019 TWS. All rights reserved.
  7. //
  8. import Foundation
  9. class HCTrial: UIViewController {
  10. @objc var account: tableAccount?
  11. let appDelegate = UIApplication.shared.delegate as! AppDelegate
  12. @IBOutlet weak var viewLogo: UIView!
  13. @IBOutlet weak var titleLabel: UILabel!
  14. @IBOutlet weak var imageTimer: UIImageView!
  15. @IBOutlet weak var textView: UITextView!
  16. @IBOutlet weak var purchaseButton: UIButton!
  17. @IBOutlet weak var continueButton: UIButton!
  18. @IBOutlet weak var purchaseLeadingConstraint: NSLayoutConstraint!
  19. override func viewDidLoad() {
  20. super.viewDidLoad()
  21. let language = Locale.current.languageCode
  22. view.backgroundColor = NCBrandColor.sharedInstance.brand
  23. viewLogo.backgroundColor = NCBrandColor.sharedInstance.brand
  24. //titleLabel.text = "HANDWERKCLOUD TRIAL"
  25. purchaseButton.layer.cornerRadius = 20
  26. purchaseButton.clipsToBounds = true
  27. purchaseButton.backgroundColor = UIColor.white //NCBrandColor.sharedInstance.brand
  28. purchaseButton.setTitleColor(NCBrandColor.sharedInstance.brand, for: .normal)
  29. purchaseButton.setTitle(NSLocalizedString("_purchase_", comment: ""), for: UIControl.State.normal)
  30. continueButton.layer.cornerRadius = 20
  31. continueButton.clipsToBounds = true
  32. continueButton.layer.borderWidth = 1
  33. continueButton.layer.borderColor = UIColor.white.cgColor //NCBrandColor.sharedInstance.brand.cgColor
  34. continueButton.backgroundColor = .clear
  35. continueButton.setTitle(NSLocalizedString("_continue_", comment: ""), for: UIControl.State.normal)
  36. guard let account = account else {
  37. return
  38. }
  39. // Expired
  40. if account.hcNextGroupExpirationGroupExpired || account.hcTrialExpired {
  41. //let numberOfDays: Int = Int(account.hcAccountRemoveRemainingSec) / (24*3600)
  42. imageTimer.image = CCGraphics.changeThemingColorImage(UIImage(named: "timeroff"), width: 200, height: 200, color: .white)!
  43. continueButton.isHidden = true
  44. purchaseLeadingConstraint.constant = (self.view.bounds.width/2) - 75
  45. if language == "de" {
  46. textView.text = "Vielen Dank, dass Sie sich für HandwerkCloud entschieden haben. Ihr Testzeitraum ist abgelaufen. Um HandwerkCloud weiterhin nutzen zu können, tippen Sie auf \"Kaufen\" oder besuchen Sie unsere Webseite."
  47. //\n\nYot have \(numberOfDays) days remaining before your account and files are removed from HadwerkCloud."
  48. } else if language == "it" {
  49. textView.text = "Grazie per aver provato HandwerkCloud, il tuo periodo di prova è scaduto.\n\nPer continuare a utilizzare HandwerkCloud tocca il pulsante di acquisto o visita il sito Web."
  50. //\n\nYot have \(numberOfDays) giorni rimanenti prima che il tuo account e i tuoi file siano rimossi da HadwerkCloud."
  51. } else {
  52. textView.text = "Thank you for trying HandwerkCloud, your trial has now expired.\n\nTo continue using HandwerkCloud tap the purchase button or visit the website."
  53. //\n\nYot have \(numberOfDays) days remaining before your account and files are removed from HadwerkCloud."
  54. }
  55. }
  56. // Trial
  57. else if account.hcIsTrial {
  58. let numberOfDays: Int = Int(account.hcTrialRemainingSec) / (24*3600)
  59. imageTimer.image = CCGraphics.changeThemingColorImage(UIImage(named: "timer"), width: 200, height: 200, color: .white)!
  60. textView.textAlignment = NSTextAlignment.center
  61. purchaseLeadingConstraint.constant = 20
  62. if language == "de" {
  63. if numberOfDays > 1 {
  64. textView.text = "Ihr Testzeitraum läuft in \(numberOfDays) Tagen ab."
  65. } else {
  66. textView.text = "Ihr Testzeitraum läuft in 1 Tag ab."
  67. }
  68. } else if language == "it" {
  69. if numberOfDays > 1 {
  70. textView.text = "Hai ancora \(numberOfDays) giorni rimasti di prova."
  71. } else {
  72. textView.text = "Hai ancora 1 giorno rimasto di prova."
  73. }
  74. } else {
  75. if numberOfDays > 1 {
  76. textView.text = "Yot have \(numberOfDays) days left in your trial."
  77. } else {
  78. textView.text = "Yot have 1 day left in your trial."
  79. }
  80. }
  81. }
  82. }
  83. @IBAction func purchaseButtonTapped(_ sender: AnyObject) {
  84. guard let capabilities = NCManageDatabase.sharedInstance.getCapabilites(account: appDelegate.activeAccount) else {
  85. return
  86. }
  87. if let url = URL(string: capabilities.HCShopUrl) {
  88. UIApplication.shared.open(url, options: [:])
  89. }
  90. dismiss(animated: true, completion: nil)
  91. }
  92. @IBAction func continueButtonTapped(_ sender: AnyObject) {
  93. dismiss(animated: true, completion: nil)
  94. }
  95. }