MockCGMManager+UI.swift 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // MockCGMManager+UI.swift
  3. // LoopKitUI
  4. //
  5. // Created by Michael Pangburn on 11/23/18.
  6. // Copyright © 2018 LoopKit Authors. All rights reserved.
  7. //
  8. import UIKit
  9. import SwiftUI
  10. import HealthKit
  11. import LoopKit
  12. import LoopKitUI
  13. import MockKit
  14. extension MockCGMManager: CGMManagerUI {
  15. fileprivate var appName: String {
  16. return Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as! String
  17. }
  18. public static var onboardingImage: UIImage? { return UIImage(named: "CGM Simulator", in: Bundle(for: MockCGMManagerSettingsViewController.self), compatibleWith: nil) }
  19. public var smallImage: UIImage? { return UIImage(named: "CGM Simulator", in: Bundle(for: MockCGMManagerSettingsViewController.self), compatibleWith: nil) }
  20. public static func setupViewController(bluetoothProvider: BluetoothProvider, displayGlucosePreference: DisplayGlucosePreference, colorPalette: LoopUIColorPalette, allowDebugFeatures: Bool, prefersToSkipUserInteraction: Bool) -> SetupUIResult<CGMManagerViewController, CGMManagerUI> {
  21. return .createdAndOnboarded(MockCGMManager())
  22. }
  23. public func settingsViewController(bluetoothProvider: BluetoothProvider, displayGlucosePreference: DisplayGlucosePreference, colorPalette: LoopUIColorPalette, allowDebugFeatures: Bool) -> CGMManagerViewController {
  24. let settings = MockCGMManagerSettingsView(cgmManager: self, displayGlucosePreference: displayGlucosePreference, appName: appName, allowDebugFeatures: allowDebugFeatures)
  25. let hostingController = DismissibleHostingController(content: settings, isModalInPresentation: false, colorPalette: colorPalette)
  26. hostingController.navigationItem.backButtonDisplayMode = .generic
  27. let nav = CGMManagerSettingsNavigationViewController(rootViewController: hostingController)
  28. nav.navigationBar.prefersLargeTitles = true
  29. return nav
  30. }
  31. public var cgmStatusBadge: DeviceStatusBadge? {
  32. return self.mockSensorState.cgmStatusBadge
  33. }
  34. public var cgmStatusHighlight: DeviceStatusHighlight? {
  35. return self.mockSensorState.cgmStatusHighlight
  36. }
  37. public var cgmLifecycleProgress: DeviceLifecycleProgress? {
  38. return self.mockSensorState.cgmLifecycleProgress
  39. }
  40. }