Преглед изворни кода

Refactor complete step to reflect overview layout+contents

Deniz Cengiz пре 1 година
родитељ
комит
3e4937be1a

+ 3 - 0
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -181716,6 +181716,9 @@
         }
       }
     },
+    "Super Micro Bolus" : {
+
+    },
     "Super Micro Bolus (SMB)" : {
       "localizations" : {
         "bg" : {

+ 78 - 6
Trio/Sources/Modules/Onboarding/View/OnboardingSteps/CompletedStepView.swift

@@ -20,12 +20,39 @@ struct CompletedStepView: View {
             .foregroundColor(.secondary)
 
             VStack(alignment: .leading, spacing: 12) {
-                ForEach(
-                    nonInfoOnboardingSteps,
-                    id: \.self
-                ) { step in
-                    SettingItemView(step: step, icon: step.iconName, title: step.title, type: .complete)
-                }
+                completedItemsView(
+                    stepIndex: 1,
+                    title: String(localized: "Prepare Trio"),
+                    steps: [.diagnostics, .nightscout, .unitSelection],
+                    description: "App diagnostics sharing, Nightscout setup, and unit and pump model selection are all complete."
+                )
+
+                Divider()
+
+                completedItemsView(
+                    stepIndex: 2,
+                    title: String(localized: "Therapy Settings"),
+                    steps: [.glucoseTarget, .basalRates, .carbRatio, .insulinSensitivity],
+                    description: "Glucose target, basal rates, carb ratios, and insulin sensitivity match your needs."
+                )
+
+                Divider()
+
+                completedItemsView(
+                    stepIndex: 3,
+                    title: String(localized: "Delivery Limits"),
+                    steps: [.deliveryLimits],
+                    description: "Safety boundaries for insulin delivery and carb entries are set to help Trio keep you safe."
+                )
+
+                Divider()
+
+                completedItemsView(
+                    stepIndex: 4,
+                    title: String(localized: "Algorithm Settings"),
+                    steps: [.autosensSettings, .smbSettings, .targetBehavior],
+                    description: "Trio’s algorithm features are customized to fit your preferences and needs."
+                )
             }
             .padding()
             .background(Color.green.opacity(0.1))
@@ -39,4 +66,49 @@ struct CompletedStepView: View {
         .padding()
         .frame(maxWidth: .infinity)
     }
+
+    /// A reusable view for displaying setting items in the completed step.
+    @ViewBuilder private func completedItemsView(
+        stepIndex: Int,
+        title: String,
+        steps _: [OnboardingStep],
+        description: String
+    ) -> some View {
+        VStack(alignment: .leading, spacing: 10) {
+            HStack {
+                HStack(spacing: 14) {
+                    stepCount(stepIndex)
+                    Text(title)
+                        .font(.headline)
+                        .bold()
+                }
+
+                Spacer()
+
+                Image(systemName: "checkmark")
+                    .foregroundStyle(Color.green)
+                    .font(.headline)
+                    .bold()
+            }
+
+            Text(description)
+                .font(.footnote)
+                .foregroundStyle(Color.white.opacity(0.8))
+                .padding(.vertical, 8)
+                .multilineTextAlignment(.leading)
+        }
+    }
+
+    @ViewBuilder private func stepCount(_ count: Int) -> some View {
+        Text(count.description)
+            .font(.subheadline.bold())
+            .frame(width: 26, height: 26, alignment: .center)
+            .background(Color.green)
+            .foregroundStyle(Color.bgDarkerDarkBlue)
+            .clipShape(Capsule())
+    }
+}
+
+#Preview {
+    CompletedStepView()
 }

+ 1 - 67
Trio/Sources/Modules/Onboarding/View/OnboardingView+Util.swift

@@ -66,7 +66,7 @@ enum OnboardingStep: Int, CaseIterable, Identifiable, Equatable {
         case .autosensSettings:
             return String(localized: "Autosens")
         case .smbSettings:
-            return String(localized: "Super Micro Bolus (SMB)")
+            return String(localized: "Super Micro Bolus")
         case .targetBehavior:
             return String(localized: "Target Behavior")
         case .completed:
@@ -437,15 +437,6 @@ struct BulletPoint: View {
     }
 }
 
-enum OnboardingSettingItemType: Equatable, CaseIterable, Identifiable {
-    case overview
-    case complete
-
-    var id: UUID {
-        UUID()
-    }
-}
-
 enum OnboardingInputSectionType: Equatable {
     case decimal
     case boolean
@@ -461,60 +452,3 @@ enum OnboardingInputSectionType: Equatable {
         }
     }
 }
-
-/// A reusable view for displaying setting items in the completed step.
-struct SettingItemView: View {
-    let step: OnboardingStep
-    let icon: String
-    let title: String
-    let type: OnboardingSettingItemType
-
-    private var accentColor: Color {
-        switch type {
-        case .overview:
-            Color.blue
-        case .complete:
-            Color.green
-        }
-    }
-
-    var body: some View {
-        HStack(spacing: 10) {
-            if step == .nightscout {
-                Image(icon)
-                    .resizable()
-                    .scaledToFit()
-                    .frame(width: 40, height: 24)
-                    .colorMultiply(accentColor)
-            } else {
-                Image(systemName: icon)
-                    .font(.system(size: 24))
-                    .foregroundStyle(accentColor)
-                    .frame(width: 40)
-            }
-
-            VStack(alignment: .leading, spacing: 2) {
-                Text(title)
-                    .font(.headline)
-            }
-
-            Spacer()
-
-            switch type {
-            case .overview:
-                let index = nonInfoOnboardingSteps.firstIndex(of: step) ?? 0
-                let stepNumber = index + 1
-                Text(stepNumber.description)
-                    .bold()
-                    .frame(width: 32, height: 32, alignment: .center)
-                    .background(accentColor)
-                    .foregroundStyle(.white)
-                    .clipShape(Capsule())
-            case .complete:
-                Image(systemName: "checkmark")
-                    .foregroundStyle(accentColor)
-            }
-        }
-        .padding(.vertical, 8)
-    }
-}