forked from LoopKit/LoopKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCGMManagerUI.swift
More file actions
86 lines (71 loc) · 3.61 KB
/
CGMManagerUI.swift
File metadata and controls
86 lines (71 loc) · 3.61 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// CGMManagerUI.swift
// LoopKitUI
//
// Copyright © 2018 LoopKit Authors. All rights reserved.
//
import HealthKit
import SwiftUI
import LoopKit
public struct CGMManagerDescriptor {
public let identifier: String
public let localizedTitle: String
public init(identifier: String, localizedTitle: String) {
self.identifier = identifier
self.localizedTitle = localizedTitle
}
}
public protocol CGMStatusIndicator {
/// a message from the cgm that needs to be brought to the user's attention in the status bar
var cgmStatusHighlight: DeviceStatusHighlight? { get }
/// the completed percent of the progress bar to display in the status bar
var cgmLifecycleProgress: DeviceLifecycleProgress? { get }
/// a badge from the cgm that needs to be brought to the user's attention in the status bar
var cgmStatusBadge: DeviceStatusBadge? { get }
/// gets the range category of a glucose sample using the CGM manager managed glucose thresholds
func glucoseRangeCategory(for glucose: GlucoseSampleValue) -> GlucoseRangeCategory?
}
public typealias CGMManagerViewController = (UIViewController & CGMManagerOnboarding & CompletionNotifying)
public protocol CGMManagerUI: CGMManager, DeviceManagerUI, DisplayGlucoseUnitObserver, CGMStatusIndicator {
/// Create and onboard a new CGM manager.
///
/// - Parameters:
/// - bluetoothProvider: The provider of Bluetooth functionality.
/// - displayGlucosePreference: The glucose units to use for display.
/// - colorPalette: Color palette to use for any UI.
/// - Returns: Either a conforming view controller to create and onboard the CGM manager or a newly created and onboarded CGM manager.
static func setupViewController(bluetoothProvider: BluetoothProvider, displayGlucosePreference: DisplayGlucosePreference, colorPalette: LoopUIColorPalette, allowDebugFeatures: Bool, prefersToSkipUserInteraction: Bool) -> SetupUIResult<CGMManagerViewController, CGMManagerUI>
/// Configure settings for an existing CGM manager.
///
/// - Parameters:
/// - bluetoothProvider: The provider of Bluetooth functionality.
/// - displayGlucosePreference: The glucose units to use for display.
/// - colorPalette: Color palette to use for any UI.
/// - Returns: A view controller to configure an existing CGM manager.
func settingsViewController(bluetoothProvider: BluetoothProvider, displayGlucosePreference: DisplayGlucosePreference, colorPalette: LoopUIColorPalette, allowDebugFeatures: Bool) -> CGMManagerViewController
}
extension CGMManagerUI {
public func glucoseRangeCategory(for glucose: GlucoseSampleValue) -> GlucoseRangeCategory? {
return nil
}
/// When conformance to the DisplayGlucoseUnitObserver is desired, use this function to be notified when the user display glucose unit changes
public func unitDidChange(to displayGlucoseUnit: HKUnit) {
// optional
}
}
public protocol CGMManagerOnboardingDelegate: AnyObject {
/// Informs the delegate that the specified CGM manager was created.
///
/// - Parameters:
/// - cgmManager: The CGM manager created.
func cgmManagerOnboarding(didCreateCGMManager cgmManager: CGMManagerUI)
/// Informs the delegate that the specified CGM manager was onboarded.
///
/// - Parameters:
/// - cgmManager: The CGM manager onboarded.
func cgmManagerOnboarding(didOnboardCGMManager cgmManager: CGMManagerUI)
}
public protocol CGMManagerOnboarding {
/// Delegate to notify about CGM manager onboarding.
var cgmManagerOnboardingDelegate: CGMManagerOnboardingDelegate? { get set }
}