Pārlūkot izejas kodu

Introduce teratment options context sheet WIP

Deniz Cengiz 1 gadu atpakaļ
vecāks
revīzija
d332b97c43

+ 108 - 0
Trio Watch App Extension/Views/TreatmentMenuView.swift

@@ -0,0 +1,108 @@
+import SwiftUI
+
+struct TreatmentMenuView: View {
+    @Environment(\.presentationMode) var presentationMode
+    let treatments = TreatmentOptions.allCases
+    @State private var selectedOption: TreatmentOptions? = nil
+
+    var body: some View {
+        ScrollView {
+            HStack {
+                Spacer()
+                Text("Choose Treatment:")
+                    .font(.subheadline)
+                    .foregroundStyle(.primary)
+                Spacer()
+            }
+
+            // Options list
+            VStack(spacing: 10) {
+                ForEach(treatments) { treatment in
+                    Button(action: {
+                        selectedOption = treatment
+                        presentationMode.wrappedValue.dismiss() // Close after selecting
+                    }) {
+                        HStack(alignment: .center, spacing: 8) {
+                            switch treatment {
+                            case .mealBolusCombo:
+                                // First Icon
+                                HStack(spacing: 0) {
+                                    Image(systemName: "fork.knife")
+                                        .resizable()
+                                        .aspectRatio(contentMode: .fit)
+                                        .frame(width: 22, height: 22) // Icon size
+                                        .padding(10) // Padding inside the circle
+                                        .background(Color.orange) // Circle background color
+                                        .clipShape(Circle())
+
+                                    // Plus Icon
+                                    Image(systemName: "plus")
+                                        .font(.caption)
+                                        .bold()
+                                        .frame(width: 24, height: 24) // Ensures consistent sizing
+
+                                    // Second Icon
+                                    Image(systemName: "syringe.fill")
+                                        .resizable()
+                                        .aspectRatio(contentMode: .fit)
+                                        .frame(width: 22, height: 22) // Icon size
+                                        .padding(10)
+                                        .background(Color.blue)
+                                        .clipShape(Circle())
+                                }
+                            case .meal:
+                                Image(systemName: "fork.knife")
+                                    .resizable()
+                                    .aspectRatio(contentMode: .fit)
+                                    .frame(width: 22, height: 22) // Icon size
+                                    .padding(10)
+                                    .background(Color.orange)
+                                    .clipShape(Circle())
+
+                            case .bolus:
+                                Image(systemName: "syringe.fill")
+                                    .resizable()
+                                    .aspectRatio(contentMode: .fit)
+                                    .frame(width: 22, height: 22) // Icon size
+                                    .padding(10)
+                                    .background(Color.blue)
+                                    .clipShape(Circle())
+                            }
+                        }
+                        .foregroundColor(.white)
+                        .frame(maxWidth: .infinity)
+                    }
+                    .buttonStyle(PressableIconButtonStyle())
+                }
+            }
+            .padding(.horizontal)
+            .background(Color.clear)
+        }
+        .frame(maxWidth: .infinity, maxHeight: .infinity)
+        .background(Color.clear)
+    }
+}
+
+enum TreatmentOptions: String, CaseIterable, Identifiable {
+    var id: String { rawValue }
+
+    case mealBolusCombo
+    case meal
+    case bolus
+
+    var displayName: String {
+        switch self {
+        case .mealBolusCombo: return "Meal & Bolus"
+        case .meal: return "Meal"
+        case .bolus: return "Bolus"
+        }
+    }
+}
+
+struct PressableIconButtonStyle: ButtonStyle {
+    func makeBody(configuration: Configuration) -> some View {
+        configuration.label
+            .opacity(configuration.isPressed ? 0.6 : 1.0) // Change opacity when pressed
+            .animation(.easeInOut(duration: 0.2), value: configuration.isPressed) // Smooth transition
+    }
+}

+ 5 - 8
Trio Watch App Extension/Views/TrioMainWatchView.swift

