浏览代码

Merge branch 'beta-fixes-2nd-iteration' of github.com:nightscout/Trio-dev into local-testing-02022025

Deniz Cengiz 1 年之前
父节点
当前提交
4405a74b70

+ 8 - 5
LiveActivity/Views/WidgetItems/LiveActivityBGLabelLargeView.swift

@@ -8,18 +8,21 @@ struct LiveActivityBGLabelLargeView: View {
     var glucoseColor: Color
 
     var body: some View {
-        HStack {
+        HStack(alignment: .center) {
             if let trendArrow = context.state.direction {
                 Text(context.state.bg)
-                    .fontWeight(.heavy)
+                    .fontWeight(.bold)
                     .font(.title)
                     .foregroundStyle(context.isStale ? .secondary : glucoseColor)
                     .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))
-                    +
-                    Text(trendArrow).foregroundStyle(context.isStale ? .secondary : glucoseColor)
+
+                Text(trendArrow)
+                    .foregroundStyle(context.isStale ? .secondary : glucoseColor)
+                    .fontWeight(.bold)
+                    .font(.headline)
             } else {
                 Text(context.state.bg)
-                    .fontWeight(.heavy)
+                    .fontWeight(.bold)
                     .font(.title)
                     .foregroundStyle(context.isStale ? .secondary : glucoseColor)
                     .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))

+ 21 - 1
Trio/Sources/Modules/BasalProfileEditor/View/BasalProfileEditorRootView.swift

@@ -24,6 +24,7 @@ extension BasalProfileEditor {
         private var rateFormatter: NumberFormatter {
             let formatter = NumberFormatter()
             formatter.numberStyle = .decimal
+
             return formatter
         }
 
@@ -140,6 +141,20 @@ extension BasalProfileEditor {
                             .foregroundColor(.secondary)
                     }
                 }.listRowBackground(Color.chart)
+
+                Section {} header: {
+                    VStack(alignment: .leading, spacing: 10) {
+                        HStack {
+                            Image(systemName: "note.text.badge.plus").foregroundStyle(.primary)
+                            Text("Add an entry by tapping 'Add Rate +' in the top right-hand corner of the screen.")
+                        }
+                        HStack {
+                            Image(systemName: "hand.draw.fill").foregroundStyle(.primary)
+                            Text("Swipe to delete a single entry. Tap on it, to edit its time or rate.")
+                        }
+                    }
+                    .textCase(nil)
+                }
             }
             .safeAreaInset(edge: .bottom, spacing: 30) { saveButton }
             .alert(isPresented: $state.showAlert) {
@@ -163,7 +178,12 @@ extension BasalProfileEditor {
                     }
                 }
                 ToolbarItem(placement: .topBarTrailing) {
-                    Button(action: { state.add() }) { Image(systemName: "plus") }.disabled(!state.canAdd)
+                    Button(action: { state.add() }) {
+                        HStack {
+                            Text("Add Rate")
+                            Image(systemName: "plus")
+                        }
+                    }.disabled(!state.canAdd)
                 }
             })
             .environment(\.editMode, $editMode)

+ 20 - 1
Trio/Sources/Modules/CarbRatioEditor/View/CarbRatioEditorRootView.swift

@@ -83,6 +83,20 @@ extension CarbRatioEditor {
                 Section(header: Text("Schedule")) {
                     list
                 }.listRowBackground(Color.chart)
+
+                Section {} header: {
+                    VStack(alignment: .leading, spacing: 10) {
+                        HStack {
+                            Image(systemName: "note.text.badge.plus").foregroundStyle(.primary)
+                            Text("Add an entry by tapping 'Add Ratio +' in the top right-hand corner of the screen.")
+                        }
+                        HStack {
+                            Image(systemName: "hand.draw.fill").foregroundStyle(.primary)
+                            Text("Swipe to delete a single entry. Tap on it, to edit its time or rate.")
+                        }
+                    }
+                    .textCase(nil)
+                }
             }
             .safeAreaInset(edge: .bottom, spacing: 30) { saveButton }
             .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
