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

Revert calculateTINS() changes from 079f041

dnzxy 2 лет назад
Родитель
Сommit
3ad2c9179e

+ 1 - 32
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

@@ -182,13 +182,7 @@ struct MainChartView: View {
             ScrollViewReader { scroll in
                 ZStack(alignment: .top) {
                     tempTargetsView(fullSize: fullSize).drawingGroup()
-
-                    ZStack {
-                        basalView(fullSize: fullSize).drawingGroup()
-                        Text(calculateTINS())
-                            .font(.callout).fontWeight(.bold)
-                            .offset(x: 0, y: 0)
-                    }
+                    basalView(fullSize: fullSize).drawingGroup()
 
                     mainView(fullSize: fullSize).id(Config.endID)
                         .drawingGroup()
@@ -1218,29 +1212,4 @@ extension MainChartView {
         let oneSecondWidth = oneSecondStep(viewWidth: viewWidth)
         return oneSecondWidth * CGFloat(lastDeltaTime)
     }
-
-    // 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"
-    }
 }

+ 27 - 0
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -84,6 +84,8 @@ struct PumpView: View {
                         .foregroundColor(batteryColor)
                     Text("\(Int(battery.percent ?? 100)) %").font(.callout)
                         .fontWeight(.bold)
+                    Text(calculateTINS())
+                        .font(.callout).fontWeight(.bold)
                 }
             }
 
@@ -102,6 +104,31 @@ 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")