Browse Source

Make triangle shape concave and follow circle

Deniz Cengiz 1 year ago
parent
commit
1df44799a7

+ 7 - 1
Trio Watch App Extension/Views/CarbsInputView.swift

@@ -7,6 +7,7 @@ struct CarbsInputView: View {
     @Environment(\.dismiss) var dismiss
     @Environment(\.dismiss) var dismiss
     @State private var carbsAmount = 0
     @State private var carbsAmount = 0
     @State private var navigateToBolus = false // Track navigation to BolusInputView
     @State private var navigateToBolus = false // Track navigation to BolusInputView
+    @FocusState private var isCrownFocused: Bool // Manage crown focus
 
 
     let state: WatchState
     let state: WatchState
     let continueToBolus: Bool
     let continueToBolus: Bool
@@ -18,9 +19,14 @@ struct CarbsInputView: View {
         VStack {
         VStack {
             Picker("Carbs", selection: $carbsAmount) {
             Picker("Carbs", selection: $carbsAmount) {
                 ForEach(0 ... 100, id: \.self) { amount in
                 ForEach(0 ... 100, id: \.self) { amount in
-                    Text("\(amount)g").tag(amount)
+                    Text("\(amount) g").tag(amount)
                 }
                 }
             }
             }
+            .focusable(true) // Enable focus for Digital Crown
+            .focused($isCrownFocused) // Bind focus state
+            .onAppear {
+                isCrownFocused = true // Automatically focus when view appears
+            }
 
 
             Button(buttonLabel) {
             Button(buttonLabel) {
                 if continueToBolus {
                 if continueToBolus {

+ 7 - 4
Trio Watch App Extension/Views/TrendShape.swift

@@ -1,16 +1,19 @@
 import SwiftUI
 import SwiftUI
 
 
 struct Triangle: Shape {
 struct Triangle: Shape {
+    /// Flag to be able to adjust size based on Apple Watch size
+    let isSmallDevice: Bool
+
     /// Creates a triangle shape pointing to the right
     /// Creates a triangle shape pointing to the right
     func path(in rect: CGRect) -> Path {
     func path(in rect: CGRect) -> Path {
         var path = Path()
         var path = Path()
 
 
         // Draw the triangle pointing to the right
         // Draw the triangle pointing to the right
-        path.move(to: CGPoint(x: rect.maxX - 10, y: rect.midY))
+        path.move(to: CGPoint(x: rect.maxX - (isSmallDevice ? 7.5 : 9), y: rect.midY))
         path.addLine(to: CGPoint(x: rect.minX, y: rect.minY))
         path.addLine(to: CGPoint(x: rect.minX, y: rect.minY))
         path.addQuadCurve(
         path.addQuadCurve(
             to: CGPoint(x: rect.minX, y: rect.maxY),
             to: CGPoint(x: rect.minX, y: rect.maxY),
-            control: CGPoint(x: rect.midX - 15, y: rect.midY)
+            control: CGPoint(x: rect.midX - (isSmallDevice ? 5 : 7), y: rect.midY)
         )
         )
         path.closeSubpath()
         path.closeSubpath()
 
 
@@ -47,7 +50,7 @@ struct TrendShape: View {
         let strokeWidth: CGFloat = isSmallDevice ? 4 : 5
         let strokeWidth: CGFloat = isSmallDevice ? 4 : 5
         let circleSize: CGFloat = isSmallDevice ? 74 : 92
         let circleSize: CGFloat = isSmallDevice ? 74 : 92
         let triangleSize: CGFloat = isSmallDevice ? 16 : 20
         let triangleSize: CGFloat = isSmallDevice ? 16 : 20
-        let offset: CGFloat = isSmallDevice ? 47 : 56
+        let offset: CGFloat = isSmallDevice ? 47.5 : 59
 
 
         ZStack {
         ZStack {
             // Outer circle with gradient
             // Outer circle with gradient
@@ -57,7 +60,7 @@ struct TrendShape: View {
                 .background(Circle().fill(Color.black))
                 .background(Circle().fill(Color.black))
 
 
             // Triangle with the color of the last gradient color
             // Triangle with the color of the last gradient color
-            Triangle()
+            Triangle(isSmallDevice: isSmallDevice)
                 .fill(triangleColor)
                 .fill(triangleColor)
                 .frame(width: triangleSize, height: triangleSize)
                 .frame(width: triangleSize, height: triangleSize)
                 .offset(x: offset)
                 .offset(x: offset)

+ 1 - 1
Trio Watch App Extension/Views/TrioMainWatchView.swift

@@ -77,7 +77,7 @@ struct TrioMainWatchView: View {
                         showingTreatmentMenuSheet.toggle()
                         showingTreatmentMenuSheet.toggle()
                     } label: {
                     } label: {
                         Image(systemName: "plus")
                         Image(systemName: "plus")
-                            .foregroundStyle(.black)
+                            .foregroundStyle(Color.bgDarkerDarkBlue)
                     }
                     }
                     .controlSize(.large)
                     .controlSize(.large)
                     .buttonStyle(WatchOSButtonStyle())
                     .buttonStyle(WatchOSButtonStyle())