StorageManagementOlderThanViewController.swift 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // _____ _
  2. // |_ _| |_ _ _ ___ ___ _ __ __ _
  3. // | | | ' \| '_/ -_) -_) ' \/ _` |_
  4. // |_| |_||_|_| \___\___|_|_|_\__,_(_)
  5. //
  6. // Threema iOS Client
  7. // Copyright (c) 2019-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 StorageManagementOlderThanViewController: ThemedTableViewController {
  22. var selectedIndex: Int = 0
  23. override func viewDidLoad() {
  24. super.viewDidLoad()
  25. self.title = BundleUtil.localizedString(forKey: "older_than")
  26. }
  27. // MARK: - Navigation
  28. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  29. guard let cell = sender as? UITableViewCell,
  30. let indexPath = tableView.indexPath(for: cell) else {
  31. return
  32. }
  33. selectedIndex = indexPath.row
  34. }
  35. // MARK: - Table view data source
  36. override func numberOfSections(in tableView: UITableView) -> Int {
  37. return 1
  38. }
  39. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  40. return StorageManagementViewController.OlderThanOption.allCases.count
  41. }
  42. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  43. guard let olderThanOption = StorageManagementViewController.OlderThanOption(rawValue: indexPath.row) else {
  44. fatalError("Unkown table view row \(indexPath.row)")
  45. }
  46. let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "OlderThanCell", for: indexPath)
  47. cell.textLabel?.text = StorageManagementViewController.titleDescription(for: olderThanOption)
  48. cell.accessoryType = indexPath.row == selectedIndex ? .checkmark : .none
  49. return cell
  50. }
  51. }