RestoreSafeForgotIdChooseViewController.swift 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 RestoreSafeForgotIdChooseViewController: IDCreationPageViewController {
  22. @IBOutlet weak var contentView: UIStackView!
  23. @IBOutlet weak var descriptionLabel: UILabel!
  24. @IBOutlet weak var cancelButton: SetupButton!
  25. var ids: [String]?
  26. var choosenId: String?
  27. override func viewDidLoad() {
  28. super.viewDidLoad()
  29. self.descriptionLabel.text = BundleUtil.localizedString(forKey: "safe_select_id")
  30. self.cancelButton.setTitle(BundleUtil.localizedString(forKey: "cancel"), for: .normal)
  31. if let ids = self.ids {
  32. var index: Int = 1
  33. for id in ids {
  34. print(id)
  35. let idButton = SetupButton()
  36. idButton.setTitle(id, for: .normal)
  37. idButton.addTarget(self, action: #selector(self.touchIdButton), for: .touchUpInside)
  38. self.contentView.insertArrangedSubview(idButton, at: index)
  39. index += 1
  40. }
  41. }
  42. }
  43. override open var shouldAutorotate: Bool {
  44. return false
  45. }
  46. @objc func touchIdButton(_ sender: SetupButton) {
  47. if let id: String = sender.titleLabel?.text {
  48. self.choosenId = String(id[id.startIndex..<id.index(id.startIndex, offsetBy: 8)])
  49. self.performSegue(withIdentifier: "choosenSafeForgotIdChoose", sender: self)
  50. }
  51. }
  52. }