|
|
@@ -6,13 +6,9 @@ struct PumpView: View {
|
|
|
@Binding var name: String
|
|
|
@Binding var expiresAtDate: Date?
|
|
|
@Binding var timerDate: Date
|
|
|
- @Binding var boluses: [PumpHistoryEvent]
|
|
|
- @Binding var screenHours: Int16
|
|
|
|
|
|
@State var state: Home.StateModel
|
|
|
|
|
|
- @State var totalBolus: Decimal = 0
|
|
|
-
|
|
|
private var reservoirFormatter: NumberFormatter {
|
|
|
let formatter = NumberFormatter()
|
|
|
formatter.numberStyle = .decimal
|
|
|
@@ -84,8 +80,6 @@ struct PumpView: View {
|
|
|
.foregroundColor(batteryColor)
|
|
|
Text("\(Int(battery.percent ?? 100)) %").font(.callout)
|
|
|
.fontWeight(.bold)
|
|
|
- Text(calculateTINS())
|
|
|
- .font(.callout).fontWeight(.bold)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -104,31 +98,6 @@ struct PumpView: View {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // MARK: WORKS....BUT MAYBE TIMEZONE PROBLEMS COULD OCCUR
|
|
|
-
|
|
|
- // DEFINETELY SOMETHING FOR OUR TIMEZONE EXPERT.....
|
|
|
-
|
|
|
- private func calculateTINS() -> String {
|
|
|
- let date = Date()
|
|
|
- let calendar = Calendar.current
|
|
|
- let offset = screenHours
|
|
|
-
|
|
|
- var offsetComponents = DateComponents()
|
|
|
- // offsetComponents.hour = -offset.rawValue
|
|
|
- offsetComponents.hour = -Int(offset)
|
|
|
-
|
|
|
- let startTime = calendar.date(byAdding: offsetComponents, to: date)!
|
|
|
- print("******************")
|
|
|
- print("die voll krasse start time ist: \(startTime)")
|
|
|
-
|
|
|
- let bolusesForCurrentDay = boluses.filter { $0.timestamp >= startTime && $0.type == .bolus }
|
|
|
-
|
|
|
- let totalBolus = bolusesForCurrentDay.map { $0.amount ?? 0 }.reduce(0, +)
|
|
|
- let roundedTotalBolus = Decimal(round(100 * Double(totalBolus)) / 100)
|
|
|
-
|
|
|
- return "\(roundedTotalBolus) U"
|
|
|
- }
|
|
|
-
|
|
|
private func remainingTimeString(time: TimeInterval) -> String {
|
|
|
guard time > 0 else {
|
|
|
return NSLocalizedString("Replace pod", comment: "View/Header when pod expired")
|