Skip to content

Commit a3ec912

Browse files
committed
[LOOP-4649] Loop Marketing Demo
1 parent f5e62fd commit a3ec912

File tree

3 files changed

+39
-17
lines changed

3 files changed

+39
-17
lines changed

Loop/Plugins/PluginManager.swift

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ import os.log
1010
import Foundation
1111
import LoopKit
1212
import LoopKitUI
13+
import TidepoolSupport
1314

1415
class PluginManager {
1516
let pluginBundles: [Bundle]
1617

1718
private let log = OSLog(category: "PluginManager")
19+
20+
private var selectedProduct: TidepoolSupport.Product {
21+
TidepoolSupport.Product(rawValue: UserDefaults.appGroup?.productSelection ?? "none") ?? .none
22+
}
1823

1924
public init(pluginsURL: URL? = Bundle.main.privateFrameworksURL) {
2025
var bundles = [Bundle]()
@@ -64,14 +69,18 @@ class PluginManager {
6469
}
6570

6671
var availablePumpManagers: [PumpManagerDescriptor] {
67-
return pluginBundles.compactMap({ (bundle) -> PumpManagerDescriptor? in
68-
guard let title = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.pumpManagerDisplayName.rawValue) as? String,
69-
let identifier = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.pumpManagerIdentifier.rawValue) as? String else {
70-
return nil
71-
}
72-
73-
return PumpManagerDescriptor(identifier: identifier, localizedTitle: title)
74-
})
72+
if selectedProduct.maskDevices {
73+
return []
74+
} else {
75+
return pluginBundles.compactMap({ (bundle) -> PumpManagerDescriptor? in
76+
guard let title = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.pumpManagerDisplayName.rawValue) as? String,
77+
let identifier = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.pumpManagerIdentifier.rawValue) as? String else {
78+
return nil
79+
}
80+
81+
return PumpManagerDescriptor(identifier: identifier, localizedTitle: title)
82+
})
83+
}
7584
}
7685

7786
func getCGMManagerTypeByIdentifier(_ identifier: String) -> CGMManagerUI.Type? {
@@ -100,14 +109,18 @@ class PluginManager {
100109
}
101110

102111
var availableCGMManagers: [CGMManagerDescriptor] {
103-
return pluginBundles.compactMap({ (bundle) -> CGMManagerDescriptor? in
104-
guard let title = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.cgmManagerDisplayName.rawValue) as? String,
105-
let identifier = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.cgmManagerIdentifier.rawValue) as? String else {
106-
return nil
107-
}
108-
109-
return CGMManagerDescriptor(identifier: identifier, localizedTitle: title)
110-
})
112+
if selectedProduct.maskDevices {
113+
return []
114+
} else {
115+
return pluginBundles.compactMap({ (bundle) -> CGMManagerDescriptor? in
116+
guard let title = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.cgmManagerDisplayName.rawValue) as? String,
117+
let identifier = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.cgmManagerIdentifier.rawValue) as? String else {
118+
return nil
119+
}
120+
121+
return CGMManagerDescriptor(identifier: identifier, localizedTitle: title)
122+
})
123+
}
111124
}
112125

113126
func getServiceTypeByIdentifier(_ identifier: String) -> ServiceUI.Type? {

Loop/View Models/SettingsViewModel.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import LoopKit
1212
import LoopKitUI
1313
import SwiftUI
1414
import HealthKit
15+
import TidepoolSupport
1516

1617
public class DeviceViewModel<T>: ObservableObject {
1718
public typealias DeleteTestingDataFunc = () -> Void
@@ -99,6 +100,14 @@ public class SettingsViewModel: ObservableObject {
99100
}
100101
}
101102

103+
var hideDeleteDataSection: Bool {
104+
guard let tidepoolSupport = availableSupports.first(where: { $0 is TidepoolSupport }) as? TidepoolSupport else {
105+
return false
106+
}
107+
108+
return tidepoolSupport.selectedProduct.hideDeleteDataSection
109+
}
110+
102111
lazy private var cancellables = Set<AnyCancellable>()
103112

104113
public init(alertPermissionsChecker: AlertPermissionsChecker,

Loop/Views/SettingsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public struct SettingsView: View {
5555
configurationSection
5656
}
5757
deviceSettingsSection
58-
if viewModel.pumpManagerSettingsViewModel.isTestingDevice || viewModel.cgmManagerSettingsViewModel.isTestingDevice {
58+
if (viewModel.pumpManagerSettingsViewModel.isTestingDevice || viewModel.cgmManagerSettingsViewModel.isTestingDevice) && !viewModel.hideDeleteDataSection {
5959
deleteDataSection
6060
}
6161
}

0 commit comments

Comments
 (0)