From 785e2afaae3c29ae851c9c832d334750532a8e25 Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 18 May 2024 17:45:05 +0200 Subject: [PATCH] fix logging and skip 2hr Chart --- .../Sources/Modules/Home/HomeStateModel.swift | 4 +-- .../Modules/Home/View/HomeRootView.swift | 28 +++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/FreeAPS/Sources/Modules/Home/HomeStateModel.swift b/FreeAPS/Sources/Modules/Home/HomeStateModel.swift index 6c218398c4..85c8456883 100644 --- a/FreeAPS/Sources/Modules/Home/HomeStateModel.swift +++ b/FreeAPS/Sources/Modules/Home/HomeStateModel.swift @@ -354,8 +354,8 @@ extension Home { let totalBoluses = bolusesForCurrentDay.map { $0.amount ?? 0 }.reduce(0, +) /// final TINS value, i.e. boluses AND delivered basal let total = totalBoluses + basalInsulinForCurrentDay - debug(.default, "totalBoluses: \(totalBoluses)") - debug(.default, "basalInsulinForCurrentDay: \(basalInsulinForCurrentDay)") + debug(.default, "TINS Bolus \(startTime): \(numberFormatter.string(from: totalBoluses as NSNumber) ?? "NaN")") + debug(.default, "TINS Basal: \(numberFormatter.string(from: basalInsulinForCurrentDay as NSNumber) ?? "NaN")") calculatedTins = numberFormatter.string(from: total as NSNumber) ?? "NaN" diff --git a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift index 311d17c720..462da7fd85 100644 --- a/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift +++ b/FreeAPS/Sources/Modules/Home/View/HomeRootView.swift @@ -23,11 +23,11 @@ extension Home { } @State var timeButtons: [Buttons] = [ - Buttons(label: "2h", number: "2", active: false, hours: 2), - Buttons(label: "4h", number: "4", active: false, hours: 4), + Buttons(label: "3h", number: "3", active: false, hours: 3), Buttons(label: "6h", number: "6", active: false, hours: 6), Buttons(label: "12h", number: "12", active: false, hours: 12), - Buttons(label: "24h", number: "24", active: false, hours: 24) + Buttons(label: "24h", number: "24", active: false, hours: 24), + Buttons(label: "36h", number: "36", active: false, hours: 36) ] let buttonFont = Font.custom("TimeButtonFont", size: 14) @@ -315,12 +315,22 @@ extension Home { .padding(.leading, 8) } if state.tins { - Text( - "TINS: \(state.calculateTINS())" + - NSLocalizedString(" U", comment: "Unit in number of units delivered (keep the space character!)") - ) - .font(.system(size: 12, weight: .bold)) - .foregroundColor(.insulin) + HStack { + Text( + "TINS: \(state.calculatedTins)" + + NSLocalizedString(" U", comment: "Unit in number of units delivered (keep the space character!)") + ) + .font(.system(size: 12, weight: .bold)) + .foregroundColor(.insulin) + .onChange(of: state.hours) { _ in + state.calculatedTins = state.calculateTINS() + } + .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + state.calculatedTins = state.calculateTINS() + } + } + } } if let tempTargetString = tempTargetString {