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