Procházet zdrojové kódy

Reposition loop cycle; some spacing and padding fixes

dnzxy před 2 roky
rodič
revize
079f0415d9

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

@@ -182,7 +182,12 @@ struct MainChartView: View {
             ScrollViewReader { scroll in
             ScrollViewReader { scroll in
                 ZStack(alignment: .top) {
                 ZStack(alignment: .top) {
                     tempTargetsView(fullSize: fullSize).drawingGroup()
                     tempTargetsView(fullSize: fullSize).drawingGroup()
-                    basalView(fullSize: fullSize).drawingGroup()
+
+                    ZStack {
+                        basalView(fullSize: fullSize).drawingGroup()
+                        Text(calculateTINS())
+                            .font(.callout).fontWeight(.bold)
+                    }
 
 
                     mainView(fullSize: fullSize).id(Config.endID)
                     mainView(fullSize: fullSize).id(Config.endID)
                         .drawingGroup()
                         .drawingGroup()
@@ -273,7 +278,7 @@ struct MainChartView: View {
         .scaleEffect(x: 1, y: -1)
         .scaleEffect(x: 1, y: -1)
         .frame(width: fullGlucoseWidth(viewWidth: fullSize.width) + additionalWidth(viewWidth: fullSize.width))
         .frame(width: fullGlucoseWidth(viewWidth: fullSize.width) + additionalWidth(viewWidth: fullSize.width))
         .frame(maxHeight: Config.basalHeight)
         .frame(maxHeight: Config.basalHeight)
-        .background(Color.secondary.opacity(0.1))
+        .background(colorScheme == .dark ? Color.black.opacity(0.8) : Color.clear)
         .onChange(of: tempBasals) { _ in
         .onChange(of: tempBasals) { _ in
             calculateBasalPoints(fullSize: fullSize)
             calculateBasalPoints(fullSize: fullSize)
         }
         }
@@ -1212,4 +1217,29 @@ extension MainChartView {
         let oneSecondWidth = oneSecondStep(viewWidth: viewWidth)
         let oneSecondWidth = oneSecondStep(viewWidth: viewWidth)
         return oneSecondWidth * CGFloat(lastDeltaTime)
         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"
+    }
 }
 }

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

@@ -84,8 +84,6 @@ struct PumpView: View {
                         .foregroundColor(batteryColor)
                         .foregroundColor(batteryColor)
                     Text("\(Int(battery.percent ?? 100)) %").font(.callout)
                     Text("\(Int(battery.percent ?? 100)) %").font(.callout)
                         .fontWeight(.bold)
                         .fontWeight(.bold)
-                    Text(calculateTINS())
-                        .font(.callout).fontWeight(.bold)
                 }
                 }
             }
             }
 
 
@@ -104,31 +102,6 @@ struct PumpView: View {
         }
         }
     }
     }
 
 
-    // MARK: WORKS....BUT MAYBE TIMEZONE PROBLEMS COULD OCCUR
-
-    // DEFINETELY SOMETHING FOR OUR TIMEZONE EXPERT.....
-
-    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 {
     private func remainingTimeString(time: TimeInterval) -> String {
         guard time > 0 else {
         guard time > 0 else {
             return NSLocalizedString("Replace pod", comment: "View/Header when pod expired")
             return NSLocalizedString("Replace pod", comment: "View/Header when pod expired")

+ 18 - 11
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -368,6 +368,8 @@ extension Home {
         var legendPanel: some View {
         var legendPanel: some View {
             ZStack {
             ZStack {
                 HStack(alignment: .center) {
                 HStack(alignment: .center) {
+                    Spacer()
+
                     Group {
                     Group {
                         Circle().fill(Color.loopGreen).frame(width: 8, height: 8)
                         Circle().fill(Color.loopGreen).frame(width: 8, height: 8)
                         Text("BG")
                         Text("BG")
@@ -385,6 +387,13 @@ extension Home {
                         Text("ZT")
                         Text("ZT")
                             .font(.system(size: 12, weight: .bold)).foregroundColor(.zt)
                             .font(.system(size: 12, weight: .bold)).foregroundColor(.zt)
                     }
                     }
+
+                    Spacer()
+
+                    loopView.padding(.top, 16)
+
+                    Spacer()
+
                     Group {
                     Group {
                         Circle().fill(Color.loopYellow).frame(width: 8, height: 8)
                         Circle().fill(Color.loopYellow).frame(width: 8, height: 8)
                             .padding(.leading, 8)
                             .padding(.leading, 8)
@@ -406,9 +415,9 @@ extension Home {
                         )
                         )
                         .font(.system(size: 12, weight: .bold)).foregroundColor(.secondary)
                         .font(.system(size: 12, weight: .bold)).foregroundColor(.secondary)
                     }
                     }
+                    Spacer()
                 }
                 }
                 .frame(maxWidth: .infinity)
                 .frame(maxWidth: .infinity)
-                .padding([.bottom], 20)
             }
             }
         }
         }
 
 
@@ -660,15 +669,15 @@ extension Home {
                 VStack(spacing: 0) {
                 VStack(spacing: 0) {
                     Spacer()
                     Spacer()
 
 
-                    ZStack {
-                        glucoseView
+//                    ZStack {
+                    glucoseView.padding(.top, 75)
 
 
-                        loopView
-                            /// circles width is 110, loops width is 35 -> (110/2) - (35/2) = 55 - 17.5 = 37.5
-                            .offset(x: UIScreen.main.bounds.width * 0.43, y: -37.5)
-                            .padding(.trailing, 10)
-                    }
-                    .padding(.top, 75)
+//                        loopView
+//                            /// circles width is 110, loops width is 35 -> (110/2) - (35/2) = 55 - 17.5 = 37.5
+//                            .offset(x: UIScreen.main.bounds.width * 0.43, y: -37.5)
+//                            .padding(.trailing, 10)
+//                    }
+//                    .padding(.top, 75)
 
 
                     Spacer()
                     Spacer()
 
 
@@ -697,8 +706,6 @@ extension Home {
 
 
                     timeInterval
                     timeInterval
 
 
-                    Spacer()
-
                     legendPanel
                     legendPanel
 
 
                     Spacer()
                     Spacer()