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

Add back note to treatment, history and NS upload

Deniz Cengiz 1 год назад
Родитель
Сommit
aab67c7e93

+ 2 - 0
FreeAPS/Sources/APS/Storage/CarbsStorage.swift

@@ -156,6 +156,7 @@ final class BaseCarbsStorage: CarbsStorage, Injectable {
             newItem.carbs = Double(truncating: NSDecimalNumber(decimal: entry.carbs))
             newItem.fat = Double(truncating: NSDecimalNumber(decimal: entry.fat ?? 0))
             newItem.protein = Double(truncating: NSDecimalNumber(decimal: entry.protein ?? 0))
+            newItem.note = entry.note
             newItem.id = UUID()
             newItem.isFPU = false
             newItem.isUploadedToNS = false
@@ -260,6 +261,7 @@ final class BaseCarbsStorage: CarbsStorage, Injectable {
                     enteredBy: CarbsEntry.manual,
                     bolus: nil,
                     insulin: nil,
+                    notes: result.note,
                     carbs: Decimal(result.carbs),
                     fat: Decimal(result.fat),
                     protein: Decimal(result.protein),

+ 4 - 0
FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift

@@ -201,6 +201,10 @@ extension Bolus {
                                     label: { Image(systemName: "plus.circle") }.tint(.blue).buttonStyle(.borderless)
                                 }
                             }
+                            HStack {
+                                Text("Note").foregroundColor(.secondary)
+                                TextFieldWithToolBarString(text: $state.note, placeholder: "", maxLength: 25)
+                            }
                         }.listRowBackground(Color.chart)
 
                         Section {

+ 25 - 16
FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift

@@ -453,24 +453,33 @@ extension DataTable {
         }
 
         @ViewBuilder private func mealView(_ meal: CarbEntryStored) -> some View {
-            HStack {
-                if meal.isFPU {
-                    Image(systemName: "circle.fill").foregroundColor(Color.orange.opacity(0.5))
-                    Text("Fat / Protein")
-                    Text((numberFormatter.string(for: meal.carbs) ?? "0") + NSLocalizedString(" g", comment: "gram of carbs"))
-                } else {
-                    Image(systemName: "circle.fill").foregroundColor(Color.loopYellow)
-                    Text("Carbs")
-                    Text(
-                        (numberFormatter.string(for: meal.carbs) ?? "0") +
-                            NSLocalizedString(" g", comment: "gram of carb equilvalents")
-                    )
-                }
+            VStack {
+                HStack {
+                    if meal.isFPU {
+                        Image(systemName: "circle.fill").foregroundColor(Color.orange.opacity(0.5))
+                        Text("Fat / Protein")
+                        Text((numberFormatter.string(for: meal.carbs) ?? "0") + NSLocalizedString(" g", comment: "gram of carbs"))
+                    } else {
+                        Image(systemName: "circle.fill").foregroundColor(Color.loopYellow)
+                        Text("Carbs")
+                        Text(
+                            (numberFormatter.string(for: meal.carbs) ?? "0") +
+                                NSLocalizedString(" g", comment: "gram of carb equilvalents")
+                        )
+                    }
 
-                Spacer()
+                    Spacer()
 
-                Text(dateFormatter.string(from: meal.date ?? Date()))
-                    .moveDisabled(true)
+                    Text(dateFormatter.string(from: meal.date ?? Date()))
+                        .moveDisabled(true)
+                }
+                if let note = meal.note {
+                    HStack {
+                        Image(systemName: "square.and.pencil")
+                        Text(note)
+                        Spacer()
+                    }.padding(.top, 5).foregroundColor(.secondary)
+                }
             }
             .swipeActions {
                 Button(