|
@@ -1,3 +1,4 @@
|
|
|
|
|
+import LoopKit
|
|
|
import LoopKitUI
|
|
import LoopKitUI
|
|
|
import SwiftUI
|
|
import SwiftUI
|
|
|
import Swinject
|
|
import Swinject
|
|
@@ -22,6 +23,26 @@ extension CGMSettings {
|
|
|
@State private var noiseAmplitude: Double = UserDefaults.standard.double(forKey: "GlucoseSimulator_NoiseAmplitude")
|
|
@State private var noiseAmplitude: Double = UserDefaults.standard.double(forKey: "GlucoseSimulator_NoiseAmplitude")
|
|
|
@State private var produceStaleValues: Bool = UserDefaults.standard.bool(forKey: "GlucoseSimulator_ProduceStaleValues")
|
|
@State private var produceStaleValues: Bool = UserDefaults.standard.bool(forKey: "GlucoseSimulator_ProduceStaleValues")
|
|
|
|
|
|
|
|
|
|
+ /// Routes "open URL failed" warnings through `TrioAlertManager` so
|
|
|
|
|
+ /// they share the same in-app banner UI as the rest of the alert
|
|
|
|
|
+ /// pipeline (no more SwiftMessages roundtrip).
|
|
|
|
|
+ private func warnOpenFailed(identifier: String, title: String, body: String) {
|
|
|
|
|
+ let content = Alert.Content(
|
|
|
|
|
+ title: title,
|
|
|
|
|
+ body: body,
|
|
|
|
|
+ acknowledgeActionButtonLabel: String(localized: "OK")
|
|
|
|
|
+ )
|
|
|
|
|
+ let alert = Alert(
|
|
|
|
|
+ identifier: Alert.Identifier(managerIdentifier: "trio.cgmSettings", alertIdentifier: identifier),
|
|
|
|
|
+ foregroundContent: content,
|
|
|
|
|
+ backgroundContent: content,
|
|
|
|
|
+ trigger: .immediate,
|
|
|
|
|
+ interruptionLevel: .active,
|
|
|
|
|
+ sound: nil
|
|
|
|
|
+ )
|
|
|
|
|
+ resolver.resolve(TrioAlertManager.self)?.issueAlert(alert)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// Initialize state variables with defaults if needed
|
|
// Initialize state variables with defaults if needed
|
|
|
private func initializeSimulatorSettings() {
|
|
private func initializeSimulatorSettings() {
|
|
|
if centerValue == 0 {
|
|
if centerValue == 0 {
|
|
@@ -65,11 +86,11 @@ extension CGMSettings {
|
|
|
Button {
|
|
Button {
|
|
|
UIApplication.shared.open(appURL, options: [:]) { success in
|
|
UIApplication.shared.open(appURL, options: [:]) { success in
|
|
|
if !success {
|
|
if !success {
|
|
|
- self.router.alertMessage
|
|
|
|
|
- .send(MessageContent(
|
|
|
|
|
- content: "Unable to open the app",
|
|
|
|
|
- type: .warning
|
|
|
|
|
- ))
|
|
|
|
|
|
|
+ warnOpenFailed(
|
|
|
|
|
+ identifier: "cgm.app.open.failed",
|
|
|
|
|
+ title: String(localized: "Open failed"),
|
|
|
|
|
+ body: String(localized: "Unable to open the app")
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -152,11 +173,11 @@ extension CGMSettings {
|
|
|
Button {
|
|
Button {
|
|
|
UIApplication.shared.open(url, options: [:]) { success in
|
|
UIApplication.shared.open(url, options: [:]) { success in
|
|
|
if !success {
|
|
if !success {
|
|
|
- self.router.alertMessage
|
|
|
|
|
- .send(MessageContent(
|
|
|
|
|
- content: "No URL available",
|
|
|
|
|
- type: .warning
|
|
|
|
|
- ))
|
|
|
|
|
|
|
+ warnOpenFailed(
|
|
|
|
|
+ identifier: "nightscout.open.failed",
|
|
|
|
|
+ title: String(localized: "Open failed"),
|
|
|
|
|
+ body: String(localized: "No URL available")
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|