Pārlūkot izejas kodu

Change confirmation dialog message #1111

Deniz Cengiz 3 nedēļas atpakaļ
vecāks
revīzija
f09ce6c5c4

+ 11 - 4
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -45770,10 +45770,6 @@
         }
       }
     },
-    "Are you sure you want to activate preset \"%@\"?" : {
-      "comment" : "A confirmation dialog asking the user to confirm the activation of a preset. The argument is the name of the preset to be activated.",
-      "isCommentAutoGenerated" : true
-    },
     "Are you sure you want to delete %@?" : {
       "localizations" : {
         "bg" : {
@@ -221259,6 +221255,17 @@
         }
       }
     },
+    "Start the %@ \"%@\"?" : {
+      "comment" : "Confirmation message for starting a preset",
+      "localizations" : {
+        "en" : {
+          "stringUnit" : {
+            "state" : "new",
+            "value" : "Start the %1$@ \"%2$@\"?"
+          }
+        }
+      }
+    },
     "Start Time" : {
       "localizations" : {
         "bg" : {

+ 1 - 1
Trio/Sources/Modules/Adjustments/AdjustmentsStateModel.swift

@@ -14,7 +14,7 @@ extension Adjustments {
         @ObservationIgnored @Injected() var nightscoutManager: NightscoutManager!
 
         var requireAdjustmentsConfirmation: Bool = false
-        var shouldDisplayPresetActivateConfirmDialog: Bool = false
+        var shouldDisplayPresetStartConfirmDialog: Bool = false
 
         // MARK: - Override and Temp Target Properties
 

+ 22 - 7
Trio/Sources/Modules/Adjustments/View/AdjustmentsRootView.swift

@@ -183,11 +183,13 @@ extension Adjustments {
                     }
 
                     Button("Cancel", role: .cancel) {
-                        state.shouldDisplayPresetActivateConfirmDialog = false
+                        state.shouldDisplayPresetStartConfirmDialog = false
                         pendingPresetActivation = nil
                     }
                 } message: {
-                    Text("Are you sure you want to activate preset \"\(pendingPresetActivation?.name ?? "")\"?")
+                    if let activation = pendingPresetActivation {
+                        Text(activation.confirmationMessage)
+                    }
                 }
             }).background(appState.trioBackgroundColor(for: colorScheme))
         }
@@ -324,18 +326,31 @@ extension Adjustments.RootView: View {
                 return name
             }
         }
+
+        var adjustmentType: String {
+            switch self {
+            case .override:
+                return String(localized: "Override")
+            case .tempTarget:
+                return String(localized: "Temp Target")
+            }
+        }
+
+        var confirmationMessage: String {
+            String(localized: "Start the \(adjustmentType) \"\(name)\"?", comment: "Confirmation message for starting a preset")
+        }
     }
 
     private var presetActivationConfirmationBinding: Binding<Bool> {
         Binding(
             get: {
                 state.requireAdjustmentsConfirmation &&
-                    state.shouldDisplayPresetActivateConfirmDialog &&
+                    state.shouldDisplayPresetStartConfirmDialog &&
                     pendingPresetActivation != nil
             },
             set: { isPresented in
                 if !isPresented {
-                    state.shouldDisplayPresetActivateConfirmDialog = false
+                    state.shouldDisplayPresetStartConfirmDialog = false
                     pendingPresetActivation = nil
                 }
             }
@@ -345,7 +360,7 @@ extension Adjustments.RootView: View {
     func requestPresetActivation(_ activation: PendingPresetActivation) {
         if state.requireAdjustmentsConfirmation {
             pendingPresetActivation = activation
-            state.shouldDisplayPresetActivateConfirmDialog = true
+            state.shouldDisplayPresetStartConfirmDialog = true
         } else {
             activatePreset(activation)
         }
@@ -361,7 +376,7 @@ extension Adjustments.RootView: View {
                     state.hideModal()
                     selectedOverridePresetID = presetID
                     showOverrideCheckmark = true
-                    state.shouldDisplayPresetActivateConfirmDialog = false
+                    state.shouldDisplayPresetStartConfirmDialog = false
                     pendingPresetActivation = nil
                 }
 
@@ -375,7 +390,7 @@ extension Adjustments.RootView: View {
                 await MainActor.run {
                     selectedTempTargetPresetID = presetID
                     showTempTargetCheckmark = true
-                    state.shouldDisplayPresetActivateConfirmDialog = false
+                    state.shouldDisplayPresetStartConfirmDialog = false
                     pendingPresetActivation = nil
                 }