SafeIntroViewController.swift 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2018-2020 Threema GmbH
  8. //
  9. // This program is free software: you can redistribute it and/or modify
  10. // it under the terms of the GNU Affero General Public License, version 3,
  11. // as published by the Free Software Foundation.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU Affero General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Affero General Public License
  19. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. import UIKit
  21. class SafeIntroViewController: ThemedViewController {
  22. @IBOutlet weak var mainContent: UIStackView!
  23. @IBOutlet weak var titleLabel: UILabel!
  24. @IBOutlet weak var descriptionLabel: UILabel!
  25. @IBOutlet weak var introCircle: UIView!
  26. @IBOutlet weak var introImage: UIImageView!
  27. @IBOutlet weak var explainLabel: UILabel!
  28. @IBOutlet weak var okButton: SetupButton!
  29. @IBOutlet weak var cancelButton: SetupButton!
  30. override func viewDidLoad() {
  31. super.viewDidLoad()
  32. self.titleLabel.text = BundleUtil.localizedString(forKey: "safe_intro_title")
  33. self.descriptionLabel.text = BundleUtil.localizedString(forKey: "safe_intro_description")
  34. self.introCircle.layer.cornerRadius = self.introCircle.frame.height / 2
  35. self.introCircle.backgroundColor = UIColor(red: 235.0/255.0, green: 235.0/255.0, blue: 235.0/255.0, alpha: 1.0)
  36. self.explainLabel.text = BundleUtil.localizedString(forKey: "safe_intro_explain")
  37. self.cancelButton.setTitle(BundleUtil.localizedString(forKey: "safe_intro_cancel"), for: .normal)
  38. self.okButton.setTitle(BundleUtil.localizedString(forKey: "safe_intro_enable"), for: .normal)
  39. self.cancelButton.accentColor = Colors.main()
  40. self.cancelButton.textColor = Colors.fontNormal()
  41. self.okButton.accentColor = Colors.main()
  42. self.okButton.textColor = Colors.fontInverted()
  43. }
  44. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  45. guard let navigationController = segue.destination as? UINavigationController else {
  46. return
  47. }
  48. if let safeSetupPasswordViewController = navigationController.topViewController as? SafeSetupPasswordViewController {
  49. safeSetupPasswordViewController.isOpenedFromIntro = true
  50. }
  51. }
  52. }
  53. extension SafeIntroViewController {
  54. @IBAction func touchDownButton(_ sender: UIButton, forEvent event: UIEvent) {
  55. self.dismiss(animated: true, completion: nil)
  56. }
  57. @IBAction func doneSafeIntroPassword(_ segue: UIStoryboardSegue) {
  58. guard segue.source is SafeSetupPasswordViewController else {
  59. return
  60. }
  61. // object: 0 -> 0s backup delay and force it
  62. NotificationCenter.default.post(name: NSNotification.Name(kSafeBackupTrigger), object: 0)
  63. self.dismiss(animated: true, completion: nil)
  64. }
  65. }