Просмотр исходного кода

Meal row and chart chrome polish

Circular alarm bell while not snoozed, carb value centered on the
panel midline, taller header slot for the sensor arc/tag, and a
shared 16pt trailing inset for the rate pill and glossary button.
dnzxy 1 день назад
Родитель
Сommit
370de81b4f

+ 1 - 1
Trio/Sources/Modules/Home/View/HomeLayout.swift

@@ -4,7 +4,7 @@ import CoreGraphics
 enum HomeLayout {
     /// header slot: pump panel / glucose bobble / loop status; includes room
     /// for the sensor arc/tag overhanging the bobble
-    static let headerHeight: CGFloat = 166
+    static let headerHeight: CGFloat = 172
     /// meal panel slot (IOB / COB / delivery rate)
     static let mealSlotHeight: CGFloat = 44
     /// shared slot for adjustment panel and bolus progress (was 8% of screen height)

+ 56 - 41
Trio/Sources/Modules/Home/View/HomeRootView+MealPanel.swift

@@ -5,41 +5,43 @@ import SwiftUI
 
 extension Home.RootView {
     @ViewBuilder func mealPanel() -> some View {
-        HStack {
-            HStack {
-                Image(systemName: "syringe.fill")
-                    .font(.callout)
-                    .foregroundColor(Color.insulin)
-                Text(
-                    (
-                        Formatter.decimalFormatterWithTwoFractionDigits
-                            .string(from: state.currentIOB as NSNumber) ?? "0"
-                    ) +
-                        String(localized: " U", comment: "Insulin unit")
-                )
-                .font(.callout).fontWeight(.bold).fontDesign(.rounded)
-            }
-
-            Spacer()
-
-            HStack {
+        ZStack {
+            // the carb value itself sits on the panel's midline; the icon hangs off it
+            Text(
+                (
+                    Formatter.decimalFormatterWithTwoFractionDigits.string(
+                        from: NSNumber(value: state.enactedAndNonEnactedDeterminations.first?.cob ?? 0)
+                    ) ?? "0"
+                ) +
+                    String(localized: " g", comment: "gram of carbs")
+            )
+            .font(.callout).fontWeight(.bold).fontDesign(.rounded)
+            .overlay(alignment: .leading) {
                 Image(systemName: "fork.knife")
                     .font(.callout)
                     .foregroundColor(.loopYellow)
-                Text(
-                    (
-                        Formatter.decimalFormatterWithTwoFractionDigits.string(
-                            from: NSNumber(value: state.enactedAndNonEnactedDeterminations.first?.cob ?? 0)
-                        ) ?? "0"
-                    ) +
-                        String(localized: " g", comment: "gram of carbs")
-                )
-                .font(.callout).fontWeight(.bold).fontDesign(.rounded)
+                    .alignmentGuide(.leading) { $0.width + 5 }
             }
 
-            Spacer()
+            HStack {
+                HStack {
+                    Image(systemName: "syringe.fill")
+                        .font(.callout)
+                        .foregroundColor(Color.insulin)
+                    Text(
+                        (
+                            Formatter.decimalFormatterWithTwoFractionDigits
+                                .string(from: state.currentIOB as NSNumber) ?? "0"
+                        ) +
+                            String(localized: " U", comment: "Insulin unit")
+                    )
+                    .font(.callout).fontWeight(.bold).fontDesign(.rounded)
+                }
 
-            alarmsPill
+                Spacer()
+
+                alarmsPill
+            }
         }.padding(.horizontal)
     }
 
@@ -57,19 +59,32 @@ extension Home.RootView {
         Button {
             showSnoozeSheet = true
         } label: {
-            HStack(spacing: 5) {
-                Image(systemName: isSnoozed ? "bell.slash.fill" : "bell.fill")
-                    .font(.callout)
-                Text(isSnoozed ? "\(remainingMinutes) m" : String(localized: "Alarms", comment: "Alarms header item"))
-                    .font(.callout).fontWeight(.bold).fontDesign(.rounded)
+            Group {
+                if isSnoozed {
+                    HStack(spacing: 5) {
+                        Image(systemName: "bell.slash.fill")
+                            .font(.callout)
+                        Text("\(remainingMinutes) m")
+                            .font(.callout).fontWeight(.bold).fontDesign(.rounded)
+                    }
+                    .padding(.vertical, 5)
+                    .padding(.horizontal, 10)
+                    .foregroundStyle(.secondary)
+                    .overlay(
+                        Capsule()
+                            .stroke(Color.primary.opacity(0.4), lineWidth: 2)
+                    )
+                } else {
+                    Image(systemName: "bell.fill")
+                        .font(.callout)
+                        .foregroundStyle(.primary)
+                        .frame(width: 32, height: 32)
+                        .overlay(
+                            Circle()
+                                .stroke(Color.primary.opacity(0.4), lineWidth: 2)
+                        )
+                }
             }
-            .padding(.vertical, 5)
-            .padding(.horizontal, 10)
-            .foregroundStyle(isSnoozed ? AnyShapeStyle(.secondary) : AnyShapeStyle(.primary))
-            .overlay(
-                Capsule()
-                    .stroke(Color.primary.opacity(0.4), lineWidth: 2)
-            )
         }
         .buttonStyle(.plain)
     }

+ 3 - 2
Trio/Sources/Modules/Home/View/HomeRootView.swift

@@ -94,7 +94,7 @@ extension Home {
                         .padding(.vertical, 3)
                         .background(Capsule().fill(.ultraThinMaterial))
                         .frame(height: chartHeight * 0.10)
-                        .padding(.trailing, 8)
+                        .padding(.trailing, 16)
                 }
             }
         }
@@ -118,7 +118,8 @@ extension Home {
             }
             .contentShape(Circle())
             .padding(.bottom, 6)
-            .padding(.trailing, 8)
+            // same trailing inset as the alarm bell in the meal row
+            .padding(.trailing, 16)
         }
 
         @ViewBuilder func mainViewElements(_ geo: GeometryProxy) -> some View {