SettingsVideoChatViewController.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import UIKit
  2. import DcCore
  3. class SettingsVideoChatViewController: UITableViewController {
  4. private var dcContext: DcContext
  5. private lazy var videoInstanceCell: TextFieldCell = {
  6. let cell = TextFieldCell.makeConfigCell(labelID: String.localized("videochat_instance"),
  7. placeholderID: String.localized("videochat_instance_placeholder"))
  8. cell.textField.autocapitalizationType = .none
  9. cell.textField.autocorrectionType = .no
  10. cell.textField.textContentType = .URL
  11. return cell
  12. }()
  13. init(dcContext: DcContext) {
  14. self.dcContext = dcContext
  15. super.init(style: .grouped)
  16. self.title = String.localized("videochat_instance")
  17. hidesBottomBarWhenPushed = true
  18. }
  19. required init?(coder aDecoder: NSCoder) {
  20. fatalError("init(coder:) has not been implemented")
  21. }
  22. // MARK: - Table view data source
  23. override func numberOfSections(in tableView: UITableView) -> Int {
  24. return 1
  25. }
  26. override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  27. return 1
  28. }
  29. override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  30. tableView.deselectRow(at: indexPath, animated: true)
  31. }
  32. override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  33. videoInstanceCell.textField.text = dcContext.getConfig("webrtc_instance")
  34. return videoInstanceCell
  35. }
  36. override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
  37. return String.localized("videochat_instance_explain_2") + "\n\n" + String.localized("videochat_instance_example")
  38. }
  39. override func viewWillDisappear(_ animated: Bool) {
  40. dcContext.setConfig("webrtc_instance", videoInstanceCell.getText())
  41. }
  42. }