@@ -96,7 +110,12 @@ extension CarbRatioEditor {
                     }
                 }
                 ToolbarItem(placement: .topBarTrailing) {
-                    Button(action: { state.add() }) { Image(systemName: "plus") }.disabled(!state.canAdd)
+                    Button(action: { state.add() }) {
+                        HStack {
+                            Text("Add Ratio")
+                            Image(systemName: "plus")
+                        }
+                    }.disabled(!state.canAdd)
                 }
             })
             .environment(\.editMode, $editMode)

+ 66 - 28
Trio/Sources/Modules/Home/View/Header/LoopStatusView.swift

@@ -6,7 +6,7 @@ struct LoopStatusView: View {
 
     var state: Home.StateModel
 
-    @State var sheetDetent = PresentationDetent.fraction(0.8)
+    @State private var sheetContentHeight = CGFloat.zero
     // Help Sheet
     @State var isHelpSheetPresented: Bool = false
     @State var helpSheetDetent = PresentationDetent.fraction(0.9)
@@ -14,23 +14,49 @@ struct LoopStatusView: View {
     @State private var statusTitle: String = ""
 
     var body: some View {
-        NavigationStack {
+        ScrollView {
             VStack(alignment: .leading, spacing: 10) {
-                Text("Current Loop Status").bold().padding(.top, 20)
+                HStack(alignment: .top) {
+                    VStack(alignment: .leading, spacing: 10) {
+                        Text("Current Loop Status").bold()
 
-                Text(statusTitle)
-                    .font(.headline)
-                    .bold()
-                    .padding(.horizontal, 12)
-                    .padding(.vertical, 6)
-                    .foregroundColor(statusBadgeTextColor)
-                    .background(statusBadgeColor)
-                    .clipShape(Capsule())
+                        Text(statusTitle)
+                            .font(.headline)
+                            .bold()
+                            .padding(.horizontal, 12)
+                            .padding(.vertical, 6)
+                            .foregroundColor(statusBadgeTextColor)
+                            .background(statusBadgeColor)
+                            .clipShape(Capsule())
+                    }
+
+                    Spacer()
+
+                    Button(
+                        action: {
+                            isHelpSheetPresented.toggle()
+                        },
+                        label: {
+                            Image(systemName: "questionmark.circle")
+                        }
+                    )
+                }.padding(.top, 20)
+//                Text("Current Loop Status").bold().padding(.top, 20)
+//
+//                Text(statusTitle)
+//                    .font(.headline)
+//                    .bold()
+//                    .padding(.horizontal, 12)
+//                    .padding(.vertical, 6)
+//                    .foregroundColor(statusBadgeTextColor)
+//                    .background(statusBadgeColor)
+//                    .clipShape(Capsule())
 
                 if let errorMessage = state.errorMessage, let date = state.errorDate {
                     Group {
                         Text("Error During Algorithm Run at \(Formatter.dateFormatter.string(from: date))").font(.headline)
-                        Text(errorMessage).font(.caption)
+                            .fixedSize(horizontal: false, vertical: true)
+                        Text(errorMessage).font(.caption).fixedSize(horizontal: false, vertical: true)
                     }.foregroundColor(.loopRed)
                 }
 
@@ -40,9 +66,11 @@ struct LoopStatusView: View {
                             .bold()
                             .padding(.top)
                             .foregroundStyle(Color.loopRed)
+                            .fixedSize(horizontal: false, vertical: true)
 
                         Text("SMBs and Non-Zero Temp. Basal Rates are disabled.")
                             .font(.subheadline)
+                            .fixedSize(horizontal: false, vertical: true)
 
                     } else {
                         Text("Latest Raw Algorithm Output")
@@ -94,24 +122,13 @@ struct LoopStatusView: View {
             }
             .padding(.vertical)
             .padding(.horizontal, 20)
-            .presentationDetents(
-                [.fraction(0.8), .large],
-                selection: $sheetDetent
-            )
             .ignoresSafeArea(edges: .top)
-            .background(appState.trioBackgroundColor(for: colorScheme))
-            .toolbar(content: {
-                ToolbarItem(placement: .topBarTrailing) {
-                    Button(
-                        action: {
-                            isHelpSheetPresented.toggle()
-                        },
-                        label: {
-                            Image(systemName: "questionmark.circle")
-                        }
-                    )
+            .background {
+                GeometryReader { geo in
+                    Color.clear
+                        .preference(key: ContentSizeKey.self, value: geo.size)
                 }
-            })
+            }
             .onAppear {
                 setStatusTitle()
             }
@@ -119,6 +136,12 @@ struct LoopStatusView: View {
                 LoopStatusHelpView(state: state, helpSheetDetent: $helpSheetDetent, isHelpSheetPresented: $isHelpSheetPresented)
             }
         }
+        .presentationDetents([.height(sheetContentHeight)])
+        .presentationDragIndicator(.visible)
+        .onPreferenceChange(ContentSizeKey.self) { newSize in
+            sheetContentHeight = newSize.height
+        }
+        .background(appState.trioBackgroundColor(for: colorScheme))
         .scrollContentBackground(.hidden)
     }
 
@@ -252,3 +275,18 @@ struct LoopStatusView: View {
         return updatedConclusion.capitalizingFirstLetter()
     }
 }
+
+struct ContentSizeKey: PreferenceKey {
+    static var defaultValue: CGSize = .zero
+
+    static func reduce(value: inout CGSize, nextValue: () -> CGSize) {
+        // If multiple views report sizes, pick whichever logic you prefer:
+        // - The largest height
+        // - The sum
+        // For a single child, just use nextValue() directly if you like.
+        let next = nextValue()
+        if next.height > value.height {
+            value = next
+        }
+    }
+}

+ 20 - 1
Trio/Sources/Modules/ISFEditor/View/ISFEditorRootView.swift

@@ -81,6 +81,20 @@ extension ISFEditor {
                 Section(header: Text("Schedule")) {
                     list
                 }.listRowBackground(Color.chart)
+
+                Section {} header: {
+                    VStack(alignment: .leading, spacing: 10) {
+                        HStack {
+                            Image(systemName: "note.text.badge.plus").foregroundStyle(.primary)
+                            Text("Add an entry by tapping 'Add Sensitivity +' in the top right-hand corner of the screen.")
+                        }
+                        HStack {
+                            Image(systemName: "hand.draw.fill").foregroundStyle(.primary)
+                            Text("Swipe left to delete a single entry. Tap on it, to edit its time or rate.")
+                        }
+                    }
+                    .textCase(nil)
+                }
             }
             .safeAreaInset(edge: .bottom, spacing: 30) { saveButton }
             .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
@@ -94,7 +108,12 @@ extension ISFEditor {
                     }
                 }
                 ToolbarItem(placement: .topBarTrailing) {
-                    Button(action: { state.add() }) { Image(systemName: "plus") }.disabled(!state.canAdd)
+                    Button(action: { state.add() }) {
+                        HStack {
+                            Text("Add Sensitivity")
+                            Image(systemName: "plus")
+                        }
+                    }.disabled(!state.canAdd)
                 }
             })
             .environment(\.editMode, $editMode)

+ 20 - 1
Trio/Sources/Modules/TargetsEditor/View/TargetsEditorRootView.swift

@@ -65,6 +65,20 @@ extension TargetsEditor {
                 Section(header: Text("Schedule")) {
                     list
                 }.listRowBackground(Color.chart)
+
+                Section {} header: {
+                    VStack(alignment: .leading, spacing: 10) {
+                        HStack {
+                            Image(systemName: "note.text.badge.plus").foregroundStyle(.primary)
+                            Text("Add an entry by tapping 'Add Target +' in the top right-hand corner of the screen.")
+                        }
+                        HStack {
+                            Image(systemName: "hand.draw.fill").foregroundStyle(.primary)
+                            Text("Swipe to delete a single entry. Tap on it, to edit its time or rate.")
+                        }
+                    }
+                    .textCase(nil)
+                }
             }
             .safeAreaInset(edge: .bottom, spacing: 30) { saveButton }
             .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
@@ -78,7 +92,12 @@ extension TargetsEditor {
                     }
                 }
                 ToolbarItem(placement: .topBarTrailing) {
-                    Button(action: { state.add() }) { Image(systemName: "plus") }.disabled(!state.canAdd)
+                    Button(action: { state.add() }) {
+                        HStack {
+                            Text("Add Target")
+                            Image(systemName: "plus")
+                        }
+                    }.disabled(!state.canAdd)
                 }
             })
             .environment(\.editMode, $editMode)