RileyLinkSettingsViewController.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // RileyLinkSettingsViewController.swift
  3. // Loop
  4. //
  5. // Copyright © 2018 LoopKit Authors. All rights reserved.
  6. //
  7. import UIKit
  8. import CoreBluetooth
  9. import RileyLinkBLEKit
  10. import RileyLinkKit
  11. open class RileyLinkSettingsViewController: UITableViewController {
  12. public let devicesDataSource: RileyLinkDevicesTableViewDataSource
  13. public init(rileyLinkPumpManager: RileyLinkPumpManager, devicesSectionIndex: Int, style: UITableView.Style) {
  14. devicesDataSource = RileyLinkDevicesTableViewDataSource(rileyLinkPumpManager: rileyLinkPumpManager, devicesSectionIndex: devicesSectionIndex)
  15. super.init(style: style)
  16. }
  17. public required init?(coder aDecoder: NSCoder) {
  18. fatalError("init(coder:) has not been implemented")
  19. }
  20. override open func viewDidLoad() {
  21. super.viewDidLoad()
  22. devicesDataSource.tableView = tableView
  23. }
  24. override open func viewDidAppear(_ animated: Bool) {
  25. super.viewDidAppear(animated)
  26. devicesDataSource.isScanningEnabled = true
  27. }
  28. override open func viewWillDisappear(_ animated: Bool) {
  29. super.viewWillDisappear(animated)
  30. devicesDataSource.isScanningEnabled = false
  31. }
  32. // MARK: - UITableViewDataSource
  33. override open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  34. return devicesDataSource.tableView(tableView, numberOfRowsInSection: section)
  35. }
  36. override open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  37. return devicesDataSource.tableView(tableView, cellForRowAt: indexPath)
  38. }
  39. override open func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
  40. return devicesDataSource.tableView(tableView, titleForHeaderInSection: section)
  41. }
  42. // MARK: - UITableViewDelegate
  43. override open func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
  44. return devicesDataSource.tableView(tableView, viewForHeaderInSection: section)
  45. }
  46. }