@@ -3,8 +3,7 @@ import SwiftUI
 
 struct TrioMainWatchView: View {
     @State private var state = WatchState()
-    @State private var showingCarbsSheet = false
-    @State private var showingBolusSheet = false
+    @State private var isTreatmentMenuSheetPresented: Bool = false
     @State private var currentPage: Double = 0
     @State private var rotationDegrees: Double = 0.0
 
@@ -78,7 +77,7 @@ struct TrioMainWatchView: View {
                     }
 
                     Button {
-                        // Perform an action here.
+                        isTreatmentMenuSheetPresented.toggle()
                     } label: {
                         Image(systemName: "plus")
                             .foregroundStyle(Color.black)
@@ -112,11 +111,9 @@ struct TrioMainWatchView: View {
         .tabViewStyle(.verticalPage)
         .navigationBarHidden(true)
         .digitalCrownRotation($currentPage, from: 0, through: 1, by: 1)
-        .sheet(isPresented: $showingCarbsSheet) {
-            CarbsInputView(state: state)
-        }
-        .sheet(isPresented: $showingBolusSheet) {
-            BolusInputView(state: state)
+        .blur(radius: isTreatmentMenuSheetPresented ? 10 : 0)
+        .sheet(isPresented: $isTreatmentMenuSheetPresented) {
+            TreatmentMenuView().presentationBackground(.clear)
         }
     }
 

+ 4 - 0
Trio.xcodeproj/project.pbxproj

@@ -456,6 +456,7 @@
 		DD6B7CB92C7BAC6900B75029 /* NightscoutImportResultView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6B7CB82C7BAC6900B75029 /* NightscoutImportResultView.swift */; };
 		DD6B7CBB2C7FBBFA00B75029 /* ReviewInsulinActionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6B7CBA2C7FBBFA00B75029 /* ReviewInsulinActionView.swift */; };
 		DD6D67E42C9C253500660C9B /* ColorSchemeOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6D67E32C9C253500660C9B /* ColorSchemeOption.swift */; };
+		DD6F63CC2D27F615007D94CF /* TreatmentMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD6F63CB2D27F606007D94CF /* TreatmentMenuView.swift */; };
 		DD88C8E22C50420800F2D558 /* DefinitionRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD88C8E12C50420800F2D558 /* DefinitionRow.swift */; };
 		DD940BAA2CA7585D000830A5 /* GlucoseColorScheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD940BA92CA7585D000830A5 /* GlucoseColorScheme.swift */; };
 		DD940BAC2CA75889000830A5 /* DynamicGlucoseColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD940BAB2CA75889000830A5 /* DynamicGlucoseColor.swift */; };
@@ -1161,6 +1162,7 @@
 		DD6B7CB82C7BAC6900B75029 /* NightscoutImportResultView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NightscoutImportResultView.swift; sourceTree = "<group>"; };
 		DD6B7CBA2C7FBBFA00B75029 /* ReviewInsulinActionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewInsulinActionView.swift; sourceTree = "<group>"; };
 		DD6D67E32C9C253500660C9B /* ColorSchemeOption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorSchemeOption.swift; sourceTree = "<group>"; };
+		DD6F63CB2D27F606007D94CF /* TreatmentMenuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TreatmentMenuView.swift; sourceTree = "<group>"; };
 		DD88C8E12C50420800F2D558 /* DefinitionRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefinitionRow.swift; sourceTree = "<group>"; };
 		DD940BA92CA7585D000830A5 /* GlucoseColorScheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GlucoseColorScheme.swift; sourceTree = "<group>"; };
 		DD940BAB2CA75889000830A5 /* DynamicGlucoseColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DynamicGlucoseColor.swift; sourceTree = "<group>"; };
@@ -2456,6 +2458,7 @@
 		BDA25F1A2D26BCE800035F34 /* Views */ = {
 			isa = PBXGroup;
 			children = (
+				DD6F63CB2D27F606007D94CF /* TreatmentMenuView.swift */,
 				BDA25F212D26D62200035F34 /* BolusInputView.swift */,
 				BDA25F1F2D26D5FB00035F34 /* CarbsInputView.swift */,
 				BDA25F1D2D26D5D800035F34 /* GlucoseChartView.swift */,
@@ -3952,6 +3955,7 @@
 				BDA25F1C2D26BD0700035F34 /* TrendShape.swift in Sources */,
 				BDFF7A892D25F97D0016C40C /* TrioWatchApp.swift in Sources */,
 				BDA25F1E2D26D5DD00035F34 /* GlucoseChartView.swift in Sources */,
+				DD6F63CC2D27F615007D94CF /* TreatmentMenuView.swift in Sources */,
 				BDA25EE62D260D5E00035F34 /* WatchState.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;