Explorar o código

Change button position; make it sticky. Add confirm dialog

Deniz Cengiz hai 1 ano
pai
achega
3639e399ae

+ 4 - 4
Trio/Sources/APS/CGM/CGMType.swift

@@ -14,7 +14,7 @@ enum CGMType: String, JSON, CaseIterable, Identifiable {
         case .none:
             return "None"
         case .nightscout:
-            return "Nightscout"
+            return "Nightscout-as-CGM"
         case .xdrip:
             return "xDrip4iOS"
         case .simulator:
@@ -52,16 +52,16 @@ enum CGMType: String, JSON, CaseIterable, Identifiable {
     var subtitle: String {
         switch self {
         case .none:
-            return NSLocalizedString("None", comment: "No CGM choiced")
+            return NSLocalizedString("None", comment: "No CGM selected")
         case .nightscout:
-            return NSLocalizedString("Online or internal server", comment: "Online or internal server")
+            return NSLocalizedString("Uses your Nightscout as CGM", comment: "Online or internal server")
         case .xdrip:
             return NSLocalizedString(
                 "Using shared app group with external CGM app xDrip4iOS",
                 comment: "Shared app group xDrip4iOS"
             )
         case .simulator:
-            return NSLocalizedString("Simple simulator", comment: "Simple simulator")
+            return NSLocalizedString("Glucose Simulator for Demo Only", comment: "Simple simulator")
         case .enlite:
             return NSLocalizedString("Minilink transmitter", comment: "Minilink transmitter")
         case .plugin:

+ 41 - 12
Trio/Sources/Modules/CGM/View/OtherCGMView.swift

@@ -13,6 +13,8 @@ extension CGM {
         @Environment(AppState.self) var appState
         @Environment(\.presentationMode) var presentationMode
 
+        @State private var shouldDisplayDeletionConfirmation: Bool = false
+
         var body: some View {
             NavigationView {
                 Form {
@@ -84,18 +86,6 @@ extension CGM {
                             }
                         ).listRowBackground(Color.chart)
                     }
-
-                    Button {
-                        deleteCGM()
-                    } label: {
-                        Text("Delete CGM")
-                            .font(.headline)
-                            .foregroundStyle(Color.white)
-                            .frame(maxWidth: .infinity, alignment: .center)
-                            .frame(height: 35)
-                    }
-                    .listRowBackground(Color(.systemRed))
-                    .clipShape(RoundedRectangle(cornerRadius: 8))
                 }
                 .navigationTitle(cgmCurrent.displayName)
                 .navigationBarTitleDisplayMode(.inline)
@@ -108,8 +98,47 @@ extension CGM {
                         }
                     }
                 }
+                .safeAreaInset(
+                    edge: .bottom,
+                    spacing: 30
+                ) {
+                    stickyDeleteButton
+                }
                 .scrollContentBackground(.hidden)
                 .background(appState.trioBackgroundColor(for: colorScheme))
+                .confirmationDialog("Delete CGM", isPresented: $shouldDisplayDeletionConfirmation) {
+                    Button(role: .destructive) {
+                        deleteCGM()
+                    } label: {
+                        Text("Delete \(cgmCurrent.displayName)")
+                            .font(.headline)
+                            .tint(.red)
+                    }
+                } message: { Text("Are you sure you want to delete \(cgmCurrent.displayName)?") }
+            }
+        }
+
+        var stickyDeleteButton: some View {
+            ZStack {
+                Rectangle()
+                    .frame(width: UIScreen.main.bounds.width, height: 65)
+                    .foregroundStyle(colorScheme == .dark ? Color.bgDarkerDarkBlue : Color.white)
+                    .background(.thinMaterial)
+                    .opacity(0.8)
+                    .clipShape(Rectangle())
+
+                Button(action: {
+                    shouldDisplayDeletionConfirmation.toggle()
+                }, label: {
+                    Text("Delete CGM")
+                        .frame(maxWidth: .infinity, maxHeight: .infinity)
+                        .padding(10)
+                })
+                    .frame(width: UIScreen.main.bounds.width * 0.9, height: 40, alignment: .center)
+                    .background(Color(.systemRed))
+                    .tint(.white)
+                    .clipShape(RoundedRectangle(cornerRadius: 8))
+                    .padding(5)
             }
         }
     }