فهرست منبع

fix checkmarks for temp targets

polscm32 2 سال پیش
والد
کامیت
f89d110eb1
1فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 6 2
      FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift

+ 6 - 2
FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift

@@ -14,6 +14,7 @@ extension OverrideProfilesConfig {
         @State private var alertSring = ""
         @State var isSheetPresented: Bool = false
         @State private var showCheckmark: Bool = false
+        @State private var selectedPresetID: String?
         // temp targets
         @State private var isPromptPresented = false
         @State private var isRemoveAlertPresented = false
@@ -489,6 +490,8 @@ extension OverrideProfilesConfig {
                 low = low?.asMmolL
                 high = high?.asMmolL
             }
+            let isSelected = preset.id == selectedPresetID
+            
             return ZStack(alignment: .trailing, content: {
                 HStack {
                     VStack {
@@ -522,6 +525,7 @@ extension OverrideProfilesConfig {
                     .contentShape(Rectangle())
                     .onTapGesture {
                         state.enactPreset(id: preset.id)
+                        selectedPresetID = preset.id
                         showCheckmark.toggle()
                         
                         //deactivate showCheckmark after 3 seconds
@@ -530,7 +534,7 @@ extension OverrideProfilesConfig {
                         }
                     }
         
-                Image(systemName: "xmark.circle").foregroundColor(showCheckmark ? Color.clear : Color.secondary)
+                Image(systemName: "xmark.circle").foregroundColor(showCheckmark && isSelected ? Color.clear : Color.secondary)
                     .contentShape(Rectangle())
                     .padding(.vertical)
                     .onTapGesture {
@@ -546,7 +550,7 @@ extension OverrideProfilesConfig {
                         removeAlert!
                     }
                 }
-                if showCheckmark {
+                if showCheckmark && isSelected {
                     //show checkmark to indicate if the preset was actually pressed
                     Image(systemName: "checkmark.circle.fill")
                         .imageScale(.large)