Skip to content

Commit 004f62c

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

File tree

4 files changed

+35
-38
lines changed

4 files changed

+35
-38
lines changed

Loop/Managers/DeviceDataManager.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,15 @@ final class DeviceDataManager {
460460
}
461461

462462
var availablePumpManagers: [PumpManagerDescriptor] {
463-
return pluginManager.availablePumpManagers + availableStaticPumpManagers
463+
var availablePumpManagers = pluginManager.availablePumpManagers + availableStaticPumpManagers
464+
465+
availableSupports.forEach { supportUI in
466+
if supportUI.onlyAllowSimulatorDevices {
467+
availablePumpManagers = []
468+
}
469+
}
470+
471+
return availablePumpManagers
464472
}
465473

466474
func setupPumpManager(withIdentifier identifier: String, initialSettings settings: PumpManagerSetupSettings, prefersToSkipUserInteraction: Bool) -> Swift.Result<SetupUIResult<PumpManagerViewController, PumpManager>, Error> {
@@ -571,6 +579,13 @@ final class DeviceDataManager {
571579
if let pumpManagerAsCGMManager = pumpManager as? CGMManager {
572580
availableCGMManagers.append(CGMManagerDescriptor(identifier: pumpManagerAsCGMManager.managerIdentifier, localizedTitle: pumpManagerAsCGMManager.localizedTitle))
573581
}
582+
583+
availableSupports.forEach { supportUI in
584+
if supportUI.onlyAllowSimulatorDevices {
585+
availableCGMManagers = []
586+
}
587+
}
588+
574589
return availableCGMManagers
575590
}
576591

Loop/Plugins/PluginManager.swift

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

1514
class PluginManager {
1615
let pluginBundles: [Bundle]
1716

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

2419
public init(pluginsURL: URL? = Bundle.main.privateFrameworksURL) {
2520
var bundles = [Bundle]()
@@ -69,18 +64,14 @@ class PluginManager {
6964
}
7065

7166
var availablePumpManagers: [PumpManagerDescriptor] {
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-
}
67+
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+
})
8475
}
8576

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

111102
var availableCGMManagers: [CGMManagerDescriptor] {
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-
}
103+
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+
})
124111
}
125112

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

Loop/View Models/SettingsViewModel.swift

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

1716
public class DeviceViewModel<T>: ObservableObject {
1817
public typealias DeleteTestingDataFunc = () -> Void
@@ -100,12 +99,8 @@ public class SettingsViewModel: ObservableObject {
10099
}
101100
}
102101

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
102+
var showDeleteTestData: Bool {
103+
availableSupports.contains(where: { $0.showsDeleteTestDataUI })
109104
}
110105

111106
lazy private var cancellables = Set<AnyCancellable>()

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) && !viewModel.hideDeleteDataSection {
58+
if (viewModel.pumpManagerSettingsViewModel.isTestingDevice || viewModel.cgmManagerSettingsViewModel.isTestingDevice) && viewModel.showDeleteTestData {
5959
deleteDataSection
6060
}
6161
}

0 commit comments

Comments
 (0)