SimpleTableViewController.swift 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  3. // SPDX-License-Identifier: GPL-3.0-or-later
  4. //
  5. class SimpleTableViewController: UITableViewController {
  6. let options: [String]
  7. let navigationTitle: String
  8. init(withOptions options: [String], withTitle title: String) {
  9. self.options = options
  10. self.navigationTitle = title
  11. super.init(style: .insetGrouped)
  12. }
  13. required init?(coder: NSCoder) {
  14. fatalError("init(coder:) has not been implemented")
  15. }
  16. override func viewDidLoad() {
  17. super.viewDidLoad()
  18. self.navigationController?.navigationBar.isTranslucent = false
  19. self.navigationItem.title = navigationTitle
  20. self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: NCAppBranding.themeTextColor()]
  21. self.navigationController?.navigationBar.tintColor = NCAppBranding.themeTextColor()
  22. self.navigationController?.navigationBar.barTintColor = NCAppBranding.themeColor()
  23. self.tabBarController?.tabBar.tintColor = NCAppBranding.themeColor()
  24. let themeColor: UIColor = NCAppBranding.themeColor()
  25. let appearance = UINavigationBarAppearance()
  26. appearance.configureWithOpaqueBackground()
  27. appearance.backgroundColor = themeColor
  28. appearance.titleTextAttributes = [.foregroundColor: NCAppBranding.themeTextColor()]
  29. self.navigationItem.standardAppearance = appearance
  30. self.navigationItem.compactAppearance = appearance
  31. self.navigationItem.scrollEdgeAppearance = appearance
  32. }
  33. // MARK: Table view data source
  34. override func numberOfSections(in tableView: UITableView) -> Int {
  35. return 1
  36. }
  37. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  38. return options.count
  39. }
  40. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  41. let cell = UITableViewCell(style: .default, reuseIdentifier: "SimpleTableViewCell")
  42. cell.textLabel?.text = options[indexPath.row]
  43. cell.selectionStyle = .none
  44. return cell
  45. }
  46. }