From 4cf0f201dcd6243bb8fb7bfefcb5502ed784348a Mon Sep 17 00:00:00 2001 From: dnzxy Date: Thu, 28 Sep 2023 22:06:56 +0200 Subject: [PATCH 01/61] Add non-pump insulin; add new colors for SMBs and non-pump --- .../NonPumpInsulin.colorset/Contents.json | 38 +++++++++++++++++++ .../Colors/SMB.colorset/Contents.json | 38 +++++++++++++++++++ .../APS/Storage/PumpHistoryStorage.swift | 7 ++-- .../Sources/Helpers/Color+Extensions.swift | 4 ++ FreeAPS/Sources/Models/PumpHistoryEvent.swift | 9 ++++- .../Modules/Bolus/BolusStateModel.swift | 3 +- .../Modules/DataTable/DataTableDataFlow.swift | 25 ++++++++---- .../DataTable/DataTableStateModel.swift | 3 +- 8 files changed, 112 insertions(+), 15 deletions(-) create mode 100644 FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json create mode 100644 FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json diff --git a/FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json b/FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json new file mode 100644 index 0000000000..2286e0275d --- /dev/null +++ b/FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "250", + "green" : "213", + "red" : "63" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "250", + "green" : "213", + "red" : "63" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json b/FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json new file mode 100644 index 0000000000..8a5ff421b4 --- /dev/null +++ b/FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "194", + "green" : "117", + "red" : "58" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "194", + "green" : "117", + "red" : "58" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift index 16fee07041..149ad08963 100644 --- a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift +++ b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift @@ -45,7 +45,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { rate: nil, temp: nil, carbInput: nil, - isSMB: dose.automatic + isSMB: dose.automatic, + isNonPumpInsulin: dose.manuallyEntered )] case .tempBasal: guard let dose = event.dose else { return [] } @@ -256,12 +257,12 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { rawRate: nil, absolute: nil, rate: nil, - eventType: (event.isSMB ?? false) ? .smb : .bolus, + eventType: (event.isSMB ?? false) ? .smb : (event.isNonPumpInsulin ?? false) ? .nonPumpInsulin : .bolus, createdAt: event.timestamp, enteredBy: NigtscoutTreatment.local, bolus: event, insulin: event.amount, - notes: nil, + notes: (event.isNonPumpInsulin ?? false) ? "Bolus with non-pump insulin" : nil, carbs: nil, fat: nil, protein: nil, diff --git a/FreeAPS/Sources/Helpers/Color+Extensions.swift b/FreeAPS/Sources/Helpers/Color+Extensions.swift index 1b66ad90d2..795b32beaf 100644 --- a/FreeAPS/Sources/Helpers/Color+Extensions.swift +++ b/FreeAPS/Sources/Helpers/Color+Extensions.swift @@ -10,6 +10,10 @@ extension Color { static let insulin = Color("Insulin") + static let smb = Color("SMB") + + static let nonPumpInsulin = Color("NonPumpInsulin") + // The loopAccent color is intended to be use as the app accent color. public static let loopAccent = Color("accent") diff --git a/FreeAPS/Sources/Models/PumpHistoryEvent.swift b/FreeAPS/Sources/Models/PumpHistoryEvent.swift index 11830cbd78..c45d7975bb 100644 --- a/FreeAPS/Sources/Models/PumpHistoryEvent.swift +++ b/FreeAPS/Sources/Models/PumpHistoryEvent.swift @@ -12,6 +12,7 @@ struct PumpHistoryEvent: JSON, Equatable { let carbInput: Int? let note: String? let isSMB: Bool? + let isNonPumpInsulin: Bool? init( id: String, @@ -24,7 +25,8 @@ struct PumpHistoryEvent: JSON, Equatable { temp: TempType? = nil, carbInput: Int? = nil, note: String? = nil, - isSMB: Bool? = nil + isSMB: Bool? = nil, + isNonPumpInsulin: Bool? = nil ) { self.id = id self.type = type @@ -37,13 +39,15 @@ struct PumpHistoryEvent: JSON, Equatable { self.carbInput = carbInput self.note = note self.isSMB = isSMB + self.isNonPumpInsulin = isNonPumpInsulin } } enum EventType: String, JSON { case bolus = "Bolus" case smb = "SMB" - case mealBulus = "Meal Bolus" + case nonPumpInsulin = "Bolus with non-pump insulin" + case mealBolus = "Meal Bolus" case correctionBolus = "Correction Bolus" case snackBolus = "Snack Bolus" case bolusWizard = "BolusWizard" @@ -85,5 +89,6 @@ extension PumpHistoryEvent { case carbInput = "carb_input" case note case isSMB + case isNonPumpInsulin } } diff --git a/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift b/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift index c24119b3d8..9e71e46d8e 100644 --- a/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift +++ b/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift @@ -83,7 +83,8 @@ extension Bolus { durationMin: nil, rate: nil, temp: nil, - carbInput: nil + carbInput: nil, + isNonPumpInsulin: true ) ] ) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift index c946e3ddc4..82832dfd26 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift @@ -67,6 +67,7 @@ enum DataTable { let fpuID: String? let note: String? let isSMB: Bool? + let isNonPump: Bool? private var numberFormatter: NumberFormatter { let formatter = NumberFormatter() @@ -94,7 +95,8 @@ enum DataTable { isFPU: Bool? = nil, fpuID: String? = nil, note: String? = nil, - isSMB: Bool? = nil + isSMB: Bool? = nil, + isNonPump: Bool? = nil ) { self.units = units self.type = type @@ -108,6 +110,7 @@ enum DataTable { self.fpuID = fpuID self.note = note self.isSMB = isSMB + self.isNonPump = isNonPump } static func == (lhs: Treatment, rhs: Treatment) -> Bool { @@ -135,12 +138,18 @@ enum DataTable { return numberFormatter .string(from: amount as NSNumber)! + NSLocalizedString(" g", comment: "gram of carb equilvalents") case .bolus: + var bolusText = " " + + if isSMB ?? false { + bolusText += NSLocalizedString("Automatic", comment: "Automatic delivered treatments") + } else if isNonPump ?? false { + bolusText += NSLocalizedString("Non-Pump", comment: "Bolus with non-pump insulin") + } else { + bolusText += NSLocalizedString("Manual", comment: "Manual Bolus") + } + return numberFormatter - .string(from: amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") + - ( - (isSMB ?? false) ? " " + NSLocalizedString("Automatic", comment: "Automatic delivered treatments") : " " + - NSLocalizedString("Manual", comment: "Manual Bolus") - ) + .string(from: amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") + bolusText case .tempBasal: return numberFormatter .string(from: amount as NSNumber)! + NSLocalizedString(" U/hr", comment: "Unit insulin per hour") @@ -172,9 +181,9 @@ enum DataTable { case .fpus: return .loopRed case .bolus: - return .insulin + return (isNonPump ?? false) ? Color.nonPumpInsulin : (isSMB ?? false) ? Color.smb : Color.insulin case .tempBasal: - return Color.insulin.opacity(0.5) + return Color.insulin.opacity(0.4) case .resume, .suspend, .tempTarget: diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index 82037886e0..cec7d9ece2 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -72,7 +72,8 @@ extension DataTable { date: $0.timestamp, amount: $0.amount, idPumpEvent: $0.id, - isSMB: $0.isSMB + isSMB: $0.isSMB, + isNonPump: $0.isNonPumpInsulin ) } From 1ebfca8778ea25e32c211485a3dd22b58a2ddfd7 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Thu, 28 Sep 2023 22:54:52 +0200 Subject: [PATCH 02/61] Changed NS eventType name + description; shortened nonPump descriptipn --- FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift | 2 +- FreeAPS/Sources/Models/PumpHistoryEvent.swift | 2 +- FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift index 149ad08963..05adf9fef6 100644 --- a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift +++ b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift @@ -262,7 +262,7 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { enteredBy: NigtscoutTreatment.local, bolus: event, insulin: event.amount, - notes: (event.isNonPumpInsulin ?? false) ? "Bolus with non-pump insulin" : nil, + notes: nil, carbs: nil, fat: nil, protein: nil, diff --git a/FreeAPS/Sources/Models/PumpHistoryEvent.swift b/FreeAPS/Sources/Models/PumpHistoryEvent.swift index c45d7975bb..df4fe3b799 100644 --- a/FreeAPS/Sources/Models/PumpHistoryEvent.swift +++ b/FreeAPS/Sources/Models/PumpHistoryEvent.swift @@ -46,7 +46,7 @@ struct PumpHistoryEvent: JSON, Equatable { enum EventType: String, JSON { case bolus = "Bolus" case smb = "SMB" - case nonPumpInsulin = "Bolus with non-pump insulin" + case nonPumpInsulin = "Non-pump insulin" case mealBolus = "Meal Bolus" case correctionBolus = "Correction Bolus" case snackBolus = "Snack Bolus" diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift index 82832dfd26..941fdd8d55 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift @@ -143,7 +143,7 @@ enum DataTable { if isSMB ?? false { bolusText += NSLocalizedString("Automatic", comment: "Automatic delivered treatments") } else if isNonPump ?? false { - bolusText += NSLocalizedString("Non-Pump", comment: "Bolus with non-pump insulin") + bolusText += NSLocalizedString("Non-Pump", comment: "Non-pump insulin") } else { bolusText += NSLocalizedString("Manual", comment: "Manual Bolus") } From d308026403072368ba34990651121d6924d96f97 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Thu, 28 Sep 2023 23:04:56 +0200 Subject: [PATCH 03/61] Capitalize 'insulin' for non-pump string; add localization to EN and GER --- .../Sources/Localizations/Main/de.lproj/Localizable.strings | 6 ++++++ .../Sources/Localizations/Main/en.lproj/Localizable.strings | 3 +++ FreeAPS/Sources/Models/PumpHistoryEvent.swift | 2 +- FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings index 3784b56360..7c294ed667 100644 --- a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings @@ -1114,6 +1114,12 @@ Enact a temp Basal or a temp target */ /* Manual temp basal mode */ "Manual" = "manuell"; +/* An Automatic delivered bolus (SMB) */ +"SMB" = "SMB"; + +/* A manually entered dose of non-pump insulin */ +"Non-pump Insulin" = "Externes Insulin"; + /* Status highlight when manual temp basal is running. */ "Manual Basal" = "Manuelle Temporäre Basalrate"; diff --git a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings index 83e5ba109d..216b2258ee 100644 --- a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings @@ -1121,6 +1121,9 @@ Enact a temp Basal or a temp target */ /* An Automatic delivered bolus (SMB) */ "SMB" = "SMB"; +/* A manually entered dose of non-pump insulin */ +"Non-pump Insulin" = "Non-pump Insulin"; + /* Status highlight when manual temp basal is running. */ "Manual Basal" = "Manual Basal"; diff --git a/FreeAPS/Sources/Models/PumpHistoryEvent.swift b/FreeAPS/Sources/Models/PumpHistoryEvent.swift index df4fe3b799..dff30f5511 100644 --- a/FreeAPS/Sources/Models/PumpHistoryEvent.swift +++ b/FreeAPS/Sources/Models/PumpHistoryEvent.swift @@ -46,7 +46,7 @@ struct PumpHistoryEvent: JSON, Equatable { enum EventType: String, JSON { case bolus = "Bolus" case smb = "SMB" - case nonPumpInsulin = "Non-pump insulin" + case nonPumpInsulin = "Non-pump Insulin" case mealBolus = "Meal Bolus" case correctionBolus = "Correction Bolus" case snackBolus = "Snack Bolus" diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift index 941fdd8d55..f738ebc3e6 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift @@ -143,7 +143,7 @@ enum DataTable { if isSMB ?? false { bolusText += NSLocalizedString("Automatic", comment: "Automatic delivered treatments") } else if isNonPump ?? false { - bolusText += NSLocalizedString("Non-Pump", comment: "Non-pump insulin") + bolusText += NSLocalizedString("Non-Pump", comment: "Non-pump Insulin") } else { bolusText += NSLocalizedString("Manual", comment: "Manual Bolus") } From d810422a4d5f9c8e51ac588f9806974888244409 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Thu, 28 Sep 2023 23:08:49 +0200 Subject: [PATCH 04/61] Add localization 'Non-Pump' --- .../Sources/Localizations/Main/en.lproj/Localizable.strings | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings index 216b2258ee..5c5d2fcefa 100644 --- a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings @@ -527,6 +527,9 @@ Enact a temp Basal or a temp target */ /* Automatic delivered treatments */ "Automatic" = "Automatic"; +/* Non-pump insulin treatments */ +"Non-Pump" = "Non-Pump"; + /* */ "Other" = "Other"; From d069beb5b12f6ec259b8ca6d074e162506b875db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bj=C3=B6rkert?= Date: Fri, 29 Sep 2023 16:08:55 +0200 Subject: [PATCH 05/61] determineBolusEventType (#1) --- .../Sources/APS/Storage/PumpHistoryStorage.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift index 05adf9fef6..b3b034f0de 100644 --- a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift +++ b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift @@ -211,6 +211,16 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { } } + func determineBolusEventType(for event: PumpHistoryEvent) -> EventType { + if event.isSMB ?? false { + return .smb + } + if event.isNonPumpInsulin ?? false { + return .nonPumpInsulin + } + return event.type + } + func nightscoutTretmentsNotUploaded() -> [NigtscoutTreatment] { let events = recent() guard !events.isEmpty else { return [] } @@ -251,13 +261,14 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { let bolusesAndCarbs = events.compactMap { event -> NigtscoutTreatment? in switch event.type { case .bolus: + let eventType = determineBolusEventType(for: event) return NigtscoutTreatment( duration: event.duration, rawDuration: nil, rawRate: nil, absolute: nil, rate: nil, - eventType: (event.isSMB ?? false) ? .smb : (event.isNonPumpInsulin ?? false) ? .nonPumpInsulin : .bolus, + eventType: eventType, createdAt: event.timestamp, enteredBy: NigtscoutTreatment.local, bolus: event, From 0563c99edde8971a6117a012f7f040e679363831 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Fri, 29 Sep 2023 23:39:16 +0200 Subject: [PATCH 06/61] Rework history to sleeker UI w/ 3 tabs, swipe-to-delete, no dots --- .../Modules/DataTable/DataTableDataFlow.swift | 6 +- .../DataTable/DataTableStateModel.swift | 29 ++- .../DataTable/View/DataTableRootView.swift | 233 +++++++++++------- 3 files changed, 164 insertions(+), 104 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift index f738ebc3e6..1157dcba35 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift @@ -6,6 +6,7 @@ enum DataTable { enum Mode: String, Hashable, Identifiable, CaseIterable { case treatments + case meals case glucose var id: String { rawValue } @@ -15,6 +16,8 @@ enum DataTable { switch self { case .treatments: name = "Treatments" + case .meals: + name = "Meals" case .glucose: name = "Glucose" } @@ -181,7 +184,8 @@ enum DataTable { case .fpus: return .loopRed case .bolus: - return (isNonPump ?? false) ? Color.nonPumpInsulin : (isSMB ?? false) ? Color.smb : Color.insulin + // return (isNonPump ?? false) ? Color.nonPumpInsulin : (isSMB ?? false) ? Color.smb : Color.insulin + return .insulin case .tempBasal: return Color.insulin.opacity(0.4) case .resume, diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index cec7d9ece2..29661d3066 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -11,6 +11,7 @@ extension DataTable { @Published var mode: Mode = .treatments @Published var treatments: [Treatment] = [] + @Published var meals: [Treatment] = [] @Published var glucose: [Glucose] = [] @Published var manualGlcuose: Decimal = 0 @@ -119,7 +120,10 @@ extension DataTable { } DispatchQueue.main.async { - self.treatments = [carbs, boluses, tempBasals, tempTargets, suspend, resume, fpus] + self.treatments = [boluses, tempBasals, tempTargets, suspend, resume] + .flatMap { $0 } + .sorted { $0.date > $1.date } + self.meals = [carbs, fpus] .flatMap { $0 } .sorted { $0.date > $1.date } } @@ -132,17 +136,22 @@ extension DataTable { } } - func deleteCarbs(_ treatment: Treatment) { - provider.deleteCarbs(treatment) + func deleteCarbs(at index: Int) { + let carbEntry = meals[index] + provider.deleteCarbs(carbEntry) } - func deleteInsulin(_ treatment: Treatment) { - unlockmanager.unlock() - .sink { _ in } receiveValue: { [weak self] _ in - guard let self = self else { return } - self.provider.deleteInsulin(treatment) - } - .store(in: &lifetime) + func deleteInsulin(at index: Int) { + let treatment = treatments[index] + provider.deleteInsulin(treatment) + /* + unlockmanager.unlock() + .sink { _ in } receiveValue: { [weak self] _ in + guard let self = self else { return } + self.provider.deleteInsulin(treatment) + } + .store(in: &lifetime) + */ } func deleteGlucose(at index: Int) { diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 7754932c6c..e27e0b3279 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -46,6 +46,7 @@ extension DataTable { Form { switch state.mode { case .treatments: treatmentsList + case .meals: mealsList case .glucose: glucoseList } } @@ -55,10 +56,20 @@ extension DataTable { .navigationBarTitleDisplayMode(.automatic) .navigationBarItems( leading: Button("Close", action: state.hideModal), - trailing: state.mode == .glucose ? EditButton().asAny() : EmptyView().asAny() + trailing: HStack { + if state.mode == .glucose && !newGlucose { + Button(action: { newGlucose = true }) { + Text("Add") + Image(systemName: "plus.circle.fill") + .resizable() + .frame(width: 24, height: 24) + Spacer() + } + } + } ) .popup(isPresented: newGlucose, alignment: .top, direction: .bottom) { - VStack(spacing: 20) { + VStack { HStack { Text("New Glucose") DecimalTextField(" ... ", value: $state.manualGlcuose, formatter: glucoseFormatter) @@ -93,122 +104,158 @@ extension DataTable { ForEach(state.treatments) { item in treatmentView(item) } + .onDelete(perform: deleteTreatment) } } - private var glucoseList: some View { + private var mealsList: some View { List { - Button { newGlucose = true } - label: { Text("Add") }.frame(maxWidth: .infinity, alignment: .trailing) - .padding(.trailing, 20) + ForEach(state.meals) { item in + mealView(item) + } + .onDelete(perform: deleteMeal) + } + } + private var glucoseList: some View { + List { ForEach(state.glucose) { item in glucoseView(item) - }.onDelete(perform: deleteGlucose) + } + .onDelete(perform: deleteGlucose) } } - @ViewBuilder private func treatmentView(_ item: Treatment) -> some View { + @ViewBuilder private func treatmentView(_ bolus: Treatment) -> some View { HStack { - Image(systemName: "circle.fill").foregroundColor(item.color) - Text(dateFormatter.string(from: item.date)) - .moveDisabled(true) - Text((item.isSMB ?? false) ? "SMB" : item.type.name) - Text(item.amountText).foregroundColor(.secondary) + Text((bolus.isSMB ?? false) ? "SMB" : bolus.type.name) + Text(bolus.amountText).foregroundColor(.secondary) - if let duration = item.durationText { + if let duration = bolus.durationText { Text(duration).foregroundColor(.secondary) } - if item.type == .carbs { - if item.note != "" { - Spacer() - Text(item.note ?? "").foregroundColor(.brown) - } - Spacer() - Image(systemName: "xmark.circle").foregroundColor(.secondary) - .contentShape(Rectangle()) - .padding(.vertical) - .onTapGesture { - removeCarbsAlert = Alert( - title: Text("Delete carbs?"), - message: Text(item.amountText), - primaryButton: .destructive( - Text("Delete"), - action: { state.deleteCarbs(item) } - ), - secondaryButton: .cancel() - ) - isRemoveCarbsAlertPresented = true - } - .alert(isPresented: $isRemoveCarbsAlertPresented) { - removeCarbsAlert! - } - } + Spacer() - if item.type == .fpus { - Spacer() - Image(systemName: "xmark.circle").foregroundColor(.secondary) - .contentShape(Rectangle()) - .padding(.vertical) - .onTapGesture { - removeCarbsAlert = Alert( - title: Text("Delete carb equivalents?"), - message: Text(""), // Temporary fix. New to fix real amount of carb equivalents later - primaryButton: .destructive( - Text("Delete"), - action: { state.deleteCarbs(item) } - ), - secondaryButton: .cancel() - ) - isRemoveCarbsAlertPresented = true - } - .alert(isPresented: $isRemoveCarbsAlertPresented) { - removeCarbsAlert! - } - } + Text(dateFormatter.string(from: bolus.date)) + .moveDisabled(true) - if item.type == .bolus { - Spacer() - Image(systemName: "xmark.circle").foregroundColor(.secondary) - .contentShape(Rectangle()) - .padding(.vertical) - .onTapGesture { - removeInsulinAlert = Alert( - title: Text("Delete insulin?"), - message: Text(item.amountText), - primaryButton: .destructive( - Text("Delete"), - action: { state.deleteInsulin(item) } - ), - secondaryButton: .cancel() - ) - isRemoveInsulinAlertPresented = true - } - .alert(isPresented: $isRemoveInsulinAlertPresented) { - removeInsulinAlert! - } + /* + if item.type == .bolus { + Spacer() + Image(systemName: "xmark.circle").foregroundColor(.secondary) + .contentShape(Rectangle()) + .padding(.vertical) + .onTapGesture { + removeInsulinAlert = Alert( + title: Text("Delete insulin?"), + message: Text(item.amountText), + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteInsulin(item) } + ), + secondaryButton: .cancel() + ) + isRemoveInsulinAlertPresented = true + } + .alert(isPresented: $isRemoveInsulinAlertPresented) { + removeInsulinAlert! + } + } + */ + } + } + + @ViewBuilder private func mealView(_ meal: Treatment) -> some View { + HStack { + Text(meal.type.name) + Text(meal.amountText).foregroundColor(.secondary) + + if let duration = meal.durationText { + Text(duration).foregroundColor(.secondary) } + + Spacer() + + Text(dateFormatter.string(from: meal.date)) + .moveDisabled(true) + + /* + if item.type == .carbs { + if item.note != "" { + Spacer() + Text(item.note ?? "").foregroundColor(.brown) + } + Spacer() + Image(systemName: "xmark.circle").foregroundColor(.secondary) + .contentShape(Rectangle()) + .padding(.vertical) + .onTapGesture { + removeCarbsAlert = Alert( + title: Text("Delete carbs?"), + message: Text(item.amountText), + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteCarbs(item) } + ), + secondaryButton: .cancel() + ) + isRemoveCarbsAlertPresented = true + } + .alert(isPresented: $isRemoveCarbsAlertPresented) { + removeCarbsAlert! + } + } + + if item.type == .fpus { + Spacer() + Image(systemName: "xmark.circle").foregroundColor(.secondary) + .contentShape(Rectangle()) + .padding(.vertical) + .onTapGesture { + removeCarbsAlert = Alert( + title: Text("Delete carb equivalents?"), + message: Text(""), // Temporary fix. New to fix real amount of carb equivalents later + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteCarbs(item) } + ), + secondaryButton: .cancel() + ) + isRemoveCarbsAlertPresented = true + } + .alert(isPresented: $isRemoveCarbsAlertPresented) { + removeCarbsAlert! + } + } + */ } } @ViewBuilder private func glucoseView(_ item: Glucose) -> some View { - VStack(alignment: .leading, spacing: 4) { - HStack { - Text(dateFormatter.string(from: item.glucose.dateString)) - Spacer() - Text(item.glucose.glucose.map { - glucoseFormatter.string(from: Double( - state.units == .mmolL ? $0.asMmolL : Decimal($0) - ) as NSNumber)! - } ?? "--") - Text(state.units.rawValue) - Text(item.glucose.direction?.symbol ?? "--") - } - Text("ID: " + item.glucose.id).font(.caption2).foregroundColor(.secondary) + HStack { + Text(item.glucose.glucose.map { + glucoseFormatter.string(from: Double( + state.units == .mmolL ? $0.asMmolL : Decimal($0) + ) as NSNumber)! + } ?? "--") + Text(state.units.rawValue) + Text(item.glucose.direction?.symbol ?? "--") + + Spacer() + + Text(dateFormatter.string(from: item.glucose.dateString)) } } + private func deleteTreatment(at offsets: IndexSet) { + state.deleteInsulin(at: offsets[offsets.startIndex]) + } + + private func deleteMeal(at offsets: IndexSet) { + state.deleteCarbs(at: offsets[offsets.startIndex]) + } + private func deleteGlucose(at offsets: IndexSet) { state.deleteGlucose(at: offsets[offsets.startIndex]) } From 6d29558b1d844c664e9bd8ee8a1f3060afcb8b01 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Fri, 29 Sep 2023 23:39:42 +0200 Subject: [PATCH 07/61] Fix typos --- .../Modules/AddCarbs/View/AddCarbsRootView.swift | 12 +++++++----- .../AddTempTarget/View/AddTempTargetRootView.swift | 12 ++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift index 976d1ef115..8d9081dbcf 100644 --- a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift +++ b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift @@ -7,7 +7,7 @@ extension AddCarbs { let resolver: Resolver @StateObject var state = StateModel() @State var dish: String = "" - @State var isPromtPresented = false + @State var isPromptPresented = false @State var saved = false @State private var showAlert = false @FocusState private var isFocused: Bool @@ -75,7 +75,7 @@ extension AddCarbs { .controlSize(.mini) .buttonStyle(BorderlessButtonStyle()) Button { - isPromtPresented = true + isPromptPresented = true } label: { Text("Save as Preset") } .frame(maxWidth: .infinity, alignment: .trailing) @@ -101,7 +101,7 @@ extension AddCarbs { ) ) } - .popover(isPresented: $isPromtPresented) { + .popover(isPresented: $isPromptPresented) { presetPopover } } @@ -130,6 +130,8 @@ extension AddCarbs { } } .onAppear(perform: configureView) + .navigationTitle(state.useFPUconversion ? "Add Carbs, Fat & Protein" : "Add Carbohydrates") + .navigationBarTitleDisplayMode(.automatic) .navigationBarItems(leading: Button("Close", action: state.hideModal)) } @@ -148,14 +150,14 @@ extension AddCarbs { try? moc.save() state.addNewPresetToWaitersNotepad(dish) saved = false - isPromtPresented = false + isPromptPresented = false } } label: { Text("Save") } Button { dish = "" saved = false - isPromtPresented = false } + isPromptPresented = false } label: { Text("Cancel") } } header: { Text("Enter Meal Preset Name") } } diff --git a/FreeAPS/Sources/Modules/AddTempTarget/View/AddTempTargetRootView.swift b/FreeAPS/Sources/Modules/AddTempTarget/View/AddTempTargetRootView.swift index 41f759a189..224a059232 100644 --- a/FreeAPS/Sources/Modules/AddTempTarget/View/AddTempTargetRootView.swift +++ b/FreeAPS/Sources/Modules/AddTempTarget/View/AddTempTargetRootView.swift @@ -6,7 +6,7 @@ extension AddTempTarget { struct RootView: BaseView { let resolver: Resolver @StateObject var state = StateModel() - @State private var isPromtPresented = false + @State private var isPromptPresented = false @State private var isRemoveAlertPresented = false @State private var removeAlert: Alert? @State private var isEditing = false @@ -99,7 +99,7 @@ extension AddTempTarget { Text("minutes").foregroundColor(.secondary) } DatePicker("Date", selection: $state.date) - Button { isPromtPresented = true } + Button { isPromptPresented = true } label: { Text("Save as preset") } } } @@ -112,7 +112,7 @@ extension AddTempTarget { Text("minutes").foregroundColor(.secondary) } DatePicker("Date", selection: $state.date) - Button { isPromtPresented = true } + Button { isPromptPresented = true } label: { Text("Save as preset") } .disabled(state.duration == 0) } @@ -125,16 +125,16 @@ extension AddTempTarget { label: { Text("Cancel Temp Target") } } } - .popover(isPresented: $isPromtPresented) { + .popover(isPresented: $isPromptPresented) { Form { Section(header: Text("Enter preset name")) { TextField("Name", text: $state.newPresetName) Button { state.save() - isPromtPresented = false + isPromptPresented = false } label: { Text("Save") } - Button { isPromtPresented = false } + Button { isPromptPresented = false } label: { Text("Cancel") } } } From 0016a86567c511cfc85d72a9539c0ac462c74270 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Fri, 29 Sep 2023 23:40:09 +0200 Subject: [PATCH 08/61] Try at home view with sleeker icons based on SF Symbols --- .../Modules/Home/View/HomeRootView.swift | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift index 3dbaf244d1..b2bc04475f 100644 --- a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift +++ b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift @@ -412,7 +412,7 @@ extension Home { let colour: Color = colorScheme == .dark ? .black : .white // Rectangle().fill(colour).frame(maxHeight: 1) ZStack { - Rectangle().fill(Color.gray.opacity(0.2)).frame(maxHeight: 40) + Rectangle().fill(Color.gray.opacity(0.3)).frame(maxHeight: 40) let cancel = fetchedPercent.first?.enabled ?? false HStack(spacing: cancel ? 25 : 15) { Text(selectedProfile().name).foregroundColor(.secondary) @@ -475,17 +475,17 @@ extension Home { @ViewBuilder private func bottomPanel(_ geo: GeometryProxy) -> some View { ZStack { - Rectangle().fill(Color.gray.opacity(0.2)).frame(height: 50 + geo.safeAreaInsets.bottom) + Rectangle().fill(Color.gray.opacity(0.3)).frame(height: 54 + geo.safeAreaInsets.bottom) HStack { Button { state.showModal(for: .addCarbs) } label: { ZStack(alignment: Alignment(horizontal: .trailing, vertical: .bottom)) { - Image("carbs") + Image(systemName: "fork.knife.circle") .renderingMode(.template) .resizable() - .frame(width: 24, height: 24) - .foregroundColor(.loopYellow) + .frame(width: 30, height: 30) + .foregroundColor(.uam) .padding(8) if let carbsReq = state.carbsRequired { Text(numberFormatter.string(from: carbsReq as NSNumber)!) @@ -495,14 +495,14 @@ extension Home { .background(Capsule().fill(Color.red)) } } - }.buttonStyle(.borderless) + }.buttonStyle(.plain) Spacer() Button { state.showModal(for: .addTempTarget) } label: { - Image("target") + Image(systemName: "target") .renderingMode(.template) .resizable() - .frame(width: 24, height: 24) + .frame(width: 30, height: 30) .padding(8) } .foregroundColor(.loopGreen) @@ -510,10 +510,10 @@ extension Home { Spacer() Button { state.showModal(for: .bolus(waitForSuggestion: false)) } label: { - Image("bolus") + Image(systemName: "drop.circle") .renderingMode(.template) .resizable() - .frame(width: 24, height: 24) + .frame(width: 30, height: 30) .padding(8) } .foregroundColor(.insulin) @@ -522,10 +522,10 @@ extension Home { if state.allowManualTemp { Button { state.showModal(for: .manualTempBasal) } label: { - Image("bolus1") + Image(systemName: "plus.circle") .renderingMode(.template) .resizable() - .frame(width: 24, height: 24) + .frame(width: 30, height: 30) .padding(8) } .foregroundColor(.insulin) @@ -535,10 +535,10 @@ extension Home { Button { state.showModal(for: .statistics) } label: { - Image(systemName: "chart.xyaxis.line") + Image(systemName: "chart.line.uptrend.xyaxis.circle") .renderingMode(.template) .resizable() - .frame(width: 24, height: 24) + .frame(width: 30, height: 30) .padding(8) } .foregroundColor(.purple) @@ -546,13 +546,13 @@ extension Home { Spacer() Button { state.showModal(for: .settings) } label: { - Image("settings1") + Image(systemName: "gearshape.circle") .renderingMode(.template) .resizable() - .frame(width: 24, height: 24) + .frame(width: 30, height: 30) .padding(8) } - .foregroundColor(.loopGray) + .foregroundColor(.gray) .buttonStyle(.borderless) } .padding(.horizontal, 24) From 91443a1fc9763854f9b2e84863fe76770dbf1624 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sat, 30 Sep 2023 02:07:05 +0200 Subject: [PATCH 09/61] Added deletion functionality deletion alerts; long press to combine treatments WIP --- .../DataTable/DataTableStateModel.swift | 23 +-- .../DataTable/View/DataTableRootView.swift | 158 ++++++++---------- 2 files changed, 81 insertions(+), 100 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index 29661d3066..808d3e8be2 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -136,22 +136,17 @@ extension DataTable { } } - func deleteCarbs(at index: Int) { - let carbEntry = meals[index] - provider.deleteCarbs(carbEntry) + func deleteCarbs(_ treatment: Treatment) { + provider.deleteCarbs(treatment) } - func deleteInsulin(at index: Int) { - let treatment = treatments[index] - provider.deleteInsulin(treatment) - /* - unlockmanager.unlock() - .sink { _ in } receiveValue: { [weak self] _ in - guard let self = self else { return } - self.provider.deleteInsulin(treatment) - } - .store(in: &lifetime) - */ + func deleteInsulin(_ treatment: Treatment) { + unlockmanager.unlock() + .sink { _ in } receiveValue: { [weak self] _ in + guard let self = self else { return } + self.provider.deleteInsulin(treatment) + } + .store(in: &lifetime) } func deleteGlucose(at index: Int) { diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index e27e0b3279..b21d67cc32 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -12,6 +12,8 @@ extension DataTable { @State private var isRemoveInsulinAlertPresented = false @State private var removeInsulinAlert: Alert? @State private var newGlucose = false + @State private var testAlert: Alert? + @State private var isTestPresented = false @Environment(\.colorScheme) var colorScheme @@ -37,19 +39,16 @@ extension DataTable { VStack { Picker("Mode", selection: $state.mode) { ForEach(Mode.allCases.indexed(), id: \.1) { index, item in - Text(item.name).tag(index) + Text(item.name) + .tag(index) } } .pickerStyle(SegmentedPickerStyle()) .padding(.horizontal) - - Form { - switch state.mode { - case .treatments: treatmentsList - case .meals: mealsList - case .glucose: glucoseList - } + .alert(isPresented: $isTestPresented) { + testAlert! } + historyContent } .onAppear(perform: configureView) .navigationTitle("History") @@ -63,13 +62,13 @@ extension DataTable { Image(systemName: "plus.circle.fill") .resizable() .frame(width: 24, height: 24) - Spacer() } + Spacer() } } ) .popup(isPresented: newGlucose, alignment: .top, direction: .bottom) { - VStack { + Form { HStack { Text("New Glucose") DecimalTextField(" ... ", value: $state.manualGlcuose, formatter: glucoseFormatter) @@ -99,13 +98,29 @@ extension DataTable { } } + private var historyContent: some View { + Form { + switch state.mode { + case .treatments: treatmentsList + case .meals: mealsList + case .glucose: glucoseList + } + } + .onLongPressGesture(minimumDuration: 1.33, perform: combineTreatments) + // force press on the list to trigger function ^ + } + private var treatmentsList: some View { List { ForEach(state.treatments) { item in treatmentView(item) } + .onDelete(perform: deleteTreatment) } + .alert(isPresented: $isRemoveInsulinAlertPresented) { + removeInsulinAlert! + } } private var mealsList: some View { @@ -115,6 +130,9 @@ extension DataTable { } .onDelete(perform: deleteMeal) } + .alert(isPresented: $isRemoveCarbsAlertPresented) { + removeCarbsAlert! + } } private var glucoseList: some View { @@ -139,30 +157,6 @@ extension DataTable { Text(dateFormatter.string(from: bolus.date)) .moveDisabled(true) - - /* - if item.type == .bolus { - Spacer() - Image(systemName: "xmark.circle").foregroundColor(.secondary) - .contentShape(Rectangle()) - .padding(.vertical) - .onTapGesture { - removeInsulinAlert = Alert( - title: Text("Delete insulin?"), - message: Text(item.amountText), - primaryButton: .destructive( - Text("Delete"), - action: { state.deleteInsulin(item) } - ), - secondaryButton: .cancel() - ) - isRemoveInsulinAlertPresented = true - } - .alert(isPresented: $isRemoveInsulinAlertPresented) { - removeInsulinAlert! - } - } - */ } } @@ -179,56 +173,6 @@ extension DataTable { Text(dateFormatter.string(from: meal.date)) .moveDisabled(true) - - /* - if item.type == .carbs { - if item.note != "" { - Spacer() - Text(item.note ?? "").foregroundColor(.brown) - } - Spacer() - Image(systemName: "xmark.circle").foregroundColor(.secondary) - .contentShape(Rectangle()) - .padding(.vertical) - .onTapGesture { - removeCarbsAlert = Alert( - title: Text("Delete carbs?"), - message: Text(item.amountText), - primaryButton: .destructive( - Text("Delete"), - action: { state.deleteCarbs(item) } - ), - secondaryButton: .cancel() - ) - isRemoveCarbsAlertPresented = true - } - .alert(isPresented: $isRemoveCarbsAlertPresented) { - removeCarbsAlert! - } - } - - if item.type == .fpus { - Spacer() - Image(systemName: "xmark.circle").foregroundColor(.secondary) - .contentShape(Rectangle()) - .padding(.vertical) - .onTapGesture { - removeCarbsAlert = Alert( - title: Text("Delete carb equivalents?"), - message: Text(""), // Temporary fix. New to fix real amount of carb equivalents later - primaryButton: .destructive( - Text("Delete"), - action: { state.deleteCarbs(item) } - ), - secondaryButton: .cancel() - ) - isRemoveCarbsAlertPresented = true - } - .alert(isPresented: $isRemoveCarbsAlertPresented) { - removeCarbsAlert! - } - } - */ } } @@ -249,15 +193,57 @@ extension DataTable { } private func deleteTreatment(at offsets: IndexSet) { - state.deleteInsulin(at: offsets[offsets.startIndex]) + let treatment = state.treatments[offsets[offsets.startIndex]] + + removeInsulinAlert = Alert( + title: Text("Delete insulin?"), + message: Text(treatment.amountText), + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteInsulin(treatment) } + ), + secondaryButton: .cancel() + ) + + isRemoveInsulinAlertPresented = true } private func deleteMeal(at offsets: IndexSet) { - state.deleteCarbs(at: offsets[offsets.startIndex]) + let meal = state.meals[offsets[offsets.startIndex]] + var alertTitle = Text("Delete carbs?") + var alertMessage = Text(meal.amountText) + + if meal.type == .fpus { + alertTitle = Text("Delete carb equivalents?") + alertMessage = Text("") + } + + removeCarbsAlert = Alert( + title: alertTitle, + message: alertMessage, + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteCarbs(meal) } + ), + secondaryButton: .cancel() + ) + + isRemoveCarbsAlertPresented = true } private func deleteGlucose(at offsets: IndexSet) { state.deleteGlucose(at: offsets[offsets.startIndex]) } + + private func combineTreatments() { + print("FORCE PRESS ON LIST TRIGGERS THIS") + + testAlert = Alert( + title: Text("Test123") + ) + isTestPresented = true + + // TODO: re-render view and combine treatments and meals into one list. + } } } From 8a22d6dc9046acde3f058ed752bc3ab32e30b974 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sun, 1 Oct 2023 18:45:11 +0200 Subject: [PATCH 10/61] Remove longpress stuff from previous fiddling around --- .../Modules/DataTable/View/DataTableRootView.swift | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index b21d67cc32..04cb32509a 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -106,8 +106,6 @@ extension DataTable { case .glucose: glucoseList } } - .onLongPressGesture(minimumDuration: 1.33, perform: combineTreatments) - // force press on the list to trigger function ^ } private var treatmentsList: some View { @@ -234,16 +232,5 @@ extension DataTable { private func deleteGlucose(at offsets: IndexSet) { state.deleteGlucose(at: offsets[offsets.startIndex]) } - - private func combineTreatments() { - print("FORCE PRESS ON LIST TRIGGERS THIS") - - testAlert = Alert( - title: Text("Test123") - ) - isTestPresented = true - - // TODO: re-render view and combine treatments and meals into one list. - } } } From 1cd22ee562d16952e73306c1da3713c01535abb5 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sun, 1 Oct 2023 18:45:34 +0200 Subject: [PATCH 11/61] Fix typo --- FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift | 4 ++-- .../Sources/Modules/DataTable/View/DataTableRootView.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index 808d3e8be2..ec24b90468 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -13,7 +13,7 @@ extension DataTable { @Published var treatments: [Treatment] = [] @Published var meals: [Treatment] = [] @Published var glucose: [Glucose] = [] - @Published var manualGlcuose: Decimal = 0 + @Published var manualGlucose: Decimal = 0 var units: GlucoseUnits = .mmolL @@ -175,7 +175,7 @@ extension DataTable { } func addManualGlucose() { - let glucose = units == .mmolL ? manualGlcuose.asMgdL : manualGlcuose + let glucose = units == .mmolL ? manualGlucose.asMgdL : manualGlucose let now = Date() let id = UUID().uuidString diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 04cb32509a..2ae890c919 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -71,7 +71,7 @@ extension DataTable { Form { HStack { Text("New Glucose") - DecimalTextField(" ... ", value: $state.manualGlcuose, formatter: glucoseFormatter) + DecimalTextField(" ... ", value: $state.manualGlucose, formatter: glucoseFormatter) Text(state.units.rawValue) }.padding(.horizontal, 20) HStack { @@ -86,7 +86,7 @@ extension DataTable { } label: { Text("Save") } .frame(maxWidth: .infinity, alignment: .trailing) - .disabled(state.manualGlcuose < limitLow || state.manualGlcuose > limitHigh) + .disabled(state.manualGlucose < limitLow || state.manualGlucose > limitHigh) }.padding(20) } From 4ba465d368c80ef0b42f50c3da2e2104caabc3f8 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sun, 1 Oct 2023 21:59:59 +0200 Subject: [PATCH 12/61] Rework manual glucose dialog --- .../DataTable/DataTableStateModel.swift | 12 +-- .../DataTable/View/DataTableRootView.swift | 93 ++++++++++++------- 2 files changed, 67 insertions(+), 38 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index ec24b90468..e872a040ec 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -14,6 +14,7 @@ extension DataTable { @Published var meals: [Treatment] = [] @Published var glucose: [Glucose] = [] @Published var manualGlucose: Decimal = 0 + @Published var manualGlucoseDate = Date() var units: GlucoseUnits = .mmolL @@ -149,8 +150,8 @@ extension DataTable { .store(in: &lifetime) } - func deleteGlucose(at index: Int) { - let id = glucose[index].id + func deleteGlucose(_ glucose: Glucose) { + let id = glucose.id provider.deleteGlucose(id: id) let fetchRequest: NSFetchRequest @@ -174,16 +175,15 @@ extension DataTable { // try? coredataContext.save() } - func addManualGlucose() { + func addManualGlucose(manualGlucoseDate: Date) { let glucose = units == .mmolL ? manualGlucose.asMgdL : manualGlucose - let now = Date() let id = UUID().uuidString let saveToJSON = BloodGlucose( _id: id, direction: nil, - date: Decimal(now.timeIntervalSince1970) * 1000, - dateString: now, + date: Decimal(manualGlucoseDate.timeIntervalSince1970) * 1000, + dateString: manualGlucoseDate, unfiltered: nil, filtered: nil, noise: nil, diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 2ae890c919..090ca1d796 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -12,8 +12,8 @@ extension DataTable { @State private var isRemoveInsulinAlertPresented = false @State private var removeInsulinAlert: Alert? @State private var newGlucose = false - @State private var testAlert: Alert? - @State private var isTestPresented = false + @State private var isRemoveGlucoseAlertPresented = false + @State private var removeGlucoseAlert: Alert? @Environment(\.colorScheme) var colorScheme @@ -45,9 +45,7 @@ extension DataTable { } .pickerStyle(SegmentedPickerStyle()) .padding(.horizontal) - .alert(isPresented: $isTestPresented) { - testAlert! - } + historyContent } .onAppear(perform: configureView) @@ -67,34 +65,47 @@ extension DataTable { } } ) - .popup(isPresented: newGlucose, alignment: .top, direction: .bottom) { - Form { - HStack { - Text("New Glucose") - DecimalTextField(" ... ", value: $state.manualGlucose, formatter: glucoseFormatter) - Text(state.units.rawValue) - }.padding(.horizontal, 20) - HStack { - let limitLow: Decimal = state.units == .mmolL ? 2.2 : 40 - let limitHigh: Decimal = state.units == .mmolL ? 21 : 380 - Button { newGlucose = false } - label: { Text("Cancel") }.frame(maxWidth: .infinity, alignment: .leading) - - Button { - state.addManualGlucose() - newGlucose = false + .sheet(isPresented: $newGlucose) { + manualGlucoseView + } + } + + var manualGlucoseView: some View { + NavigationView { + VStack { + Form { + Section { + HStack { + Text("New Glucose") + DecimalTextField(" ... ", value: $state.manualGlucose, formatter: glucoseFormatter) + Text(state.units.rawValue) + } + } + + Section { + DatePicker("Date", selection: $state.manualGlucoseDate) } - label: { Text("Save") } - .frame(maxWidth: .infinity, alignment: .trailing) - .disabled(state.manualGlucose < limitLow || state.manualGlucose > limitHigh) - }.padding(20) + Section { + HStack { + let limitLow: Decimal = state.units == .mmolL ? 2.2 : 40 + let limitHigh: Decimal = state.units == .mmolL ? 21 : 380 + + Button { + state.addManualGlucose(manualGlucoseDate: state.manualGlucoseDate) + newGlucose = false + } + label: { Text("Save").font(.title3) } + .frame(maxWidth: .infinity, alignment: .center) + .disabled(state.manualGlucose < limitLow || state.manualGlucose > limitHigh) + } + } + } } - .frame(maxHeight: 140) - .background( - RoundedRectangle(cornerRadius: 8, style: .continuous) - .fill(Color(colorScheme == .dark ? UIColor.systemGray2 : UIColor.systemGray6)) - ) + .onAppear(perform: configureView) + .navigationTitle("Add Glucose") + .navigationBarTitleDisplayMode(.automatic) + .navigationBarItems(leading: Button("Close", action: { newGlucose = false })) } } @@ -140,6 +151,9 @@ extension DataTable { } .onDelete(perform: deleteGlucose) } + .alert(isPresented: $isRemoveGlucoseAlertPresented) { + removeGlucoseAlert! + } } @ViewBuilder private func treatmentView(_ bolus: Treatment) -> some View { @@ -194,7 +208,7 @@ extension DataTable { let treatment = state.treatments[offsets[offsets.startIndex]] removeInsulinAlert = Alert( - title: Text("Delete insulin?"), + title: Text("Delete Insulin?"), message: Text(treatment.amountText), primaryButton: .destructive( Text("Delete"), @@ -230,7 +244,22 @@ extension DataTable { } private func deleteGlucose(at offsets: IndexSet) { - state.deleteGlucose(at: offsets[offsets.startIndex]) + let glucose = state.glucose[offsets[offsets.startIndex]] + let glucoseValue = glucoseFormatter.string(from: Double( + state.units == .mmolL ? glucose.glucose.value.asMmolL : glucose.glucose.value.asMgdL + ) as NSNumber)! + " " + state.units.rawValue + + removeGlucoseAlert = Alert( + title: Text("Delete Glucose?"), + message: Text(glucoseValue), + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteGlucose(glucose) } + ), + secondaryButton: .cancel() + ) + + isRemoveGlucoseAlertPresented = true } } } From b48ca9e04be3e893e45773a656572696d70b0103 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sun, 1 Oct 2023 22:02:49 +0200 Subject: [PATCH 13/61] Add FPU carb equivalent value to delete alert --- .../DataTable/View/DataTableRootView.swift | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 090ca1d796..755fb7adc6 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -35,6 +35,14 @@ extension DataTable { return formatter } + private var fpuFormatter: NumberFormatter { + let formatter = NumberFormatter() + formatter.numberStyle = .decimal + formatter.maximumFractionDigits = 1 + formatter.roundingMode = .halfUp + return formatter + } + var body: some View { VStack { Picker("Mode", selection: $state.mode) { @@ -226,8 +234,18 @@ extension DataTable { var alertMessage = Text(meal.amountText) if meal.type == .fpus { - alertTitle = Text("Delete carb equivalents?") - alertMessage = Text("") + let fpus = state.meals + let carbEquivalents = fpuFormatter.string(from: Double( + fpus.filter { fpu in + fpu.fpuID == meal.fpuID + } + .map { fpu in + fpu.amount ?? 0 } + .reduce(0, +) + ) as NSNumber)! + + alertTitle = Text("Delete Carb Equivalents?") + alertMessage = Text(carbEquivalents + NSLocalizedString(" g", comment: "gram of carbs")) } removeCarbsAlert = Alert( From 8f48a364165dc75648ac098f2df344593a8835da Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sun, 1 Oct 2023 22:55:34 +0200 Subject: [PATCH 14/61] Fix faulty formatting of glucose value in warning --- FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 755fb7adc6..f44c2ad332 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -264,7 +264,7 @@ extension DataTable { private func deleteGlucose(at offsets: IndexSet) { let glucose = state.glucose[offsets[offsets.startIndex]] let glucoseValue = glucoseFormatter.string(from: Double( - state.units == .mmolL ? glucose.glucose.value.asMmolL : glucose.glucose.value.asMgdL + state.units == .mmolL ? Double(glucose.glucose.value.asMmolL) : glucose.glucose.value ) as NSNumber)! + " " + state.units.rawValue removeGlucoseAlert = Alert( From e00c9a47bcaf7c4a5a56719d73c97bf4ffda7f74 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 02:30:34 +0200 Subject: [PATCH 15/61] Add non-pump insulin entry dialog and logic --- .../Modules/DataTable/DataTableProvider.swift | 6 + .../DataTable/DataTableStateModel.swift | 42 +++++- .../DataTable/View/DataTableRootView.swift | 137 ++++++++++++++++-- 3 files changed, 174 insertions(+), 11 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift b/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift index 3bd4bd98b4..0970e2b47f 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift @@ -13,6 +13,12 @@ extension DataTable { pumpHistoryStorage.recent() } + func pumpSettings() -> PumpSettings { + storage.retrieve(OpenAPS.Settings.settings, as: PumpSettings.self) + ?? PumpSettings(from: OpenAPS.defaults(for: OpenAPS.Settings.settings)) + ?? PumpSettings(insulinActionCurve: 6, maxBolus: 10, maxBasal: 2) + } + func tempTargets() -> [TempTarget] { tempTargetsStorage.recent() } diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index e872a040ec..68f3a39d96 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -6,6 +6,7 @@ extension DataTable { @Injected() var broadcaster: Broadcaster! @Injected() var unlockmanager: UnlockManager! @Injected() private var storage: FileStorage! + @Injected() var pumpHistoryStorage: PumpHistoryStorage! let coredataContext = CoreDataStack.shared.persistentContainer.viewContext @@ -15,6 +16,9 @@ extension DataTable { @Published var glucose: [Glucose] = [] @Published var manualGlucose: Decimal = 0 @Published var manualGlucoseDate = Date() + @Published var maxBolus: Decimal = 0 + @Published var nonPumpInsulinAmount: Decimal = 0 + @Published var nonPumpInsulinDate = Date() var units: GlucoseUnits = .mmolL @@ -27,6 +31,7 @@ extension DataTable { broadcaster.register(TempTargetsObserver.self, observer: self) broadcaster.register(CarbsObserver.self, observer: self) broadcaster.register(GlucoseObserver.self, observer: self) + maxBolus = provider.pumpSettings().maxBolus } private func setupTreatments() { @@ -175,7 +180,7 @@ extension DataTable { // try? coredataContext.save() } - func addManualGlucose(manualGlucoseDate: Date) { + func addManualGlucose() { let glucose = units == .mmolL ? manualGlucose.asMgdL : manualGlucose let id = UUID().uuidString @@ -193,6 +198,41 @@ extension DataTable { provider.glucoseStorage.storeGlucose([saveToJSON]) debug(.default, "Manual Glucose saved to glucose.json") } + + func addNonPumpInsulin() { + print("ADDED INSULIN") + + guard nonPumpInsulinAmount > 0 else { + showModal(for: nil) + return + } + + nonPumpInsulinAmount = min(nonPumpInsulinAmount, maxBolus * 3) // Allow for 3 * Max Bolus for non-pump insulin + + unlockmanager.unlock() + .sink { _ in } receiveValue: { [weak self] _ in + guard let self = self else { return } + pumpHistoryStorage.storeEvents( + [ + PumpHistoryEvent( + id: UUID().uuidString, + type: .bolus, + timestamp: nonPumpInsulinDate, + amount: nonPumpInsulinAmount, + duration: nil, + durationMin: nil, + rate: nil, + temp: nil, + carbInput: nil, + isNonPumpInsulin: true + ) + ] + ) + + // showModal(for: nil) + } + .store(in: &lifetime) + } } } diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index f44c2ad332..b0a13bdba8 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -11,9 +11,11 @@ extension DataTable { @State private var removeCarbsAlert: Alert? @State private var isRemoveInsulinAlertPresented = false @State private var removeInsulinAlert: Alert? - @State private var newGlucose = false @State private var isRemoveGlucoseAlertPresented = false + @State private var isInsulinAmountAlertPresented = false @State private var removeGlucoseAlert: Alert? + @State private var newGlucose = false + @State private var nonPumpInsulin = false @Environment(\.colorScheme) var colorScheme @@ -43,6 +45,13 @@ extension DataTable { return formatter } + private var insulinFormatter: NumberFormatter { + let formatter = NumberFormatter() + formatter.numberStyle = .decimal + formatter.maximumFractionDigits = 2 + return formatter + } + var body: some View { VStack { Picker("Mode", selection: $state.mode) { @@ -54,7 +63,7 @@ extension DataTable { .pickerStyle(SegmentedPickerStyle()) .padding(.horizontal) - historyContent + historyContentView } .onAppear(perform: configureView) .navigationTitle("History") @@ -62,6 +71,16 @@ extension DataTable { .navigationBarItems( leading: Button("Close", action: state.hideModal), trailing: HStack { + if state.mode == .treatments && !nonPumpInsulin { + Button(action: { nonPumpInsulin = true }) { + Text("Add") + Image(systemName: "plus.circle.fill") + .resizable() + .frame(width: 24, height: 24) + } + Spacer() + } + if state.mode == .glucose && !newGlucose { Button(action: { newGlucose = true }) { Text("Add") @@ -74,19 +93,27 @@ extension DataTable { } ) .sheet(isPresented: $newGlucose) { - manualGlucoseView + addManualGlucoseView + } + .sheet(isPresented: $nonPumpInsulin) { + addNonPumpInsulinView } } - var manualGlucoseView: some View { + var addManualGlucoseView: some View { NavigationView { VStack { Form { Section { HStack { Text("New Glucose") - DecimalTextField(" ... ", value: $state.manualGlucose, formatter: glucoseFormatter) - Text(state.units.rawValue) + DecimalTextField( + " ... ", + value: $state.manualGlucose, + formatter: glucoseFormatter, + autofocus: true + ) + Text(state.units.rawValue).foregroundStyle(.secondary) } } @@ -100,10 +127,10 @@ extension DataTable { let limitHigh: Decimal = state.units == .mmolL ? 21 : 380 Button { - state.addManualGlucose(manualGlucoseDate: state.manualGlucoseDate) + state.addManualGlucose() newGlucose = false } - label: { Text("Save").font(.title3) } + label: { Text("Save") } .frame(maxWidth: .infinity, alignment: .center) .disabled(state.manualGlucose < limitLow || state.manualGlucose > limitHigh) } @@ -113,11 +140,101 @@ extension DataTable { .onAppear(perform: configureView) .navigationTitle("Add Glucose") .navigationBarTitleDisplayMode(.automatic) - .navigationBarItems(leading: Button("Close", action: { newGlucose = false })) + .navigationBarItems(leading: Button("Close", action: { newGlucose = false + state.nonPumpInsulinAmount = 0 })) + } + } + + var addNonPumpInsulinView: some View { + NavigationView { + VStack { + Form { + Section { + HStack { + Text("Amount") + Spacer() + DecimalTextField( + "0", + value: $state.nonPumpInsulinAmount, + formatter: insulinFormatter, + autofocus: true, + cleanInput: true + ) + Text("U").foregroundColor(.secondary) + } + } + + Section { + DatePicker("Date", selection: $state.nonPumpInsulinDate) + } + + let amountWarningCondition = (state.nonPumpInsulinAmount > state.maxBolus) && + (state.nonPumpInsulinAmount <= state.maxBolus * 3) + + Section { + HStack { + Button { + /* + if amountWarningCondition + { + isInsulinAmountAlertPresented = true + } else { + state.addNonPumpInsulin() + nonPumpInsulin = false + } + */ + state.addNonPumpInsulin() + nonPumpInsulin = false + } + label: { Text("Log non-pump insulin") } + .foregroundColor(amountWarningCondition ? .warning : .accentColor) + .frame(maxWidth: .infinity, alignment: .center) + .disabled( + state.nonPumpInsulinAmount <= 0 || state.nonPumpInsulinAmount > state + .maxBolus * 3 + ) + } + } + header: { + if amountWarningCondition + { + Text("**⚠️ Warning!** The entered insulin amount is greater than your Max Bolus setting!") + } + } + } + /* + .alert(isPresented: $isInsulinAmountAlertPresented) { + let insulinAmount = insulinFormatter.string(from: state.nonPumpInsulinAmount as NSNumber)! + let alertMessage = NSLocalizedString( + "The entered insulin amount is greater than your Max Bolus setting! Are you sure you want to add ", + comment: "Alert" + ) + insulinAmount + + NSLocalizedString(" U", comment: "Insulin unit") + " of non-pump insulin?" + + return Alert( + title: Text("Warning"), + message: Text(alertMessage), + primaryButton: .destructive( + Text("Confirm"), + action: { + state.addNonPumpInsulin() + nonPumpInsulin = false + isInsulinAmountAlertPresented = false + } + ), + secondaryButton: .cancel() + ) + } + */ + } + .onAppear(perform: configureView) + .navigationTitle("Add Non-Pump Insulin") + .navigationBarTitleDisplayMode(.automatic) + .navigationBarItems(leading: Button("Close", action: { nonPumpInsulin = false })) } } - private var historyContent: some View { + private var historyContentView: some View { Form { switch state.mode { case .treatments: treatmentsList From db006adfe484f02f326e0658beec4aa903bd12e5 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 02:31:53 +0200 Subject: [PATCH 16/61] Remove non-pump insulin view elements and logic from bolus module --- .../Modules/Bolus/BolusStateModel.swift | 26 ---------- .../Modules/Bolus/View/BolusRootView.swift | 50 +------------------ 2 files changed, 1 insertion(+), 75 deletions(-) diff --git a/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift b/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift index 72a53a01a6..08604c38c5 100644 --- a/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift +++ b/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift @@ -68,32 +68,6 @@ extension Bolus { .store(in: &lifetime) } - func addWithoutBolus() { - guard amount > 0 else { - showModal(for: nil) - return - } - amount = min(amount, maxBolus * 3) // Allow for 3 * Max Bolus for non-pump insulin - - pumpHistoryStorage.storeEvents( - [ - PumpHistoryEvent( - id: UUID().uuidString, - type: .bolus, - timestamp: Date(), - amount: amount, - duration: nil, - durationMin: nil, - rate: nil, - temp: nil, - carbInput: nil, - isNonPumpInsulin: true - ) - ] - ) - showModal(for: nil) - } - func setupInsulinRequired() { DispatchQueue.main.async { self.insulinRequired = self.provider.suggestion?.insulinReq ?? 0 diff --git a/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift b/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift index 0f1f38b06f..a1c37dbf16 100644 --- a/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift +++ b/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift @@ -7,7 +7,6 @@ extension Bolus { let waitForSuggestion: Bool @StateObject var state = StateModel() - @State private var isAddInsulinAlertPresented = false @State private var presentInfo = false @State private var displayError = false @@ -79,58 +78,11 @@ extension Bolus { Section { Button { state.add() } label: { Text(!(state.amount > state.maxBolus) ? "Enact bolus" : "Max Bolus exceeded!") } + .frame(maxWidth: .infinity, alignment: .center) .disabled( state.amount <= 0 || state.amount > state.maxBolus ) } - Section { - if waitForSuggestion { - Button { state.showModal(for: nil) } - label: { Text("Continue without bolus") } - } else { - Button { isAddInsulinAlertPresented = true } - label: { Text("Add insulin without actually bolusing") } - .disabled(state.amount <= 0 || state.amount > state.maxBolus * 3) - } - } - .alert(isPresented: $isAddInsulinAlertPresented) { - let isOverMax = state.amount > state.maxBolus ? true : false - let secondParagrap1 = "Add" - let secondParagraph2 = " U" - let secondParagraph3 = " without bolusing" - let insulinAmount = formatter.string(from: state.amount as NSNumber)! - - // Actual alert - return Alert( - title: Text( - isOverMax ? "Warning" : "Are you sure?" - ), - message: - Text( - isOverMax ? ( - NSLocalizedString( - "\nAmount is more than your Max Bolus setting! \nAre you sure you want to add ", - comment: "Alert" - ) + insulinAmount + - NSLocalizedString(secondParagraph2, comment: "Insulin unit") + - NSLocalizedString(secondParagraph3, comment: "Add insulin without bolusing alert") + "?" - ) : - NSLocalizedString(secondParagrap1, comment: "Add insulin without bolusing alert") + - " " + - insulinAmount + - NSLocalizedString(secondParagraph2, comment: "Insulin unit") + - NSLocalizedString(secondParagraph3, comment: "Add insulin without bolusing alert") - ), - primaryButton: .destructive( - Text("Add"), - action: { - state.addWithoutBolus() - isAddInsulinAlertPresented = false - } - ), - secondaryButton: .cancel() - ) - } } } .alert(isPresented: $displayError) { From 547f845c486a6a9fd8e1760986df1796c5d5ede8 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 02:32:08 +0200 Subject: [PATCH 17/61] Make button style uniform --- FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift index 8d9081dbcf..e4cac2626f 100644 --- a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift +++ b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift @@ -118,7 +118,7 @@ extension AddCarbs { Section { Button { state.add() } - label: { Text("Save and continue").font(.title3) } + label: { Text("Save and continue") } .disabled(state.carbs <= 0 && state.fat <= 0 && state.protein <= 0) .frame(maxWidth: .infinity, alignment: .center) } footer: { Text(state.waitersNotepad().description) } From b1dfdd99bd574fb93ad8fcc8db67d294d80fb410 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 03:33:48 +0200 Subject: [PATCH 18/61] Update bolus amount warning for better visuals --- .../DataTable/View/DataTableRootView.swift | 45 +++---------------- 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index b0a13bdba8..e8829ebeaa 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -73,22 +73,20 @@ extension DataTable { trailing: HStack { if state.mode == .treatments && !nonPumpInsulin { Button(action: { nonPumpInsulin = true }) { - Text("Add") + Text("Non-Pump Insulin") Image(systemName: "plus.circle.fill") .resizable() .frame(width: 24, height: 24) } - Spacer() } if state.mode == .glucose && !newGlucose { Button(action: { newGlucose = true }) { - Text("Add") + Text("Glucose") Image(systemName: "plus.circle.fill") .resizable() .frame(width: 24, height: 24) } - Spacer() } } ) @@ -174,20 +172,11 @@ extension DataTable { Section { HStack { Button { - /* - if amountWarningCondition - { - isInsulinAmountAlertPresented = true - } else { - state.addNonPumpInsulin() - nonPumpInsulin = false - } - */ state.addNonPumpInsulin() nonPumpInsulin = false } label: { Text("Log non-pump insulin") } - .foregroundColor(amountWarningCondition ? .warning : .accentColor) + .foregroundColor(amountWarningCondition ? Color.white : Color.accentColor) .frame(maxWidth: .infinity, alignment: .center) .disabled( state.nonPumpInsulinAmount <= 0 || state.nonPumpInsulinAmount > state @@ -201,31 +190,11 @@ extension DataTable { Text("**⚠️ Warning!** The entered insulin amount is greater than your Max Bolus setting!") } } + .listRowBackground( + amountWarningCondition ? Color + .red : colorScheme == .dark ? Color(UIColor.secondarySystemBackground) : Color.white + ) } - /* - .alert(isPresented: $isInsulinAmountAlertPresented) { - let insulinAmount = insulinFormatter.string(from: state.nonPumpInsulinAmount as NSNumber)! - let alertMessage = NSLocalizedString( - "The entered insulin amount is greater than your Max Bolus setting! Are you sure you want to add ", - comment: "Alert" - ) + insulinAmount + - NSLocalizedString(" U", comment: "Insulin unit") + " of non-pump insulin?" - - return Alert( - title: Text("Warning"), - message: Text(alertMessage), - primaryButton: .destructive( - Text("Confirm"), - action: { - state.addNonPumpInsulin() - nonPumpInsulin = false - isInsulinAmountAlertPresented = false - } - ), - secondaryButton: .cancel() - ) - } - */ } .onAppear(perform: configureView) .navigationTitle("Add Non-Pump Insulin") From 20ea08fb718019d8f2a3afd53e878296d8e9d12b Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 03:41:28 +0200 Subject: [PATCH 19/61] Add conditional 'No data.' message for history contents --- .../DataTable/View/DataTableRootView.swift | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index e8829ebeaa..81160a9d13 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -215,11 +215,16 @@ extension DataTable { private var treatmentsList: some View { List { - ForEach(state.treatments) { item in - treatmentView(item) + if !state.treatments.isEmpty { + ForEach(state.treatments) { item in + treatmentView(item) + } + .onDelete(perform: deleteTreatment) + } else { + HStack { + Text("No data.") + } } - - .onDelete(perform: deleteTreatment) } .alert(isPresented: $isRemoveInsulinAlertPresented) { removeInsulinAlert! @@ -228,10 +233,16 @@ extension DataTable { private var mealsList: some View { List { - ForEach(state.meals) { item in - mealView(item) + if !state.meals.isEmpty { + ForEach(state.meals) { item in + mealView(item) + } + .onDelete(perform: deleteMeal) + } else { + HStack { + Text("No data.") + } } - .onDelete(perform: deleteMeal) } .alert(isPresented: $isRemoveCarbsAlertPresented) { removeCarbsAlert! @@ -240,10 +251,16 @@ extension DataTable { private var glucoseList: some View { List { - ForEach(state.glucose) { item in - glucoseView(item) + if !state.glucose.isEmpty { + ForEach(state.glucose) { item in + glucoseView(item) + } + .onDelete(perform: deleteGlucose) + } else { + HStack { + Text("No data.") + } } - .onDelete(perform: deleteGlucose) } .alert(isPresented: $isRemoveGlucoseAlertPresented) { removeGlucoseAlert! From b375ee0858ec18d4506b64a02e6826e04d52a1b3 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 14:40:37 +0200 Subject: [PATCH 20/61] Revert home view icon changes --- .../Colors/Basal.colorset/Contents.json | 8 ++--- .../Modules/Home/View/HomeRootView.swift | 34 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/FreeAPS/Resources/Assets.xcassets/Colors/Basal.colorset/Contents.json b/FreeAPS/Resources/Assets.xcassets/Colors/Basal.colorset/Contents.json index 7aae3ba200..cfddd9cc6f 100644 --- a/FreeAPS/Resources/Assets.xcassets/Colors/Basal.colorset/Contents.json +++ b/FreeAPS/Resources/Assets.xcassets/Colors/Basal.colorset/Contents.json @@ -22,10 +22,10 @@ "color" : { "color-space" : "srgb", "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" + "alpha" : "0.500", + "blue" : "0.988", + "green" : "0.588", + "red" : "0.118" } }, "idiom" : "universal" diff --git a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift index b2bc04475f..6efcf8e091 100644 --- a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift +++ b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift @@ -95,7 +95,7 @@ extension Home { .frame(maxWidth: .infinity) .padding(.top, 10 + geo.safeAreaInsets.top) .padding(.bottom, 10) - .background(Color.gray.opacity(0.2)) + .background(Color.gray.opacity(0.3)) } var cobIobView: some View { @@ -475,17 +475,17 @@ extension Home { @ViewBuilder private func bottomPanel(_ geo: GeometryProxy) -> some View { ZStack { - Rectangle().fill(Color.gray.opacity(0.3)).frame(height: 54 + geo.safeAreaInsets.bottom) + Rectangle().fill(Color.gray.opacity(0.3)).frame(height: 50 + geo.safeAreaInsets.bottom) HStack { Button { state.showModal(for: .addCarbs) } label: { ZStack(alignment: Alignment(horizontal: .trailing, vertical: .bottom)) { - Image(systemName: "fork.knife.circle") + Image("carbs") .renderingMode(.template) .resizable() - .frame(width: 30, height: 30) - .foregroundColor(.uam) + .frame(width: 24, height: 24) + .foregroundColor(.loopYellow) .padding(8) if let carbsReq = state.carbsRequired { Text(numberFormatter.string(from: carbsReq as NSNumber)!) @@ -495,14 +495,14 @@ extension Home { .background(Capsule().fill(Color.red)) } } - }.buttonStyle(.plain) + }.buttonStyle(.borderless) Spacer() Button { state.showModal(for: .addTempTarget) } label: { - Image(systemName: "target") + Image("target") .renderingMode(.template) .resizable() - .frame(width: 30, height: 30) + .frame(width: 24, height: 24) .padding(8) } .foregroundColor(.loopGreen) @@ -510,10 +510,10 @@ extension Home { Spacer() Button { state.showModal(for: .bolus(waitForSuggestion: false)) } label: { - Image(systemName: "drop.circle") + Image("bolus") .renderingMode(.template) .resizable() - .frame(width: 30, height: 30) + .frame(width: 24, height: 24) .padding(8) } .foregroundColor(.insulin) @@ -522,10 +522,10 @@ extension Home { if state.allowManualTemp { Button { state.showModal(for: .manualTempBasal) } label: { - Image(systemName: "plus.circle") + Image("bolus1") .renderingMode(.template) .resizable() - .frame(width: 30, height: 30) + .frame(width: 24, height: 24) .padding(8) } .foregroundColor(.insulin) @@ -535,10 +535,10 @@ extension Home { Button { state.showModal(for: .statistics) } label: { - Image(systemName: "chart.line.uptrend.xyaxis.circle") + Image(systemName: "chart.xyaxis.line") .renderingMode(.template) .resizable() - .frame(width: 30, height: 30) + .frame(width: 24, height: 24) .padding(8) } .foregroundColor(.purple) @@ -546,13 +546,13 @@ extension Home { Spacer() Button { state.showModal(for: .settings) } label: { - Image(systemName: "gearshape.circle") + Image("settings1") .renderingMode(.template) .resizable() - .frame(width: 30, height: 30) + .frame(width: 24, height: 24) .padding(8) } - .foregroundColor(.gray) + .foregroundColor(.loopGray) .buttonStyle(.borderless) } .padding(.horizontal, 24) From ca72e1e090ffa54ecbf3bc604d6cd44b72d15c2e Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 14:42:20 +0200 Subject: [PATCH 21/61] Add wrongly removed 'Continue without bolusing' back in --- FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift b/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift index a1c37dbf16..a94ac703df 100644 --- a/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift +++ b/FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift @@ -83,6 +83,13 @@ extension Bolus { state.amount <= 0 || state.amount > state.maxBolus ) } + + if waitForSuggestion { + Section { + Button { state.showModal(for: nil) } + label: { Text("Continue without bolus") }.frame(maxWidth: .infinity, alignment: .center) + } + } } } .alert(isPresented: $displayError) { From 6af6300f943b3b3e0ff94578c3b9846150cbb86d Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 14:42:39 +0200 Subject: [PATCH 22/61] Resert non-pump insulin amount on save --- FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index 68f3a39d96..b7fdde19ec 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -229,7 +229,8 @@ extension DataTable { ] ) - // showModal(for: nil) + // Reset amount to 0 for next entry. + self.nonPumpInsulinAmount = 0 } .store(in: &lifetime) } From 5f721e8ece8c633c69edcea51d5644a1f898ac79 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 16:30:16 +0200 Subject: [PATCH 23/61] Fix setting non-pump insulin amount and manual glucose value to 0 on save --- FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift | 6 +++++- .../Sources/Modules/DataTable/View/DataTableRootView.swift | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index b7fdde19ec..84819bc826 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -197,6 +197,9 @@ extension DataTable { ) provider.glucoseStorage.storeGlucose([saveToJSON]) debug(.default, "Manual Glucose saved to glucose.json") + + // Reset amount to 0 for next entry. + manualGlucose = 0 } func addNonPumpInsulin() { @@ -228,9 +231,10 @@ extension DataTable { ) ] ) + debug(.default, "Non-pump insulin saved to pumphistory.json") // Reset amount to 0 for next entry. - self.nonPumpInsulinAmount = 0 + nonPumpInsulinAmount = 0 } .store(in: &lifetime) } diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 81160a9d13..2cda1b8253 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -139,7 +139,7 @@ extension DataTable { .navigationTitle("Add Glucose") .navigationBarTitleDisplayMode(.automatic) .navigationBarItems(leading: Button("Close", action: { newGlucose = false - state.nonPumpInsulinAmount = 0 })) + state.manualGlucose = 0 })) } } @@ -199,7 +199,7 @@ extension DataTable { .onAppear(perform: configureView) .navigationTitle("Add Non-Pump Insulin") .navigationBarTitleDisplayMode(.automatic) - .navigationBarItems(leading: Button("Close", action: { nonPumpInsulin = false })) + .navigationBarItems(leading: Button("Close", action: { nonPumpInsulin = false; state.nonPumpInsulinAmount = 0 })) } } From 45022d2dd4a9a56bba4a8f2decd8d29b313ab697 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 23:01:27 +0200 Subject: [PATCH 24/61] Shorten overly long navigation view title for carb entry --- FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift index e4cac2626f..14e7fc29e9 100644 --- a/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift +++ b/FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift @@ -130,7 +130,7 @@ extension AddCarbs { } } .onAppear(perform: configureView) - .navigationTitle(state.useFPUconversion ? "Add Carbs, Fat & Protein" : "Add Carbohydrates") + .navigationTitle("Add Meals") .navigationBarTitleDisplayMode(.automatic) .navigationBarItems(leading: Button("Close", action: state.hideModal)) } From 6fcd2da6de87484b241f6f121fe24a2b8ea986cd Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 23:03:50 +0200 Subject: [PATCH 25/61] Add filter for future meal entries; add variable types; shorten title --- .../DataTable/View/DataTableRootView.swift | 73 ++++++++++++++----- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 2cda1b8253..eb3effd5a4 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -14,8 +14,9 @@ extension DataTable { @State private var isRemoveGlucoseAlertPresented = false @State private var isInsulinAmountAlertPresented = false @State private var removeGlucoseAlert: Alert? - @State private var newGlucose = false - @State private var nonPumpInsulin = false + @State private var showManualGlucose: Bool = false + @State private var showNonPumpInsulin: Bool = false + @State private var showFutureEntries: Bool = false @Environment(\.colorScheme) var colorScheme @@ -52,6 +53,19 @@ extension DataTable { return formatter } + var futureEntryBtn: some View { + Button(action: { showFutureEntries.toggle() }, label: { + Text((showFutureEntries ? "Hide" : "Show") + " Future Entries").foregroundColor(Color.white) + .font(.caption) + Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus") + .resizable() + .frame(width: 18, height: 18) + .foregroundColor(Color.white) + }) + .padding(.trailing, 20) + .offset(x: 0, y: -50) + } + var body: some View { VStack { Picker("Mode", selection: $state.mode) { @@ -62,7 +76,7 @@ extension DataTable { } .pickerStyle(SegmentedPickerStyle()) .padding(.horizontal) - + historyContentView } .onAppear(perform: configureView) @@ -71,17 +85,27 @@ extension DataTable { .navigationBarItems( leading: Button("Close", action: state.hideModal), trailing: HStack { - if state.mode == .treatments && !nonPumpInsulin { - Button(action: { nonPumpInsulin = true }) { + if state.mode == .treatments && !showNonPumpInsulin { + Button(action: { showNonPumpInsulin = true }) { Text("Non-Pump Insulin") Image(systemName: "plus.circle.fill") .resizable() .frame(width: 24, height: 24) } } - - if state.mode == .glucose && !newGlucose { - Button(action: { newGlucose = true }) { + if state.mode == .meals { + Button(action: { showFutureEntries.toggle() }, label: { + Text((showFutureEntries ? "Hide" : "Show") + " Future Entries") + .foregroundColor(colorScheme == .dark ? Color.white : Color.black) + .font(.caption) + Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus") + .resizable() + .frame(width: 18, height: 18) + .foregroundColor(colorScheme == .dark ? Color.white : Color.black) + }).buttonStyle(.bordered) + } + if state.mode == .glucose && !showManualGlucose { + Button(action: { showManualGlucose = true }) { Text("Glucose") Image(systemName: "plus.circle.fill") .resizable() @@ -90,10 +114,10 @@ extension DataTable { } } ) - .sheet(isPresented: $newGlucose) { + .sheet(isPresented: $showManualGlucose) { addManualGlucoseView } - .sheet(isPresented: $nonPumpInsulin) { + .sheet(isPresented: $showNonPumpInsulin) { addNonPumpInsulinView } } @@ -126,7 +150,7 @@ extension DataTable { Button { state.addManualGlucose() - newGlucose = false + showManualGlucose = false } label: { Text("Save") } .frame(maxWidth: .infinity, alignment: .center) @@ -136,9 +160,9 @@ extension DataTable { } } .onAppear(perform: configureView) - .navigationTitle("Add Glucose") + .navigationTitle("Add Glucose") .navigationBarTitleDisplayMode(.automatic) - .navigationBarItems(leading: Button("Close", action: { newGlucose = false + .navigationBarItems(leading: Button("Close", action: { showManualGlucose = false state.manualGlucose = 0 })) } } @@ -173,7 +197,7 @@ extension DataTable { HStack { Button { state.addNonPumpInsulin() - nonPumpInsulin = false + showNonPumpInsulin = false } label: { Text("Log non-pump insulin") } .foregroundColor(amountWarningCondition ? Color.white : Color.accentColor) @@ -197,9 +221,10 @@ extension DataTable { } } .onAppear(perform: configureView) - .navigationTitle("Add Non-Pump Insulin") + .navigationTitle("Non-Pump Insulin") .navigationBarTitleDisplayMode(.automatic) - .navigationBarItems(leading: Button("Close", action: { nonPumpInsulin = false; state.nonPumpInsulinAmount = 0 })) + .navigationBarItems(leading: Button("Close", action: { showNonPumpInsulin = false + state.nonPumpInsulinAmount = 0 })) } } @@ -234,10 +259,20 @@ extension DataTable { private var mealsList: some View { List { if !state.meals.isEmpty { - ForEach(state.meals) { item in - mealView(item) + if !showFutureEntries { + ForEach(state.meals.filter { meal in + meal.date <= Date() + }) { meal in + + mealView(meal) + } + .onDelete(perform: deleteMeal) + } else { + ForEach(state.meals) { item in + mealView(item) + } + .onDelete(perform: deleteMeal) } - .onDelete(perform: deleteMeal) } else { HStack { Text("No data.") From 5d49213e2d0e886c6efa731a0bd5285d910bcb15 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 2 Oct 2023 23:16:40 +0200 Subject: [PATCH 26/61] Fix weird text change for filter button --- .../Sources/Modules/DataTable/View/DataTableRootView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index eb3effd5a4..b9d98da868 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -76,7 +76,7 @@ extension DataTable { } .pickerStyle(SegmentedPickerStyle()) .padding(.horizontal) - + historyContentView } .onAppear(perform: configureView) @@ -95,7 +95,7 @@ extension DataTable { } if state.mode == .meals { Button(action: { showFutureEntries.toggle() }, label: { - Text((showFutureEntries ? "Hide" : "Show") + " Future Entries") + Text(showFutureEntries ? "Hide Future Entries" : "Show Future Entries") .foregroundColor(colorScheme == .dark ? Color.white : Color.black) .font(.caption) Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus") From ce7a69e0abb392755a3ee01d658bdb595a92b338 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Tue, 3 Oct 2023 22:25:07 +0200 Subject: [PATCH 27/61] Add combined treatments view and related setting; filter broken --- .../Resources/json/defaults/preferences.json | 3 +- FreeAPS/Sources/Models/FreeAPSSettings.swift | 5 + .../Modules/DataTable/DataTableDataFlow.swift | 4 + .../Modules/DataTable/DataTableProvider.swift | 1 + .../DataTable/DataTableStateModel.swift | 47 ++++- .../DataTable/View/DataTableRootView.swift | 191 +++++++++++++++--- .../StatConfig/StatConfigStateModel.swift | 8 +- .../StatConfig/View/StatConfigRootView.swift | 1 + 8 files changed, 217 insertions(+), 43 deletions(-) diff --git a/FreeAPS/Resources/json/defaults/preferences.json b/FreeAPS/Resources/json/defaults/preferences.json index 6edb81100d..5bf5272496 100644 --- a/FreeAPS/Resources/json/defaults/preferences.json +++ b/FreeAPS/Resources/json/defaults/preferences.json @@ -49,5 +49,6 @@ "enableSMB_high_bg" : false, "enableSMB_high_bg_target" : 110, "threshold_setting" : 65, - "updateInterval" : 20 + "updateInterval" : 20, + "combineTreatmentsHistory" : false } diff --git a/FreeAPS/Sources/Models/FreeAPSSettings.swift b/FreeAPS/Sources/Models/FreeAPSSettings.swift index 031d9a48b2..9802a9884e 100644 --- a/FreeAPS/Sources/Models/FreeAPSSettings.swift +++ b/FreeAPS/Sources/Models/FreeAPSSettings.swift @@ -33,6 +33,7 @@ struct FreeAPSSettings: JSON, Equatable { var useAppleHealth: Bool = false var smoothGlucose: Bool = false var displayOnWatch: AwConfig = .BGTarget + var combineTreatmentsHistory: Bool = false var overrideHbA1cUnit: Bool = false var high: Decimal = 145 var low: Decimal = 70 @@ -218,6 +219,10 @@ extension FreeAPSSettings: Decodable { settings.rulerMarks = rulerMarks } + if let combineTreatmentsHistory = try? container.decode(Bool.self, forKey: .combineTreatmentsHistory) { + settings.combineTreatmentsHistory = combineTreatmentsHistory + } + if let overrideHbA1cUnit = try? container.decode(Bool.self, forKey: .overrideHbA1cUnit) { settings.overrideHbA1cUnit = overrideHbA1cUnit } diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift index 1157dcba35..295a91ea80 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift @@ -116,6 +116,10 @@ enum DataTable { self.isNonPump = isNonPump } + func isInFuture() -> Bool { + date <= Date() + } + static func == (lhs: Treatment, rhs: Treatment) -> Bool { lhs.id == rhs.id } diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift b/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift index 0970e2b47f..843f4aa9c7 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift @@ -8,6 +8,7 @@ extension DataTable { @Injected() var carbsStorage: CarbsStorage! @Injected() var nightscoutManager: NightscoutManager! @Injected() var healthkitManager: HealthKitManager! + @Injected() var settingsManager: SettingsManager! func pumpHistory() -> [PumpHistoryEvent] { pumpHistoryStorage.recent() diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index 84819bc826..c539fe2434 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -10,9 +10,11 @@ extension DataTable { let coredataContext = CoreDataStack.shared.persistentContainer.viewContext + @Published var isCombinedTreatments: Bool = false @Published var mode: Mode = .treatments @Published var treatments: [Treatment] = [] @Published var meals: [Treatment] = [] + @Published var filteredEntries: [Treatment] = [] @Published var glucose: [Glucose] = [] @Published var manualGlucose: Decimal = 0 @Published var manualGlucoseDate = Date() @@ -35,6 +37,8 @@ extension DataTable { } private func setupTreatments() { + isCombinedTreatments = settingsManager.settings.combineTreatmentsHistory + DispatchQueue.global().async { let units = self.settingsManager.settings.units @@ -70,6 +74,21 @@ extension DataTable { ) } + let fpusFiltered = self.provider.fpus() + .filter { $0.isFPU ?? false && $0.createdAt <= Date() } + .map { + Treatment( + units: units, + type: .fpus, + date: $0.createdAt, + amount: $0.carbs, + id: $0.id, + isFPU: $0.isFPU, + fpuID: $0.fpuID, + note: $0.note + ) + } + let boluses = self.provider.pumpHistory() .filter { $0.type == .bolus } .map { @@ -126,12 +145,26 @@ extension DataTable { } DispatchQueue.main.async { - self.treatments = [boluses, tempBasals, tempTargets, suspend, resume] - .flatMap { $0 } - .sorted { $0.date > $1.date } - self.meals = [carbs, fpus] - .flatMap { $0 } - .sorted { $0.date > $1.date } + if self.isCombinedTreatments { + self.treatments = [boluses, tempBasals, tempTargets, suspend, resume, carbs, fpus] + .flatMap { $0 } + .sorted { $0.date > $1.date } + self.filteredEntries = [boluses, tempBasals, tempTargets, suspend, resume, carbs, fpusFiltered] + .flatMap { $0 } + .sorted { $0.date > $1.date } + .filter { $0.date <= Date() } + } else { + self.treatments = [boluses, tempBasals, tempTargets, suspend, resume] + .flatMap { $0 } + .sorted { $0.date > $1.date } + self.meals = [carbs, fpus] + .flatMap { $0 } + .sorted { $0.date > $1.date } + self.filteredEntries = [carbs, fpusFiltered] + .flatMap { $0 } + .sorted { $0.date > $1.date } + .filter { $0.date <= Date() } + } } } } @@ -197,7 +230,7 @@ extension DataTable { ) provider.glucoseStorage.storeGlucose([saveToJSON]) debug(.default, "Manual Glucose saved to glucose.json") - + // Reset amount to 0 for next entry. manualGlucose = 0 } diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index b9d98da868..beaab01a07 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -7,6 +7,8 @@ extension DataTable { let resolver: Resolver @StateObject var state = StateModel() + @State private var isRemoveCombinedTreatmentAlertPresented = false + @State private var removeCombinedTreatmentAlert: Alert? @State private var isRemoveCarbsAlertPresented = false @State private var removeCarbsAlert: Alert? @State private var isRemoveInsulinAlertPresented = false @@ -16,7 +18,8 @@ extension DataTable { @State private var removeGlucoseAlert: Alert? @State private var showManualGlucose: Bool = false @State private var showNonPumpInsulin: Bool = false - @State private var showFutureEntries: Bool = false + @State private var showFutureEntries: Bool = + true // false TODO: fix filtering of future entries OR rework treatment for to show MEALS not carbs + FPU @Environment(\.colorScheme) var colorScheme @@ -53,25 +56,21 @@ extension DataTable { return formatter } - var futureEntryBtn: some View { - Button(action: { showFutureEntries.toggle() }, label: { - Text((showFutureEntries ? "Hide" : "Show") + " Future Entries").foregroundColor(Color.white) - .font(.caption) - Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus") - .resizable() - .frame(width: 18, height: 18) - .foregroundColor(Color.white) - }) - .padding(.trailing, 20) - .offset(x: 0, y: -50) - } - var body: some View { VStack { Picker("Mode", selection: $state.mode) { - ForEach(Mode.allCases.indexed(), id: \.1) { index, item in - Text(item.name) - .tag(index) + if state.isCombinedTreatments { + ForEach(Mode.allCases.indexed(), id: \.1) { index, item in + if item != .meals { + Text(item.name) + .tag(index) + } + } + } else { + ForEach(Mode.allCases.indexed(), id: \.1) { index, item in + Text(item.name) + .tag(index) + } } } .pickerStyle(SegmentedPickerStyle()) @@ -93,17 +92,11 @@ extension DataTable { .frame(width: 24, height: 24) } } - if state.mode == .meals { - Button(action: { showFutureEntries.toggle() }, label: { - Text(showFutureEntries ? "Hide Future Entries" : "Show Future Entries") - .foregroundColor(colorScheme == .dark ? Color.white : Color.black) - .font(.caption) - Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus") - .resizable() - .frame(width: 18, height: 18) - .foregroundColor(colorScheme == .dark ? Color.white : Color.black) - }).buttonStyle(.bordered) - } + /* + if state.mode == .meals, !state.isCombinedTreatments { + filterFutureEntriesButton + } + */ if state.mode == .glucose && !showManualGlucose { Button(action: { showManualGlucose = true }) { Text("Glucose") @@ -228,12 +221,43 @@ extension DataTable { } } + private var filterFutureEntriesButton: some View { + VStack { + Button(action: { showFutureEntries.toggle() }, label: { + HStack { + Text(showFutureEntries ? "Hide Future Entries" : "Show Future Entries") + .foregroundColor(colorScheme == .dark ? Color.white : Color.black) + .font(.caption) + Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus") + .resizable() + .frame(width: 18, height: 18) + .foregroundColor(colorScheme == .dark ? Color.white : Color.black) + }.frame(maxWidth: .infinity, alignment: .center) + }).buttonStyle(.bordered) + + Spacer() + } + } + private var historyContentView: some View { Form { - switch state.mode { - case .treatments: treatmentsList - case .meals: mealsList - case .glucose: glucoseList + Section( + // header: state.isCombinedTreatments && state.mode == .treatments ? filterFutureEntriesButton : nil + ) { + // populate the list + if state.isCombinedTreatments { + switch state.mode { + case .treatments: combinedTreatmentsList + case .meals: EmptyView() + case .glucose: glucoseList + } + } else { + switch state.mode { + case .treatments: treatmentsList + case .meals: mealsList + case .glucose: glucoseList + } + } } } } @@ -256,6 +280,37 @@ extension DataTable { } } + private var combinedTreatmentsList: some View { + List { + ForEach(!showFutureEntries ? state.filteredEntries : state.treatments) { treatment in + combinedTreatmentView(treatment) + } + .onDelete(perform: deleteTreatmentForCombined) + /* + if !showFutureEntries { + // use filteredEntries here -> filtered in StateModel + + /* + ForEach(state.filteredEntries.filter { treatment in + treatment.date <= Date() + }, id: \.self) { treatment in + combinedTreatmentView(treatment) + } + .onDelete(perform: deleteTreatmentForCombined) + */ + } else { + ForEach(state.treatments) { treatment in + combinedTreatmentView(treatment) + } + .onDelete(perform: deleteTreatmentForCombined) + } + */ + } + .alert(isPresented: $isRemoveCombinedTreatmentAlertPresented) { + removeCombinedTreatmentAlert! + } + } + private var mealsList: some View { List { if !state.meals.isEmpty { @@ -302,6 +357,23 @@ extension DataTable { } } + @ViewBuilder private func combinedTreatmentView(_ treatment: Treatment) -> some View { + HStack { + Image(systemName: "circle.fill").foregroundColor(treatment.color) + Text((treatment.isSMB ?? false) ? "SMB" : treatment.type.name) + Text(treatment.amountText).foregroundColor(.secondary) + + if let duration = treatment.durationText { + Text(duration).foregroundColor(.secondary) + } + + Spacer() + + Text(dateFormatter.string(from: treatment.date)) + .moveDisabled(true) + } + } + @ViewBuilder private func treatmentView(_ bolus: Treatment) -> some View { HStack { Text((bolus.isSMB ?? false) ? "SMB" : bolus.type.name) @@ -399,6 +471,61 @@ extension DataTable { isRemoveCarbsAlertPresented = true } + private func deleteTreatmentForCombined(at offsets: IndexSet) { + let treatment = state.treatments[offsets[offsets.startIndex]] + var alertTitle = "" + var alertMessage = "" + + if treatment.type == .carbs || treatment.type == .fpus { + if treatment.type == .fpus { + let fpus = state.treatments + let carbEquivalents = fpuFormatter.string(from: Double( + fpus.filter { fpu in + fpu.fpuID == treatment.fpuID + } + .map { fpu in + fpu.amount ?? 0 } + .reduce(0, +) + ) as NSNumber)! + + alertTitle = "Delete Carb Equivalents?" + alertMessage = carbEquivalents + NSLocalizedString(" g", comment: "gram of carbs") + } + + if treatment.type == .carbs { + alertTitle = "Delete Carbs?" + alertMessage = treatment.amountText + } + + removeCombinedTreatmentAlert = Alert( + title: Text(alertTitle), + message: Text(alertMessage), + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteCarbs(treatment) } + ), + secondaryButton: .cancel() + ) + } else { + // treatment is .bolus + + alertTitle = "Delete Insulin?" + alertMessage = treatment.amountText + + removeCombinedTreatmentAlert = Alert( + title: Text(alertTitle), + message: Text(alertMessage), + primaryButton: .destructive( + Text("Delete"), + action: { state.deleteInsulin(treatment) } + ), + secondaryButton: .cancel() + ) + } + + isRemoveCombinedTreatmentAlertPresented = true + } + private func deleteGlucose(at offsets: IndexSet) { let glucose = state.glucose[offsets[offsets.startIndex]] let glucoseValue = glucoseFormatter.string(from: Double( diff --git a/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift b/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift index 4699f1a756..268e9b991b 100644 --- a/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift +++ b/FreeAPS/Sources/Modules/StatConfig/StatConfigStateModel.swift @@ -2,13 +2,14 @@ import SwiftUI extension StatConfig { final class StateModel: BaseStateModel { - @Published var overrideHbA1cUnit = false + @Published var combineTreatmentsHistory: Bool = false + @Published var overrideHbA1cUnit: Bool = false @Published var low: Decimal = 4 / 0.0555 @Published var high: Decimal = 10 / 0.0555 @Published var hours: Decimal = 6 - @Published var xGridLines = false + @Published var xGridLines: Bool = false @Published var yGridLines: Bool = false - @Published var oneDimensionalGraph = false + @Published var oneDimensionalGraph: Bool = false @Published var rulerMarks: Bool = false var units: GlucoseUnits = .mmolL @@ -17,6 +18,7 @@ extension StatConfig { let units = settingsManager.settings.units self.units = units + subscribeSetting(\.combineTreatmentsHistory, on: $combineTreatmentsHistory) { combineTreatmentsHistory = $0 } subscribeSetting(\.overrideHbA1cUnit, on: $overrideHbA1cUnit) { overrideHbA1cUnit = $0 } subscribeSetting(\.xGridLines, on: $xGridLines) { xGridLines = $0 } subscribeSetting(\.yGridLines, on: $yGridLines) { yGridLines = $0 } diff --git a/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift b/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift index fb12163d13..ac20eba434 100644 --- a/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift +++ b/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift @@ -27,6 +27,7 @@ extension StatConfig { var body: some View { Form { Section(header: Text("Settings")) { + Toggle("Combine Treatments in History", isOn: $state.combineTreatmentsHistory) Toggle("Change HbA1c Unit", isOn: $state.overrideHbA1cUnit) Toggle("Display Chart X - Grid lines", isOn: $state.xGridLines) Toggle("Display Chart Y - Grid lines", isOn: $state.yGridLines) From 9c63ba71c28dfcc06cdc03f7c43893f06db0e479 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Wed, 4 Oct 2023 00:39:56 +0200 Subject: [PATCH 28/61] Change isCombined state and do not import settingsManager --- FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift | 1 - FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift b/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift index 843f4aa9c7..0970e2b47f 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableProvider.swift @@ -8,7 +8,6 @@ extension DataTable { @Injected() var carbsStorage: CarbsStorage! @Injected() var nightscoutManager: NightscoutManager! @Injected() var healthkitManager: HealthKitManager! - @Injected() var settingsManager: SettingsManager! func pumpHistory() -> [PumpHistoryEvent] { pumpHistoryStorage.recent() diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index c539fe2434..2a81811550 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -10,7 +10,6 @@ extension DataTable { let coredataContext = CoreDataStack.shared.persistentContainer.viewContext - @Published var isCombinedTreatments: Bool = false @Published var mode: Mode = .treatments @Published var treatments: [Treatment] = [] @Published var meals: [Treatment] = [] @@ -23,9 +22,11 @@ extension DataTable { @Published var nonPumpInsulinDate = Date() var units: GlucoseUnits = .mmolL + var isCombinedTreatments: Bool = false override func subscribe() { units = settingsManager.settings.units + isCombinedTreatments = settingsManager.settings.combineTreatmentsHistory setupTreatments() setupGlucose() broadcaster.register(SettingsObserver.self, observer: self) From 90563a283e9b9696bc9ef3cdefda1f10f0885827 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Fri, 6 Oct 2023 23:34:04 +0200 Subject: [PATCH 29/61] Remove filtering from history; colors for SMB and non-pump insulin --- .../xcshareddata/swiftpm/Package.resolved | 2 +- .../NonPumpInsulin.colorset/Contents.json | 38 ------ .../Colors/SMB.colorset/Contents.json | 38 ------ .../Sources/Helpers/Color+Extensions.swift | 4 - .../Modules/DataTable/DataTableDataFlow.swift | 1 - .../DataTable/DataTableStateModel.swift | 24 ---- .../DataTable/View/DataTableRootView.swift | 113 +++++------------- 7 files changed, 28 insertions(+), 192 deletions(-) delete mode 100644 FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json delete mode 100644 FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json diff --git a/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved b/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved index 142d983415..2cfe78ebfa 100644 --- a/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -30,7 +30,7 @@ }, { "package": "SwiftCharts", - "repositoryURL": "https://github.com/ivanschuetz/SwiftCharts", + "repositoryURL": "https://github.com/ivanschuetz/SwiftCharts.git", "state": { "branch": "master", "revision": "c354c1945bb35a1f01b665b22474f6db28cba4a2", diff --git a/FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json b/FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json deleted file mode 100644 index 2286e0275d..0000000000 --- a/FreeAPS/Resources/Assets.xcassets/Colors/NonPumpInsulin.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "250", - "green" : "213", - "red" : "63" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "250", - "green" : "213", - "red" : "63" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json b/FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json deleted file mode 100644 index 8a5ff421b4..0000000000 --- a/FreeAPS/Resources/Assets.xcassets/Colors/SMB.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "194", - "green" : "117", - "red" : "58" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "194", - "green" : "117", - "red" : "58" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/FreeAPS/Sources/Helpers/Color+Extensions.swift b/FreeAPS/Sources/Helpers/Color+Extensions.swift index 795b32beaf..1b66ad90d2 100644 --- a/FreeAPS/Sources/Helpers/Color+Extensions.swift +++ b/FreeAPS/Sources/Helpers/Color+Extensions.swift @@ -10,10 +10,6 @@ extension Color { static let insulin = Color("Insulin") - static let smb = Color("SMB") - - static let nonPumpInsulin = Color("NonPumpInsulin") - // The loopAccent color is intended to be use as the app accent color. public static let loopAccent = Color("accent") diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift index 295a91ea80..e7afba5118 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift @@ -188,7 +188,6 @@ enum DataTable { case .fpus: return .loopRed case .bolus: - // return (isNonPump ?? false) ? Color.nonPumpInsulin : (isSMB ?? false) ? Color.smb : Color.insulin return .insulin case .tempBasal: return Color.insulin.opacity(0.4) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index 2a81811550..2f9630362b 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -13,7 +13,6 @@ extension DataTable { @Published var mode: Mode = .treatments @Published var treatments: [Treatment] = [] @Published var meals: [Treatment] = [] - @Published var filteredEntries: [Treatment] = [] @Published var glucose: [Glucose] = [] @Published var manualGlucose: Decimal = 0 @Published var manualGlucoseDate = Date() @@ -75,21 +74,6 @@ extension DataTable { ) } - let fpusFiltered = self.provider.fpus() - .filter { $0.isFPU ?? false && $0.createdAt <= Date() } - .map { - Treatment( - units: units, - type: .fpus, - date: $0.createdAt, - amount: $0.carbs, - id: $0.id, - isFPU: $0.isFPU, - fpuID: $0.fpuID, - note: $0.note - ) - } - let boluses = self.provider.pumpHistory() .filter { $0.type == .bolus } .map { @@ -150,10 +134,6 @@ extension DataTable { self.treatments = [boluses, tempBasals, tempTargets, suspend, resume, carbs, fpus] .flatMap { $0 } .sorted { $0.date > $1.date } - self.filteredEntries = [boluses, tempBasals, tempTargets, suspend, resume, carbs, fpusFiltered] - .flatMap { $0 } - .sorted { $0.date > $1.date } - .filter { $0.date <= Date() } } else { self.treatments = [boluses, tempBasals, tempTargets, suspend, resume] .flatMap { $0 } @@ -161,10 +141,6 @@ extension DataTable { self.meals = [carbs, fpus] .flatMap { $0 } .sorted { $0.date > $1.date } - self.filteredEntries = [carbs, fpusFiltered] - .flatMap { $0 } - .sorted { $0.date > $1.date } - .filter { $0.date <= Date() } } } } diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index beaab01a07..a9c3155002 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -18,8 +18,6 @@ extension DataTable { @State private var removeGlucoseAlert: Alert? @State private var showManualGlucose: Bool = false @State private var showNonPumpInsulin: Bool = false - @State private var showFutureEntries: Bool = - true // false TODO: fix filtering of future entries OR rework treatment for to show MEALS not carbs + FPU @Environment(\.colorScheme) var colorScheme @@ -92,11 +90,6 @@ extension DataTable { .frame(width: 24, height: 24) } } - /* - if state.mode == .meals, !state.isCombinedTreatments { - filterFutureEntriesButton - } - */ if state.mode == .glucose && !showManualGlucose { Button(action: { showManualGlucose = true }) { Text("Glucose") @@ -221,47 +214,36 @@ extension DataTable { } } - private var filterFutureEntriesButton: some View { - VStack { - Button(action: { showFutureEntries.toggle() }, label: { - HStack { - Text(showFutureEntries ? "Hide Future Entries" : "Show Future Entries") - .foregroundColor(colorScheme == .dark ? Color.white : Color.black) - .font(.caption) - Image(systemName: showFutureEntries ? "calendar.badge.minus" : "calendar.badge.plus") - .resizable() - .frame(width: 18, height: 18) - .foregroundColor(colorScheme == .dark ? Color.white : Color.black) - }.frame(maxWidth: .infinity, alignment: .center) - }).buttonStyle(.bordered) - - Spacer() - } - } - private var historyContentView: some View { Form { - Section( - // header: state.isCombinedTreatments && state.mode == .treatments ? filterFutureEntriesButton : nil - ) { - // populate the list - if state.isCombinedTreatments { - switch state.mode { - case .treatments: combinedTreatmentsList - case .meals: EmptyView() - case .glucose: glucoseList - } - } else { - switch state.mode { - case .treatments: treatmentsList - case .meals: mealsList - case .glucose: glucoseList - } + if state.isCombinedTreatments { + switch state.mode { + case .treatments: combinedTreatmentsList + case .meals: EmptyView() + case .glucose: glucoseList + } + } else { + switch state.mode { + case .treatments: treatmentsList + case .meals: mealsList + case .glucose: glucoseList } } } } + private var combinedTreatmentsList: some View { + List { + ForEach(state.treatments) { treatment in + combinedTreatmentView(treatment) + } + .onDelete(perform: deleteTreatmentForCombined) + } + .alert(isPresented: $isRemoveCombinedTreatmentAlertPresented) { + removeCombinedTreatmentAlert! + } + } + private var treatmentsList: some View { List { if !state.treatments.isEmpty { @@ -280,54 +262,13 @@ extension DataTable { } } - private var combinedTreatmentsList: some View { - List { - ForEach(!showFutureEntries ? state.filteredEntries : state.treatments) { treatment in - combinedTreatmentView(treatment) - } - .onDelete(perform: deleteTreatmentForCombined) - /* - if !showFutureEntries { - // use filteredEntries here -> filtered in StateModel - - /* - ForEach(state.filteredEntries.filter { treatment in - treatment.date <= Date() - }, id: \.self) { treatment in - combinedTreatmentView(treatment) - } - .onDelete(perform: deleteTreatmentForCombined) - */ - } else { - ForEach(state.treatments) { treatment in - combinedTreatmentView(treatment) - } - .onDelete(perform: deleteTreatmentForCombined) - } - */ - } - .alert(isPresented: $isRemoveCombinedTreatmentAlertPresented) { - removeCombinedTreatmentAlert! - } - } - private var mealsList: some View { List { if !state.meals.isEmpty { - if !showFutureEntries { - ForEach(state.meals.filter { meal in - meal.date <= Date() - }) { meal in - - mealView(meal) - } - .onDelete(perform: deleteMeal) - } else { - ForEach(state.meals) { item in - mealView(item) - } - .onDelete(perform: deleteMeal) + ForEach(state.meals) { item in + mealView(item) } + .onDelete(perform: deleteMeal) } else { HStack { Text("No data.") @@ -440,7 +381,7 @@ extension DataTable { private func deleteMeal(at offsets: IndexSet) { let meal = state.meals[offsets[offsets.startIndex]] - var alertTitle = Text("Delete carbs?") + var alertTitle = Text("Delete Carbs?") var alertMessage = Text(meal.amountText) if meal.type == .fpus { From a2bbab8c540da85137ea699d9791421e7ce07678 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Fri, 6 Oct 2023 23:55:25 +0200 Subject: [PATCH 30/61] Add EN localization strings; change edited localization keys --- .../Main/ar.lproj/Localizable.strings | 4 +- .../Main/ca.lproj/Localizable.strings | 4 +- .../Main/da.lproj/Localizable.strings | 4 +- .../Main/de.lproj/Localizable.strings | 4 +- .../Main/en.lproj/Localizable.strings | 35 +++++++++++- .../Main/es.lproj/Localizable.strings | 4 +- .../Main/fi.lproj/Localizable.strings | 4 +- .../Main/fr.lproj/Localizable.strings | 4 +- .../Main/he.lproj/Localizable.strings | 4 +- .../Main/it.lproj/Localizable.strings | 4 +- .../Main/nb.lproj/Localizable.strings | 4 +- .../Main/nl.lproj/Localizable.strings | 4 +- .../Main/pl.lproj/Localizable.strings | 4 +- .../Main/pt-BR.lproj/Localizable.strings | 4 +- .../Main/pt-PT.lproj/Localizable.strings | 4 +- .../Main/ru.lproj/Localizable.strings | 4 +- .../Main/sk.lproj/Localizable.strings | 4 +- .../Main/sv.lproj/Localizable.strings | 4 +- .../Main/tr.lproj/Localizable.strings | 4 +- .../Main/uk.lproj/Localizable.strings | 4 +- .../Main/zh-Hans.lproj/Localizable.strings | 4 +- .../DataTable/View/DataTableRootView.swift | 55 ++++++++++--------- 22 files changed, 103 insertions(+), 67 deletions(-) diff --git a/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings index 0e38b4165c..de2b97aa12 100644 --- a/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/ca.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/ca.lproj/Localizable.strings index 617a1f967f..6e44f9dd94 100644 --- a/FreeAPS/Sources/Localizations/Main/ca.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/ca.lproj/Localizable.strings @@ -490,10 +490,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings index befd2ee618..42e6a12c24 100644 --- a/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings index d974432b07..142f4892ce 100644 --- a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temporäre Ziele"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Kohlenhydrate löschen?"; +"Delete Carbs?" = "Kohlenhydrate löschen?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Insulin löschen?"; +"Delete Insulin?" = "Insulin löschen?"; /* Treatments list */ "Treatments" = "Behandlungen"; diff --git a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings index f2d228b7a1..6d43ff914a 100644 --- a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings @@ -498,20 +498,48 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; + +/* Delete fpus alert title */ +"Delete Carb Equivalents?" = "Delete Carb Equivalents?"; + +/* Delete Glucose alert title */ +"Delete Glucose?" = "Delete Glucose?"; /* Treatments list */ "Treatments" = "Treatments"; +/* Meals list */ +"Meals" = "Meals"; + +/* No data text when no entries in history list */ +"No data." = "No data."; + /* " min" in Treatments list */ " min" = " min"; /* */ "Unable to change anything" = "Unable to change anything"; +/* Non-pump insulin maxBolus * 3 alert text */ +"**⚠️ Warning!** The entered insulin amount is greater than your Max Bolus setting!" = "**⚠️ Warning!** The entered insulin amount is greater than your Max Bolus setting!"; + +/* Log non-pump insulin button text */ +"Log non-pump insulin" = "Log non-pump insulin"; + +/* Non-Pump Insulin button text */ +"Non-Pump Insulin" = "Non-Pump Insulin"; + +/* Glucose button text */ +"Glucose" = "Glucose"; + +/* Add glucose dialog title */ +"Add Glucose" = "Add Glucose"; + + /* Calendar and Libre transmitter settings --------------- */ @@ -1541,6 +1569,9 @@ Enact a temp Basal or a temp target */ /* In Range */ "In Range" = "In Range"; +/* Display treatment history with 2 tabs (treatments+glucose) or 3 tabs (treatments split in insulin and meals + glucose) */ +"Combine Treatments in History" = "Combine Treatments in History"; + /* Display % */ "Change HbA1c Unit" = "Change HbA1c Unit"; diff --git a/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings index c9f3996654..c7e290f0ea 100644 --- a/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "¿Eliminar carbohidratos?"; +"Delete Carbs?" = "¿Eliminar carbohidratos?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Tratamientos"; diff --git a/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings index f97ffee40b..3f2cd5acbf 100644 --- a/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings index 7ebc10fdb9..683edfdadb 100644 --- a/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Cibles temporaires"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Supprimer les glucides ?"; +"Delete Carbs?" = "Supprimer les glucides ?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Traitements"; diff --git a/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings index 0e38b4165c..de2b97aa12 100644 --- a/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings index 32689f4342..b4a51d6bb6 100644 --- a/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Obiettivi Temporanei"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Cancella carboidrati?"; +"Delete Carbs?" = "Cancella carboidrati?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Cancella l'insulina?"; +"Delete Insulin?" = "Cancella l'insulina?"; /* Treatments list */ "Treatments" = "Trattamenti"; diff --git a/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings index 7a579b92bd..dc2582e67c 100644 --- a/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Midlertidige mål"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Slette karbohydrater?"; +"Delete Carbs?" = "Slette karbohydrater?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Slette insulin?"; +"Delete Insulin?" = "Slette insulin?"; /* Treatments list */ "Treatments" = "Behandlinger"; diff --git a/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings index 299410814e..48d5599b18 100644 --- a/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Tijdelijk streefdoel"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Koolhydraten verwijderen?"; +"Delete Carbs?" = "Koolhydraten verwijderen?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Insuline verwijderen?"; +"Delete Insulin?" = "Insuline verwijderen?"; /* Treatments list */ "Treatments" = "Behandelingen"; diff --git a/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings index 0e7014406f..cbb138f7df 100644 --- a/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings @@ -500,10 +500,10 @@ Połączono z Nightscout!"; "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings index 5d2b50df0f..a7b2817940 100644 --- a/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Alvos Temporários"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Deletar carboidratos?"; +"Delete Carbs?" = "Deletar carboidratos?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Tratamentos"; diff --git a/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings index 603e3e2261..801a38c225 100644 --- a/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings index be36b12b1d..094436ac40 100644 --- a/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Временные цели"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Удалить углеводы?"; +"Delete Carbs?" = "Удалить углеводы?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Удалить инсулин?"; +"Delete Insulin?" = "Удалить инсулин?"; /* Treatments list */ "Treatments" = "События"; diff --git a/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings index 65fe95c5c3..86bbf52b71 100644 --- a/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Temp Targets"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Delete carbs?"; +"Delete Carbs?" = "Delete Carbs?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "Treatments"; diff --git a/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings index fd3cef0d0a..f5c4ddb3e5 100644 --- a/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Målvärden"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Ta bort kolhydrater?"; +"Delete Carbs?" = "Ta bort kolhydrater?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Ta bort insulin?"; +"Delete Insulin?" = "Ta bort insulin?"; /* Treatments list */ "Treatments" = "Behandlingar"; diff --git a/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings index 8411e89bbd..874c18513e 100644 --- a/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Geçici Hedefler"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Karbonhidratları sil?"; +"Delete Carbs?" = "Karbonhidratları sil?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "İnsülin silinsin mi?"; +"Delete Insulin?" = "İnsülin silinsin mi?"; /* Treatments list */ "Treatments" = "Tedaviler"; diff --git a/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings index 16034cb209..4f90a9f932 100644 --- a/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "Тимчасові цілі"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "Видалити вуглеводи?"; +"Delete Carbs?" = "Видалити вуглеводи?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Видалити інсулін?"; +"Delete Insulin?" = "Видалити інсулін?"; /* Treatments list */ "Treatments" = "Події"; diff --git a/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings index 6b9394d9f7..87a5ec427d 100644 --- a/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings @@ -498,10 +498,10 @@ Enact a temp Basal or a temp target */ "Temp Targets" = "临时目标"; /* Delete carbs from data table and Nightscout */ -"Delete carbs?" = "删除碳水?"; +"Delete Carbs?" = "删除碳水?"; /* Delete insulin from pump history and Nightscout */ -"Delete insulin?" = "Delete insulin?"; +"Delete Insulin?" = "Delete Insulin?"; /* Treatments list */ "Treatments" = "治疗"; diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index a9c3155002..c09c44ec41 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -84,7 +84,7 @@ extension DataTable { trailing: HStack { if state.mode == .treatments && !showNonPumpInsulin { Button(action: { showNonPumpInsulin = true }) { - Text("Non-Pump Insulin") + Text(NSLocalizedString("Non-Pump Insulin", comment: "Non-Pump Insulin button text")) Image(systemName: "plus.circle.fill") .resizable() .frame(width: 24, height: 24) @@ -92,7 +92,7 @@ extension DataTable { } if state.mode == .glucose && !showManualGlucose { Button(action: { showManualGlucose = true }) { - Text("Glucose") + Text(NSLocalizedString("Glucose", comment: "Glucose button text")) Image(systemName: "plus.circle.fill") .resizable() .frame(width: 24, height: 24) @@ -159,7 +159,7 @@ extension DataTable { Form { Section { HStack { - Text("Amount") + Text(NSLocalizedString("Amount", comment: "")) Spacer() DecimalTextField( "0", @@ -185,19 +185,24 @@ extension DataTable { state.addNonPumpInsulin() showNonPumpInsulin = false } - label: { Text("Log non-pump insulin") } - .foregroundColor(amountWarningCondition ? Color.white : Color.accentColor) - .frame(maxWidth: .infinity, alignment: .center) - .disabled( - state.nonPumpInsulinAmount <= 0 || state.nonPumpInsulinAmount > state - .maxBolus * 3 - ) + label: { + Text(NSLocalizedString("Log non-pump insulin", comment: "Log non-pump insulin button text")) + } + .foregroundColor(amountWarningCondition ? Color.white : Color.accentColor) + .frame(maxWidth: .infinity, alignment: .center) + .disabled( + state.nonPumpInsulinAmount <= 0 || state.nonPumpInsulinAmount > state + .maxBolus * 3 + ) } } header: { if amountWarningCondition { - Text("**⚠️ Warning!** The entered insulin amount is greater than your Max Bolus setting!") + Text(NSLocalizedString( + "**⚠️ Warning!** The entered insulin amount is greater than your Max Bolus setting!", + comment: "Non-pump insulin maxBolus * 3 alert text" + )) } } .listRowBackground( @@ -253,7 +258,7 @@ extension DataTable { .onDelete(perform: deleteTreatment) } else { HStack { - Text("No data.") + Text(NSLocalizedString("No data.", comment: "No data text when no entries in history list")) } } } @@ -271,7 +276,7 @@ extension DataTable { .onDelete(perform: deleteMeal) } else { HStack { - Text("No data.") + Text(NSLocalizedString("No data.", comment: "No data text when no entries in history list")) } } } @@ -289,7 +294,7 @@ extension DataTable { .onDelete(perform: deleteGlucose) } else { HStack { - Text("No data.") + Text(NSLocalizedString("No data.", comment: "No data text when no entries in history list")) } } } @@ -367,7 +372,7 @@ extension DataTable { let treatment = state.treatments[offsets[offsets.startIndex]] removeInsulinAlert = Alert( - title: Text("Delete Insulin?"), + title: Text(NSLocalizedString("Delete Insulin?", comment: "Delete insulin from pump history and Nightscout")), message: Text(treatment.amountText), primaryButton: .destructive( Text("Delete"), @@ -381,8 +386,8 @@ extension DataTable { private func deleteMeal(at offsets: IndexSet) { let meal = state.meals[offsets[offsets.startIndex]] - var alertTitle = Text("Delete Carbs?") - var alertMessage = Text(meal.amountText) + var alertTitle = NSLocalizedString("Delete Carbs?", comment: "Delete carbs from data table and Nightscout") + var alertMessage = meal.amountText if meal.type == .fpus { let fpus = state.meals @@ -395,13 +400,13 @@ extension DataTable { .reduce(0, +) ) as NSNumber)! - alertTitle = Text("Delete Carb Equivalents?") - alertMessage = Text(carbEquivalents + NSLocalizedString(" g", comment: "gram of carbs")) + alertTitle = NSLocalizedString("Delete Carb Equivalents?", comment: "Delte fpus alert title") + alertMessage = carbEquivalents + NSLocalizedString(" g", comment: "gram of carbs") } removeCarbsAlert = Alert( - title: alertTitle, - message: alertMessage, + title: Text(alertTitle), + message: Text(alertMessage), primaryButton: .destructive( Text("Delete"), action: { state.deleteCarbs(meal) } @@ -429,12 +434,12 @@ extension DataTable { .reduce(0, +) ) as NSNumber)! - alertTitle = "Delete Carb Equivalents?" + alertTitle = NSLocalizedString("Delete Carb Equivalents?", comment: "Delete fpus alert title") alertMessage = carbEquivalents + NSLocalizedString(" g", comment: "gram of carbs") } if treatment.type == .carbs { - alertTitle = "Delete Carbs?" + alertTitle = NSLocalizedString("Delete Carbs?", comment: "Delete carbs from data table and Nightscout") alertMessage = treatment.amountText } @@ -450,7 +455,7 @@ extension DataTable { } else { // treatment is .bolus - alertTitle = "Delete Insulin?" + alertTitle = NSLocalizedString("Delete Insulin?", comment: "Delete insulin from pump history and Nightscout") alertMessage = treatment.amountText removeCombinedTreatmentAlert = Alert( @@ -474,7 +479,7 @@ extension DataTable { ) as NSNumber)! + " " + state.units.rawValue removeGlucoseAlert = Alert( - title: Text("Delete Glucose?"), + title: Text(NSLocalizedString("Delete Glucose?", comment: "Delete Glucose alert title")), message: Text(glucoseValue), primaryButton: .destructive( Text("Delete"), From 9ff112e643d35ad0b85ab19a638a62578bb8ad22 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sun, 8 Oct 2023 14:09:40 +0200 Subject: [PATCH 31/61] Fix issue where amount in modal was not reset on dismiss --- .../Modules/DataTable/View/DataTableRootView.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index c09c44ec41..ea1ea6e974 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -82,7 +82,7 @@ extension DataTable { .navigationBarItems( leading: Button("Close", action: state.hideModal), trailing: HStack { - if state.mode == .treatments && !showNonPumpInsulin { + if state.mode == .treatments { Button(action: { showNonPumpInsulin = true }) { Text(NSLocalizedString("Non-Pump Insulin", comment: "Non-Pump Insulin button text")) Image(systemName: "plus.circle.fill") @@ -90,7 +90,7 @@ extension DataTable { .frame(width: 24, height: 24) } } - if state.mode == .glucose && !showManualGlucose { + if state.mode == .glucose { Button(action: { showManualGlucose = true }) { Text(NSLocalizedString("Glucose", comment: "Glucose button text")) Image(systemName: "plus.circle.fill") @@ -100,10 +100,10 @@ extension DataTable { } } ) - .sheet(isPresented: $showManualGlucose) { + .sheet(isPresented: $showManualGlucose, onDismiss: { state.manualGlucose = 0 }) { addManualGlucoseView } - .sheet(isPresented: $showNonPumpInsulin) { + .sheet(isPresented: $showNonPumpInsulin, onDismiss: { state.nonPumpInsulinAmount = 0 }) { addNonPumpInsulinView } } From e510eb306ba201606f319b61838fc3e7bebc8864 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Mon, 9 Oct 2023 22:20:38 +0200 Subject: [PATCH 32/61] Fix previous fix with isAmountUnconfirmed condition check --- .../Sources/Modules/DataTable/View/DataTableRootView.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index ea1ea6e974..330854b7e6 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -18,6 +18,7 @@ extension DataTable { @State private var removeGlucoseAlert: Alert? @State private var showManualGlucose: Bool = false @State private var showNonPumpInsulin: Bool = false + @State private var isAmountUnconfirmed: Bool = true @Environment(\.colorScheme) var colorScheme @@ -100,10 +101,10 @@ extension DataTable { } } ) - .sheet(isPresented: $showManualGlucose, onDismiss: { state.manualGlucose = 0 }) { + .sheet(isPresented: $showManualGlucose, onDismiss: { if isAmountUnconfirmed { state.manualGlucose = 0 } }) { addManualGlucoseView } - .sheet(isPresented: $showNonPumpInsulin, onDismiss: { state.nonPumpInsulinAmount = 0 }) { + .sheet(isPresented: $showNonPumpInsulin, onDismiss: { if isAmountUnconfirmed { state.nonPumpInsulinAmount = 0 } }) { addNonPumpInsulinView } } @@ -136,6 +137,7 @@ extension DataTable { Button { state.addManualGlucose() + isAmountUnconfirmed = false showManualGlucose = false } label: { Text("Save") } @@ -183,6 +185,7 @@ extension DataTable { HStack { Button { state.addNonPumpInsulin() + isAmountUnconfirmed = false showNonPumpInsulin = false } label: { From c7b88adfabbd2dff05df61adaa9be51999b0559e Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sat, 14 Oct 2023 20:59:02 +0200 Subject: [PATCH 33/61] * Changed non-pump insulin and manual glucose button style and position * Change setting placement: add new section and more descriptive text for history setting --- .../DataTable/View/DataTableRootView.swift | 139 +++++++++++------- .../StatConfig/View/StatConfigRootView.swift | 12 +- 2 files changed, 97 insertions(+), 54 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 330854b7e6..76f7db65af 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -67,8 +67,13 @@ extension DataTable { } } else { ForEach(Mode.allCases.indexed(), id: \.1) { index, item in - Text(item.name) - .tag(index) + if item == .treatments { + Text("Insulin") + .tag(index) + } else { + Text(item.name) + .tag(index) + } } } } @@ -81,25 +86,25 @@ extension DataTable { .navigationTitle("History") .navigationBarTitleDisplayMode(.automatic) .navigationBarItems( - leading: Button("Close", action: state.hideModal), - trailing: HStack { - if state.mode == .treatments { - Button(action: { showNonPumpInsulin = true }) { - Text(NSLocalizedString("Non-Pump Insulin", comment: "Non-Pump Insulin button text")) - Image(systemName: "plus.circle.fill") - .resizable() - .frame(width: 24, height: 24) - } - } - if state.mode == .glucose { - Button(action: { showManualGlucose = true }) { - Text(NSLocalizedString("Glucose", comment: "Glucose button text")) - Image(systemName: "plus.circle.fill") - .resizable() - .frame(width: 24, height: 24) - } - } - } + leading: Button("Close", action: state.hideModal) +// trailing: HStack { +// if state.mode == .treatments { +// Button(action: { showNonPumpInsulin = true }) { +// Text(NSLocalizedString("Non-Pump Insulin", comment: "Non-Pump Insulin button text")) +// Image(systemName: "plus.circle.fill") +// .resizable() +// .frame(width: 24, height: 24) +// } +// } +// if state.mode == .glucose { +// Button(action: { showManualGlucose = true }) { +// Text(NSLocalizedString("Glucose", comment: "Glucose button text")) +// Image(systemName: "plus.circle.fill") +// .resizable() +// .frame(width: 24, height: 24) +// } +// } +// } ) .sheet(isPresented: $showManualGlucose, onDismiss: { if isAmountUnconfirmed { state.manualGlucose = 0 } }) { addManualGlucoseView @@ -240,33 +245,57 @@ extension DataTable { } } + private func dialogActionButton(action _: @escaping () -> Void) -> some View { + VStack { + Spacer() + Button(action: { showNonPumpInsulin = true }, label: { + HStack { + Image(systemName: "plus.circle.fill") + .resizable() + .frame(width: 26, height: 26) + .foregroundColor(Color.gray).opacity(0.8) + }.frame(maxWidth: .infinity, alignment: .trailing) + + }) + Spacer() + } + } + private var combinedTreatmentsList: some View { - List { - ForEach(state.treatments) { treatment in - combinedTreatmentView(treatment) + Section( + header: dialogActionButton(action: { showNonPumpInsulin = true }) + ) { + List { + ForEach(state.treatments) { treatment in + combinedTreatmentView(treatment) + } + .onDelete(perform: deleteTreatmentForCombined) + } + .alert(isPresented: $isRemoveCombinedTreatmentAlertPresented) { + removeCombinedTreatmentAlert! } - .onDelete(perform: deleteTreatmentForCombined) - } - .alert(isPresented: $isRemoveCombinedTreatmentAlertPresented) { - removeCombinedTreatmentAlert! } } private var treatmentsList: some View { - List { - if !state.treatments.isEmpty { - ForEach(state.treatments) { item in - treatmentView(item) - } - .onDelete(perform: deleteTreatment) - } else { - HStack { - Text(NSLocalizedString("No data.", comment: "No data text when no entries in history list")) + Section( + header: dialogActionButton(action: { showNonPumpInsulin = true }) + ) { + List { + if !state.treatments.isEmpty { + ForEach(state.treatments) { item in + treatmentView(item) + } + .onDelete(perform: deleteTreatment) + } else { + HStack { + Text(NSLocalizedString("No data.", comment: "No data text when no entries in history list")) + } } } - } - .alert(isPresented: $isRemoveInsulinAlertPresented) { - removeInsulinAlert! + .alert(isPresented: $isRemoveInsulinAlertPresented) { + removeInsulinAlert! + } } } @@ -289,20 +318,24 @@ extension DataTable { } private var glucoseList: some View { - List { - if !state.glucose.isEmpty { - ForEach(state.glucose) { item in - glucoseView(item) - } - .onDelete(perform: deleteGlucose) - } else { - HStack { - Text(NSLocalizedString("No data.", comment: "No data text when no entries in history list")) + Section( + header: dialogActionButton(action: { showManualGlucose = true }) + ) { + List { + if !state.glucose.isEmpty { + ForEach(state.glucose) { item in + glucoseView(item) + } + .onDelete(perform: deleteGlucose) + } else { + HStack { + Text(NSLocalizedString("No data.", comment: "No data text when no entries in history list")) + } } } - } - .alert(isPresented: $isRemoveGlucoseAlertPresented) { - removeGlucoseAlert! + .alert(isPresented: $isRemoveGlucoseAlertPresented) { + removeGlucoseAlert! + } } } @@ -403,7 +436,7 @@ extension DataTable { .reduce(0, +) ) as NSNumber)! - alertTitle = NSLocalizedString("Delete Carb Equivalents?", comment: "Delte fpus alert title") + alertTitle = NSLocalizedString("Delete Carb Equivalents?", comment: "Delete fpus alert title") alertMessage = carbEquivalents + NSLocalizedString(" g", comment: "gram of carbs") } diff --git a/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift b/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift index ac20eba434..f8b39131ad 100644 --- a/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift +++ b/FreeAPS/Sources/Modules/StatConfig/View/StatConfigRootView.swift @@ -27,7 +27,6 @@ extension StatConfig { var body: some View { Form { Section(header: Text("Settings")) { - Toggle("Combine Treatments in History", isOn: $state.combineTreatmentsHistory) Toggle("Change HbA1c Unit", isOn: $state.overrideHbA1cUnit) Toggle("Display Chart X - Grid lines", isOn: $state.xGridLines) Toggle("Display Chart Y - Grid lines", isOn: $state.yGridLines) @@ -55,6 +54,17 @@ extension StatConfig { Text(state.units.rawValue).foregroundColor(.secondary) } } + + Section( + header: Text("History View"), + footer: Text( + "By default, the History View shows insulin, meals, and glucose in separate tabs. Toggle on \"Combine Treatments in History\" to display insulin and meals together under a single tab." + ) + .font(.caption) + .foregroundColor(Color.secondary) + ) { + Toggle("Combine Treatments in History", isOn: $state.combineTreatmentsHistory) + } } .onAppear(perform: configureView) .navigationBarTitle("Statistics") From 16cbb2fe2a24d4990df52e6923b0009c9b917537 Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sat, 14 Oct 2023 21:04:20 +0200 Subject: [PATCH 34/61] Fix faulty button wrapper function argument --- .../Sources/Modules/DataTable/View/DataTableRootView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index 76f7db65af..d22fd592a1 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -245,10 +245,10 @@ extension DataTable { } } - private func dialogActionButton(action _: @escaping () -> Void) -> some View { + private func dialogActionButton(action: @escaping () -> Void) -> some View { VStack { Spacer() - Button(action: { showNonPumpInsulin = true }, label: { + Button(action: action, label: { HStack { Image(systemName: "plus.circle.fill") .resizable() From 3cda9efe2d2d693580727bf35a120461d1fdb31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:21 +0200 Subject: [PATCH 35/61] New translations localizable.strings (Dutch) --- .../Sources/Localizations/Main/nl.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings index c1a7fb7107..b153d2473c 100644 --- a/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Kan Nightscout profiel niet vinden."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Medtronic toevoegen"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS is niet actief!"; /* */ -"Last loop was more then %d min ago" = "Laatste loop was meer dan %d min geleden"; +"Last loop was more than %d min ago" = "Laatste loop was meer dan %d min geleden"; /* Glucose badge */ "Show glucose on the app badge" = "Toon glucosewaarde op de app icoon"; From fb670322d2cbeb52f1d5c36b47641dfd699a5eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:22 +0200 Subject: [PATCH 36/61] New translations localizable.strings (French) --- .../Sources/Localizations/Main/fr.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings index 8e8490bfeb..8ecc9dcb13 100644 --- a/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/fr.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Ajouter une pompe Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS pas actif"; /* */ -"Last loop was more then %d min ago" = "Dernier bouclage depuis plus de %d min"; +"Last loop was more than %d min ago" = "Dernier bouclage depuis plus de %d min"; /* Glucose badge */ "Show glucose on the app badge" = "Afficher glycémie en tant que badge"; From 30a57f8444be15ef1b233d05460ee260e04b846a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:23 +0200 Subject: [PATCH 37/61] New translations localizable.strings (Spanish) --- .../Sources/Localizations/Main/es.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings index 65fa811e6d..4c33b986fe 100644 --- a/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/es.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Añadir Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From 81121acedf518af1a766e3cac57b16b54469255d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:24 +0200 Subject: [PATCH 38/61] New translations localizable.strings (Arabic) --- .../Sources/Localizations/Main/ar.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings index daf5e9c1f0..c96f3f8406 100644 --- a/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/ar.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Add Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From ccebbce8f5df1929ff9fc03c85a70a01863d7170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:25 +0200 Subject: [PATCH 39/61] New translations localizable.strings (Danish) --- .../Sources/Localizations/Main/da.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings index 24fe70b286..3649d64403 100644 --- a/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/da.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Tilføj Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From 895f2f01beeea5359cae7a6d25c2afdd98fed51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:26 +0200 Subject: [PATCH 40/61] New translations localizable.strings (German) --- .../Sources/Localizations/Main/de.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings index 8f1d65b69f..c64bac88bb 100644 --- a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Medtronic-Pumpe hinzufügen"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS ist nicht aktiv"; /* */ -"Last loop was more then %d min ago" = "Letzter Loop vor mehr als %d Minuten"; +"Last loop was more than %d min ago" = "Letzter Loop vor mehr als %d Minuten"; /* Glucose badge */ "Show glucose on the app badge" = "Zeige Glucosewert auf dem App Symbol"; From d9440be351a71b3c8be59aac007df993798a7501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:28 +0200 Subject: [PATCH 41/61] New translations localizable.strings (Finnish) --- .../Sources/Localizations/Main/fi.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings index b34ab36792..70c9d5b995 100644 --- a/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/fi.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Add Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From 2795ce7d3f948e622e516b6341b01c096a828266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:29 +0200 Subject: [PATCH 42/61] New translations localizable.strings (Hebrew) --- .../Sources/Localizations/Main/he.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings index daf5e9c1f0..c96f3f8406 100644 --- a/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/he.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Add Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From b7f2bba52f8636c9ce71902c33799a3288be3876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:30 +0200 Subject: [PATCH 43/61] New translations localizable.strings (Italian) --- .../Sources/Localizations/Main/it.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings index 55635b473b..65092af189 100644 --- a/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/it.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Aggiungi microinfusore Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS non attivo"; /* */ -"Last loop was more then %d min ago" = "L'ultimo ciclo è stato più di %d min fa"; +"Last loop was more than %d min ago" = "L'ultimo ciclo è stato più di %d min fa"; /* Glucose badge */ "Show glucose on the app badge" = "Mostra il glicemie sul badge dell'app"; From dc57a921d6fca845c829e5ccaf37d8d138c0d0e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:31 +0200 Subject: [PATCH 44/61] New translations localizable.strings (Polish) --- .../Sources/Localizations/Main/pl.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings index cc8f68a061..9ce06bcdf2 100644 --- a/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/pl.lproj/Localizable.strings @@ -352,6 +352,9 @@ Połączono z Nightscout!"; /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Add Medtronic"; @@ -989,7 +992,7 @@ Połączono z Nightscout!"; "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From 4074d34dd84ad0a247070da7b5e56af24dfdda23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:32 +0200 Subject: [PATCH 45/61] New translations localizable.strings (Portuguese) --- .../Localizations/Main/pt-PT.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings index c115dbd101..26e055217c 100644 --- a/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/pt-PT.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Adicionar Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From bc15348628b4f12c7a881d17236cc3806276bc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:33 +0200 Subject: [PATCH 46/61] New translations localizable.strings (Russian) --- .../Sources/Localizations/Main/ru.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings index 3f6d123e4b..bba6524a0b 100644 --- a/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Не удается найти профиль Nightscout по умолчанию."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Добавить Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS неактивен"; /* */ -"Last loop was more then %d min ago" = "Последний цикл был более %d минут назад"; +"Last loop was more than %d min ago" = "Последний цикл был более %d минут назад"; /* Glucose badge */ "Show glucose on the app badge" = "Показывать глюкозу на значке приложения"; From c5a14ba3cecb0e33ec1cb0032fea0bf9e819b726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:34 +0200 Subject: [PATCH 47/61] New translations localizable.strings (Slovak) --- .../Sources/Localizations/Main/sk.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings index 54fc1f76f6..e2af781755 100644 --- a/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/sk.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Add Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From 8ed6e8c7c29c38760ed72dd4bfddce226eacaf74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:35 +0200 Subject: [PATCH 48/61] New translations localizable.strings (Swedish) --- .../Sources/Localizations/Main/sv.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings index 65df7d82c2..e8e6b52a96 100644 --- a/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Kan inte hitta en profil i Nightcsout"; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blodsockerprov"; + /* Add Medtronic pump */ "Add Medtronic" = "Lägg till Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS är inte aktiv"; /* */ -"Last loop was more then %d min ago" = "Senaste loopen var mer än %d min sedan"; +"Last loop was more than %d min ago" = "Senaste loop var för mer än %d min sedan"; /* Glucose badge */ "Show glucose on the app badge" = "Visa glukosvärde på app-ikon"; From eb5457966785ec46cb9a6e56ee897acfb31dea2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:36 +0200 Subject: [PATCH 49/61] New translations localizable.strings (Turkish) --- .../Sources/Localizations/Main/tr.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings index 1d73a4d269..b7b15c1cd5 100644 --- a/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/tr.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Medtronic Pompa ekle"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS etkin değil"; /* */ -"Last loop was more then %d min ago" = "Son döngü %d dak kadar önceydi"; +"Last loop was more than %d min ago" = "Son döngü %d dak kadar önceydi"; /* Glucose badge */ "Show glucose on the app badge" = "Uygulama rozetinde glikozu göster"; From af434e9ee169c3d29e577b89899940e8c198f992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:38 +0200 Subject: [PATCH 50/61] New translations localizable.strings (Ukrainian) --- .../Sources/Localizations/Main/uk.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings index ddeb24aaa3..44e32e8801 100644 --- a/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/uk.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Не вдається знайти профіль Nightscout за замовчуванням."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Додати Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS не активний"; /* */ -"Last loop was more then %d min ago" = "Останній цикл був більше, ніж %d хв тому"; +"Last loop was more than %d min ago" = "Останній цикл був більше, ніж %d хв тому"; /* Glucose badge */ "Show glucose on the app badge" = "Показувати глюкозу на значку додатку"; From 7340e62b04b34bc6de21a11e22985ae5e9474a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:39 +0200 Subject: [PATCH 51/61] New translations localizable.strings (Chinese Simplified) --- .../Localizations/Main/zh-Hans.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings index ce451e52aa..e731371bcc 100644 --- a/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/zh-Hans.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "添加美敦力泵"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS 未激活"; /* */ -"Last loop was more then %d min ago" = "上次闭环成功在 %d 分钟前"; +"Last loop was more than %d min ago" = "上次闭环成功在 %d 分钟前"; /* Glucose badge */ "Show glucose on the app badge" = "在应用图表上显示葡萄糖。"; From fd7141add643788e9753c79ea282e1a4ad6712e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:40 +0200 Subject: [PATCH 52/61] New translations localizable.strings (Portuguese, Brazilian) --- .../Localizations/Main/pt-BR.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings index 72095619dc..354d643043 100644 --- a/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/pt-BR.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Can't find the default Nightscout Profile."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Adicionar Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS not active"; /* */ -"Last loop was more then %d min ago" = "Last loop was more then %d min ago"; +"Last loop was more than %d min ago" = "Last loop was more than %d min ago"; /* Glucose badge */ "Show glucose on the app badge" = "Show glucose on the app badge"; From 72231c39f03690a27e9f552ada2a789cc67d3e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 01:55:41 +0200 Subject: [PATCH 53/61] New translations localizable.strings (Norwegian Bokmal) --- .../Sources/Localizations/Main/nb.lproj/Localizable.strings | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings index 7d6d7ed55b..029fdfe1b4 100644 --- a/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings @@ -350,6 +350,9 @@ Enact a temp Basal or a temp target */ /* Import Error */ "Can't find the default Nightscout Profile." = "Finner ikke standard profil i Nightscout."; +/* Add Blood Glucose Test, header */ +"Blood Glucose Test" = "Blood Glucose Test"; + /* Add Medtronic pump */ "Add Medtronic" = "Legge til Medtronic"; @@ -987,7 +990,7 @@ Enact a temp Basal or a temp target */ "iAPS not active" = "iAPS ikke aktiv"; /* */ -"Last loop was more then %d min ago" = "Siste loop var mer enn %d min siden"; +"Last loop was more than %d min ago" = "Siste loop var mer enn %d min siden"; /* Glucose badge */ "Show glucose on the app badge" = "Vis blodsukker på app-ikonet"; From cce037f66a256e0a7bb3cb1bb8862c3a981f13c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 12:46:48 +0200 Subject: [PATCH 54/61] New translations localizable.strings (Norwegian Bokmal) --- FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings index 029fdfe1b4..677ba08ab7 100644 --- a/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/nb.lproj/Localizable.strings @@ -351,7 +351,7 @@ Enact a temp Basal or a temp target */ "Can't find the default Nightscout Profile." = "Finner ikke standard profil i Nightscout."; /* Add Blood Glucose Test, header */ -"Blood Glucose Test" = "Blood Glucose Test"; +"Blood Glucose Test" = "Blodsukkermåling"; /* Add Medtronic pump */ "Add Medtronic" = "Legge til Medtronic"; From 7cd6130ec8a4df982a5fe6f6e70bcb96e51906c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 16:22:08 +0200 Subject: [PATCH 55/61] New translations localizable.strings (Dutch) --- FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings index b153d2473c..0525c489c3 100644 --- a/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/nl.lproj/Localizable.strings @@ -351,7 +351,7 @@ Enact a temp Basal or a temp target */ "Can't find the default Nightscout Profile." = "Kan Nightscout profiel niet vinden."; /* Add Blood Glucose Test, header */ -"Blood Glucose Test" = "Blood Glucose Test"; +"Blood Glucose Test" = "Bloedglucose test"; /* Add Medtronic pump */ "Add Medtronic" = "Medtronic toevoegen"; From ce6d7de71fce051198c5190f32ee0b7713f84095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:27:42 +0200 Subject: [PATCH 56/61] New translations localizable.strings (Russian) --- FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings index bba6524a0b..0c6cbc2533 100644 --- a/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/ru.lproj/Localizable.strings @@ -351,7 +351,7 @@ Enact a temp Basal or a temp target */ "Can't find the default Nightscout Profile." = "Не удается найти профиль Nightscout по умолчанию."; /* Add Blood Glucose Test, header */ -"Blood Glucose Test" = "Blood Glucose Test"; +"Blood Glucose Test" = "Тест на глюкозу в крови"; /* Add Medtronic pump */ "Add Medtronic" = "Добавить Medtronic"; From d11c091bcdefebbc62c6da468d360bd5307c3425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20B=20M=C3=A5rtensson?= <53905247+Jon-b-m@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:27:43 +0200 Subject: [PATCH 57/61] New translations localizable.strings (Russian) --- .../G7SensorKit/G7SensorKitUI/ru.lproj/Localizable.strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dependencies/G7SensorKit/G7SensorKitUI/ru.lproj/Localizable.strings b/Dependencies/G7SensorKit/G7SensorKitUI/ru.lproj/Localizable.strings index 585bf0bf08..1fca7ed023 100644 --- a/Dependencies/G7SensorKit/G7SensorKitUI/ru.lproj/Localizable.strings +++ b/Dependencies/G7SensorKit/G7SensorKitUI/ru.lproj/Localizable.strings @@ -99,7 +99,7 @@ "Sensor failed" = "Сбой датчика"; /* title for g7 settings row showing sensor start time */ -"Sensor Start" = "Start sensor"; +"Sensor Start" = "Запуск датчика"; /* G7 Status highlight text for signal loss */ "Signal\nLoss" = "Сигнал\nПотерян"; From 331ee475638b97d32830e4551eac40b232c47338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20M=C3=A5rtensson?= Date: Sun, 22 Oct 2023 00:21:03 +0200 Subject: [PATCH 58/61] Dexcom G7 SAGE Upload activation and session start date to NS. --- FreeAPS/Sources/APS/CGM/dexcomSourceG7.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/FreeAPS/Sources/APS/CGM/dexcomSourceG7.swift b/FreeAPS/Sources/APS/CGM/dexcomSourceG7.swift index 0d35538a7c..1b585ef217 100644 --- a/FreeAPS/Sources/APS/CGM/dexcomSourceG7.swift +++ b/FreeAPS/Sources/APS/CGM/dexcomSourceG7.swift @@ -135,6 +135,15 @@ extension DexcomSourceG7: CGMManagerDelegate { debug(.deviceManager, "DEXCOMG7 - Process CGM Reading Result launched") switch readingResult { case let .newData(values): + + var activationDate: Date = .distantPast + var sessionStart: Date = .distantPast + if let cgmG7Manager = cgmManager as? G7CGMManager { + activationDate = cgmG7Manager.sensorActivatedAt ?? .distantPast + sessionStart = cgmG7Manager.sensorFinishesWarmupAt ?? .distantPast + print("Activastion date: " + activationDate.description) + } + let bloodGlucose = values.compactMap { newGlucoseSample -> BloodGlucose? in let quantity = newGlucoseSample.quantity let value = Int(quantity.doubleValue(for: .milligramsPerDeciliter)) @@ -148,7 +157,9 @@ extension DexcomSourceG7: CGMManagerDelegate { filtered: nil, noise: nil, glucose: value, - type: "sgv" + type: "sgv", + activationDate: activationDate, + sessionStartDate: sessionStart ) } From 4a39fba4390b5e8e39eb45eda252cc753281f39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20M=C3=A5rtensson?= Date: Sun, 22 Oct 2023 12:20:37 +0200 Subject: [PATCH 59/61] Force push Profiles and settings when using button --- .../Modules/Settings/SettingsStateModel.swift | 6 +++--- .../Modules/Settings/View/SettingsRootView.swift | 2 +- .../Sources/Services/Network/NightscoutManager.swift | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift b/FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift index c36317b531..d2c8e4a8fe 100644 --- a/FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift +++ b/FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift @@ -46,13 +46,13 @@ extension Settings { return items } - func uploadProfileAndSettings() { + func uploadProfileAndSettings(_: Bool) { NSLog("SettingsState Upload Profile") - nightscoutManager.uploadProfileAndSettings() + nightscoutManager.uploadProfileAndSettings(true) } func hideSettingsModal() { - nightscoutManager.uploadProfileAndSettings() + nightscoutManager.uploadProfileAndSettings(false) hideModal() } } diff --git a/FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift b/FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift index 53bb3c63d0..4698551020 100644 --- a/FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift +++ b/FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift @@ -51,7 +51,7 @@ extension Settings { Group { HStack { Text("NS Upload Profile and Settings") - Button("Upload") { state.uploadProfileAndSettings() } + Button("Upload") { state.uploadProfileAndSettings(true) } .frame(maxWidth: .infinity, alignment: .trailing) .buttonStyle(.borderedProminent) } diff --git a/FreeAPS/Sources/Services/Network/NightscoutManager.swift b/FreeAPS/Sources/Services/Network/NightscoutManager.swift index 80ce54c582..c5267af953 100644 --- a/FreeAPS/Sources/Services/Network/NightscoutManager.swift +++ b/FreeAPS/Sources/Services/Network/NightscoutManager.swift @@ -17,7 +17,7 @@ protocol NightscoutManager: GlucoseSource { func uploadManualGlucose() func uploadStatistics(dailystat: Statistics) func uploadPreferences(_ preferences: Preferences) - func uploadProfileAndSettings() + func uploadProfileAndSettings(_: Bool) var cgmURL: URL? { get } } @@ -445,7 +445,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable { } } - func uploadProfileAndSettings() { + func uploadProfileAndSettings(_ force: Bool) { // These should be modified anyways and not the defaults guard let sensitivities = storage.retrieve(OpenAPS.Settings.insulinSensitivities, as: InsulinSensitivities.self), let basalProfile = storage.retrieve(OpenAPS.Settings.basalProfile, as: [BasalProfileEntry].self), @@ -454,7 +454,7 @@ final class BaseNightscoutManager: NightscoutManager, Injectable { let preferences = storage.retrieve(OpenAPS.Settings.preferences, as: Preferences.self), let settings = storage.retrieve(OpenAPS.FreeAPS.settings, as: FreeAPSSettings.self) else { - NSLog("NightscoutManager uploadProfile Not all settings found to build profile!") + debug(.nightscout, "NightscoutManager uploadProfile Not all settings found to build profile!") return } @@ -548,20 +548,20 @@ final class BaseNightscoutManager: NightscoutManager, Injectable { // UPLOAD PREFERNCES WHEN CHANGED if let uploadedPreferences = storage.retrieve(OpenAPS.Nightscout.uploadedPreferences, as: Preferences.self), - uploadedPreferences.rawJSON.sorted() == preferences.rawJSON.sorted() + uploadedPreferences.rawJSON.sorted() == preferences.rawJSON.sorted(), !force { NSLog("NightscoutManager Preferences, preferences unchanged") } else { uploadPreferences(preferences) } // UPLOAD FreeAPS Settings WHEN CHANGED if let uploadedSettings = storage.retrieve(OpenAPS.Nightscout.uploadedSettings, as: FreeAPSSettings.self), - uploadedSettings.rawJSON.sorted() == settings.rawJSON.sorted() + uploadedSettings.rawJSON.sorted() == settings.rawJSON.sorted(), !force { NSLog("NightscoutManager Settings, settings unchanged") } else { uploadSettings(settings) } if let uploadedProfile = storage.retrieve(OpenAPS.Nightscout.uploadedProfile, as: NightscoutProfileStore.self), - (uploadedProfile.store["default"]?.rawJSON ?? "").sorted() == ps.rawJSON.sorted() + (uploadedProfile.store["default"]?.rawJSON ?? "").sorted() == ps.rawJSON.sorted(), !force { NSLog("NightscoutManager uploadProfile, no profile change") return From 6011575963a9564286fdbe4530652b43377c76b0 Mon Sep 17 00:00:00 2001 From: Deniz Cengiz <48965855+dnzxy@users.noreply.github.com> Date: Sun, 22 Oct 2023 17:09:10 +0200 Subject: [PATCH 60/61] Add "non-pump insulin" as treatment type (#267) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jonas Björkert --- .../xcshareddata/swiftpm/Package.resolved | 2 +- .../APS/Storage/PumpHistoryStorage.swift | 16 ++++++++++-- .../Main/de.lproj/Localizable.strings | 3 +++ .../Main/en.lproj/Localizable.strings | 6 +++++ FreeAPS/Sources/Models/PumpHistoryEvent.swift | 9 +++++-- .../Modules/Bolus/BolusStateModel.swift | 3 ++- .../Modules/DataTable/DataTableDataFlow.swift | 25 +++++++++++++------ .../DataTable/DataTableStateModel.swift | 3 ++- 8 files changed, 52 insertions(+), 15 deletions(-) diff --git a/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved b/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved index 142d983415..2cfe78ebfa 100644 --- a/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/FreeAPS.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -30,7 +30,7 @@ }, { "package": "SwiftCharts", - "repositoryURL": "https://github.com/ivanschuetz/SwiftCharts", + "repositoryURL": "https://github.com/ivanschuetz/SwiftCharts.git", "state": { "branch": "master", "revision": "c354c1945bb35a1f01b665b22474f6db28cba4a2", diff --git a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift index 16fee07041..b3b034f0de 100644 --- a/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift +++ b/FreeAPS/Sources/APS/Storage/PumpHistoryStorage.swift @@ -45,7 +45,8 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { rate: nil, temp: nil, carbInput: nil, - isSMB: dose.automatic + isSMB: dose.automatic, + isNonPumpInsulin: dose.manuallyEntered )] case .tempBasal: guard let dose = event.dose else { return [] } @@ -210,6 +211,16 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { } } + func determineBolusEventType(for event: PumpHistoryEvent) -> EventType { + if event.isSMB ?? false { + return .smb + } + if event.isNonPumpInsulin ?? false { + return .nonPumpInsulin + } + return event.type + } + func nightscoutTretmentsNotUploaded() -> [NigtscoutTreatment] { let events = recent() guard !events.isEmpty else { return [] } @@ -250,13 +261,14 @@ final class BasePumpHistoryStorage: PumpHistoryStorage, Injectable { let bolusesAndCarbs = events.compactMap { event -> NigtscoutTreatment? in switch event.type { case .bolus: + let eventType = determineBolusEventType(for: event) return NigtscoutTreatment( duration: event.duration, rawDuration: nil, rawRate: nil, absolute: nil, rate: nil, - eventType: (event.isSMB ?? false) ? .smb : .bolus, + eventType: eventType, createdAt: event.timestamp, enteredBy: NigtscoutTreatment.local, bolus: event, diff --git a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings index c64bac88bb..e7b8112ce7 100644 --- a/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/de.lproj/Localizable.strings @@ -1171,6 +1171,9 @@ Enact a temp Basal or a temp target */ /* An Automatic delivered bolus (SMB) */ "SMB" = "SMB"; +/* A manually entered dose of non-pump insulin */ +"Non-pump Insulin" = "Externes Insulin"; + /* Status highlight when manual temp basal is running. */ "Manual Basal" = "Manuelle Temporäre Basalrate"; diff --git a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings index 05b03384c6..8cd859d1b3 100644 --- a/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings +++ b/FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings @@ -569,6 +569,9 @@ Enact a temp Basal or a temp target */ /* Automatic delivered treatments */ "Automatic" = "Automatic"; +/* Non-pump insulin treatments */ +"Non-Pump" = "Non-Pump"; + /* */ "Other" = "Other"; @@ -1172,6 +1175,9 @@ Enact a temp Basal or a temp target */ /* An Automatic delivered bolus (SMB) */ "SMB" = "SMB"; +/* A manually entered dose of non-pump insulin */ +"Non-pump Insulin" = "Non-pump Insulin"; + /* Status highlight when manual temp basal is running. */ "Manual Basal" = "Manual Basal"; diff --git a/FreeAPS/Sources/Models/PumpHistoryEvent.swift b/FreeAPS/Sources/Models/PumpHistoryEvent.swift index b7a06a2996..c53362d3d9 100644 --- a/FreeAPS/Sources/Models/PumpHistoryEvent.swift +++ b/FreeAPS/Sources/Models/PumpHistoryEvent.swift @@ -12,6 +12,7 @@ struct PumpHistoryEvent: JSON, Equatable { let carbInput: Int? let note: String? let isSMB: Bool? + let isNonPumpInsulin: Bool? init( id: String, @@ -24,7 +25,8 @@ struct PumpHistoryEvent: JSON, Equatable { temp: TempType? = nil, carbInput: Int? = nil, note: String? = nil, - isSMB: Bool? = nil + isSMB: Bool? = nil, + isNonPumpInsulin: Bool? = nil ) { self.id = id self.type = type @@ -37,13 +39,15 @@ struct PumpHistoryEvent: JSON, Equatable { self.carbInput = carbInput self.note = note self.isSMB = isSMB + self.isNonPumpInsulin = isNonPumpInsulin } } enum EventType: String, JSON { case bolus = "Bolus" case smb = "SMB" - case mealBulus = "Meal Bolus" + case nonPumpInsulin = "Non-pump Insulin" + case mealBolus = "Meal Bolus" case correctionBolus = "Correction Bolus" case snackBolus = "Snack Bolus" case bolusWizard = "BolusWizard" @@ -86,5 +90,6 @@ extension PumpHistoryEvent { case carbInput = "carb_input" case note case isSMB + case isNonPumpInsulin } } diff --git a/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift b/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift index a8f22abdb9..72a53a01a6 100644 --- a/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift +++ b/FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift @@ -86,7 +86,8 @@ extension Bolus { durationMin: nil, rate: nil, temp: nil, - carbInput: nil + carbInput: nil, + isNonPumpInsulin: true ) ] ) diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift index 39185b734b..41f448f414 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableDataFlow.swift @@ -67,6 +67,7 @@ enum DataTable { let fpuID: String? let note: String? let isSMB: Bool? + let isNonPump: Bool? private var numberFormatter: NumberFormatter { let formatter = NumberFormatter() @@ -94,7 +95,8 @@ enum DataTable { isFPU: Bool? = nil, fpuID: String? = nil, note: String? = nil, - isSMB: Bool? = nil + isSMB: Bool? = nil, + isNonPump: Bool? = nil ) { self.units = units self.type = type @@ -108,6 +110,7 @@ enum DataTable { self.fpuID = fpuID self.note = note self.isSMB = isSMB + self.isNonPump = isNonPump } static func == (lhs: Treatment, rhs: Treatment) -> Bool { @@ -135,12 +138,18 @@ enum DataTable { return numberFormatter .string(from: amount as NSNumber)! + NSLocalizedString(" g", comment: "gram of carb equilvalents") case .bolus: + var bolusText = " " + + if isSMB ?? false { + bolusText += NSLocalizedString("Automatic", comment: "Automatic delivered treatments") + } else if isNonPump ?? false { + bolusText += NSLocalizedString("Non-Pump", comment: "Non-pump Insulin") + } else { + bolusText += NSLocalizedString("Manual", comment: "Manual Bolus") + } + return numberFormatter - .string(from: amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") + - ( - (isSMB ?? false) ? " " + NSLocalizedString("Automatic", comment: "Automatic delivered treatments") : " " + - NSLocalizedString("Manual", comment: "Manual Bolus") - ) + .string(from: amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") + bolusText case .tempBasal: return numberFormatter .string(from: amount as NSNumber)! + NSLocalizedString(" U/hr", comment: "Unit insulin per hour") @@ -172,9 +181,9 @@ enum DataTable { case .fpus: return .orange.opacity(0.5) case .bolus: - return .insulin + return Color.insulin case .tempBasal: - return Color.insulin.opacity(0.5) + return Color.insulin.opacity(0.4) case .resume, .suspend, .tempTarget: diff --git a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift index 7021a84df0..f23b5fd910 100644 --- a/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift +++ b/FreeAPS/Sources/Modules/DataTable/DataTableStateModel.swift @@ -73,7 +73,8 @@ extension DataTable { date: $0.timestamp, amount: $0.amount, idPumpEvent: $0.id, - isSMB: $0.isSMB + isSMB: $0.isSMB, + isNonPump: $0.isNonPumpInsulin ) } From fd099664d2e2566402b8cc294709546cbf7892ca Mon Sep 17 00:00:00 2001 From: dnzxy Date: Sun, 22 Oct 2023 18:31:11 +0200 Subject: [PATCH 61/61] Fix date issues for new entry dialogs: * Reset date to now when opening entry dialog (non-pump insulin and glucose) * Limit date to past values up to current for glucose entry (do not permit future glucose entries!) --- .../Modules/DataTable/View/DataTableRootView.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift index ae3fcb0f95..4805267740 100644 --- a/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift +++ b/FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift @@ -106,10 +106,12 @@ extension DataTable { // } // } ) - .sheet(isPresented: $showManualGlucose, onDismiss: { if isAmountUnconfirmed { state.manualGlucose = 0 } }) { + .sheet(isPresented: $showManualGlucose, onDismiss: { if isAmountUnconfirmed { state.manualGlucose = 0 + state.manualGlucoseDate = Date() } }) { addManualGlucoseView } - .sheet(isPresented: $showNonPumpInsulin, onDismiss: { if isAmountUnconfirmed { state.nonPumpInsulinAmount = 0 } }) { + .sheet(isPresented: $showNonPumpInsulin, onDismiss: { if isAmountUnconfirmed { state.nonPumpInsulinAmount = 0 + state.nonPumpInsulinDate = Date() } }) { addNonPumpInsulinView } } @@ -132,7 +134,11 @@ extension DataTable { } Section { - DatePicker("Date", selection: $state.manualGlucoseDate) + DatePicker( + "Date", + selection: $state.manualGlucoseDate, + in: ...Date() + ) } Section {