forked from tidepool-org/LoopSupport
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLoopSupportUI.swift
More file actions
102 lines (76 loc) · 3.14 KB
/
LoopSupportUI.swift
File metadata and controls
102 lines (76 loc) · 3.14 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// LoopSupportUI.swift
// LoopSupportKitUI
//
// Created by Darin Krauss on 1/23/21.
// Copyright © 2021 LoopKit Authors. All rights reserved.
//
import Foundation
import SwiftUI
import LoopKit
import LoopKitUI
public final class LoopSupportUI: SupportUI {
public static var pluginIdentifier: String = "LoopSupportUI"
private var analytics = LoopKitAnalytics.shared
public func checkVersion(bundleIdentifier: String, currentVersion: String) async -> LoopKit.VersionUpdate? {
return nil
}
public func softwareUpdateView(bundleIdentifier: String, currentVersion: String, guidanceColors: GuidanceColors, openAppStore: (() -> Void)?) -> AnyView? { nil }
public init?(rawState: RawStateValue) {
self.rawState = rawState
}
public var rawState: RawStateValue
public init() {
rawState = [:]
}
public func getScenarios(from scenarioURLs: [URL]) -> [LoopScenario] { [] }
public func supportMenuItem(supportInfoProvider: SupportInfoProvider, urlHandler: @escaping (URL) -> Void) -> AnyView? {
return AnyView(Button(LocalizedString("Submit Bug Report", comment: "Navigation link title for Submit Bug Report"), action: {
let url = URL(string: "https://github.com/LoopKit/Loop/issues")!
urlHandler(url)
}))
}
public weak var delegate: SupportUIDelegate?
public func initializationComplete(for services: [LoopKit.Service]) { }
public func configurationMenuItems() -> [LoopKitUI.CustomMenuItem] {
let view = Button(LocalizedString("Submit Bug Report", comment: "Navigation link title for Submit Bug Report"), action: {
let url = URL(string: "https://github.com/LoopKit/Loop/issues")!
self.delegate?.openURL(url: url)
})
return [
CustomMenuItem(section: .support, view: AnyView(view)),
CustomMenuItem(section: .configuration, view: AnyView(UsageDataPrivacyPreferenceMenuItem())),
]
}
public func loopWillReset() { }
public func loopDidReset() { }
}
// LoopSupport also provides analytics
extension LoopSupportUI: AnalyticsService {
public static var localizedTitle = LocalizedString("LoopKit Analytics", comment: "Title for LoopKit Analytics")
public func recordAnalyticsEvent(_ name: String, withProperties properties: [AnyHashable : Any]?, outOfSession: Bool) {
analytics.recordAnalyticsEvent(name, withProperties: properties, outOfSession: outOfSession)
}
public func recordIdentify(_ property: String, value: String) {
analytics.recordIdentify(property, value: value)
}
public func recordIdentify(_ property: String, array: [String]) {
analytics.recordIdentify(property, array: array)
}
public static var serviceIdentifier = "LoopKitAnalytics"
public var serviceDelegate: LoopKit.ServiceDelegate? {
get {
return nil
}
set(newValue) {}
}
public var stateDelegate: LoopKit.StatefulPluggableDelegate? {
get {
return nil
}
set(newValue) {}
}
public var isOnboarded: Bool {
return true
}
}