polscm32 2 лет назад
Родитель
Сommit
84ff8c539a

+ 6 - 2
FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift

@@ -11,6 +11,8 @@ struct CurrentGlucoseView: View {
 
     @State private var rotationDegrees: Double = 0.0
 
+    @Environment(\.colorScheme) var colorScheme
+
     private var glucoseFormatter: NumberFormatter {
         let formatter = NumberFormatter()
         formatter.numberStyle = .decimal
@@ -47,6 +49,8 @@ struct CurrentGlucoseView: View {
     }
 
     var body: some View {
+        let colourGlucoseText: Color = colorScheme == .dark ? .white : .black
+
         ZStack {
             TrendShape(color: colorOfGlucose)
                 .rotationEffect(.degrees(rotationDegrees))
@@ -61,7 +65,7 @@ struct CurrentGlucoseView: View {
                             ?? "--"
                     )
                     .font(.system(size: 40, weight: .bold))
-                    .foregroundColor(alarm == nil ? colorOfGlucose : .loopRed)
+                    .foregroundColor(alarm == nil ? colourGlucoseText : .loopRed)
 
                     //                image
                 }
@@ -194,7 +198,7 @@ struct CircleShape: View {
     let color: Color
 
     var body: some View {
-        let colorBackground: Color = colorScheme == .dark ? .gray.opacity(0.2) : .white
+        let colorBackground: Color = colorScheme == .dark ? .black : .white
 
         Circle()
             .stroke(color, lineWidth: 10)

+ 28 - 20
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -21,36 +21,41 @@ struct PumpView: View {
     }
 
     var body: some View {
-        VStack(alignment: .leading, spacing: 12) {
+        HStack {
+            Spacer()
+
             if let reservoir = reservoir {
                 HStack {
                     Image(systemName: "drop.fill")
                         .resizable()
                         .aspectRatio(contentMode: .fit)
-                        .frame(maxHeight: 10)
+                        .frame(maxHeight: 15)
                         .foregroundColor(reservoirColor)
                     if reservoir == 0xDEAD_BEEF {
-                        Text("50+ " + NSLocalizedString("U", comment: "Insulin unit")).font(.footnote)
+                        Text("50+ " + NSLocalizedString("U", comment: "Insulin unit")).font(.callout)
                             .fontWeight(.bold)
                     } else {
                         Text(
                             reservoirFormatter
                                 .string(from: reservoir as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit")
                         )
-                        .font(.footnote).fontWeight(.bold)
+                        .font(.callout).fontWeight(.bold)
                     }
-                }.frame(alignment: .top)
+                }
             }
+
+            Spacer()
+
             if let battery = battery, battery.display ?? false, expiresAtDate == nil {
                 HStack {
                     Image(systemName: "battery.100")
                         .resizable()
                         .aspectRatio(contentMode: .fit)
-                        .frame(maxHeight: 10)
+                        .frame(maxHeight: 15)
                         .foregroundColor(batteryColor)
-                    Text("\(Int(battery.percent ?? 100)) %").font(.footnote)
+                    Text("\(Int(battery.percent ?? 100)) %").font(.callout)
                         .fontWeight(.bold)
-                }.frame(alignment: .bottom)
+                }
             }
 
             if let date = expiresAtDate {
@@ -58,11 +63,14 @@ struct PumpView: View {
                     Image(systemName: "stopwatch.fill")
                         .resizable()
                         .aspectRatio(contentMode: .fit)
-                        .frame(maxHeight: 10)
+                        .frame(maxHeight: 15)
                         .foregroundColor(timerColor)
-                    Text(remainingTimeString(time: date.timeIntervalSince(timerDate))).font(.footnote)
+
+                    Spacer()
+
+                    Text(remainingTimeString(time: date.timeIntervalSince(timerDate))).font(.callout)
                         .fontWeight(.bold)
-                }.frame(alignment: .bottom)
+                }
             }
         }
     }
@@ -98,11 +106,11 @@ struct PumpView: View {
 
         switch percent {
         case ...10:
-            return .loopRed
+            return .red
         case ...20:
-            return .loopYellow
+            return .yellow
         default:
-            return .loopGreen
+            return .green
         }
     }
 
@@ -113,11 +121,11 @@ struct PumpView: View {
 
         switch reservoir {
         case ...10:
-            return .loopRed
+            return .red
         case ...30:
-            return .loopYellow
+            return .yellow
         default:
-            return .insulin
+            return .blue
         }
     }
 
@@ -130,11 +138,11 @@ struct PumpView: View {
 
         switch time {
         case ...8.hours.timeInterval:
-            return .loopRed
+            return .red
         case ...1.days.timeInterval:
-            return .loopYellow
+            return .yellow
         default:
-            return .loopGreen
+            return .green
         }
     }
 }

+ 48 - 5
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -123,6 +123,25 @@ extension Home {
                 .padding([.leading, .trailing], 10)
         }
 
+        @ViewBuilder func header2(_: GeometryProxy) -> some View {
+//            let colour: Color = colorScheme == .dark ? .gray.opacity(0.2) : .white
+
+            HStack {
+                Spacer()
+                cobIobView2
+//                Spacer()
+//                        glucoseView
+//                        Spacer()
+//                loopView
+//                Spacer()
+                pumpView
+                Spacer()
+            }
+//            .frame(maxWidth: .infinity)
+//                    .padding(.top, 10 + geo.safeAreaInsets.top)
+//                    .padding(.bottom, 10)
+        }
+
         var cobIobView: some View {
             VStack(alignment: .leading, spacing: 12) {
                 HStack {
@@ -144,6 +163,28 @@ extension Home {
             }
         }
 
+        var cobIobView2: some View {
+            HStack {
+                Text("IOB").font(.callout).foregroundColor(.secondary)
+                Text(
+                    (numberFormatter.string(from: (state.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
+                        NSLocalizedString(" U", comment: "Insulin unit")
+                )
+                .font(.callout).fontWeight(.bold)
+
+                Spacer()
+
+                Text("COB").font(.callout).foregroundColor(.secondary)
+                Text(
+                    (numberFormatter.string(from: (state.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
+                        NSLocalizedString(" g", comment: "gram of carbs")
+                )
+                .font(.callout).fontWeight(.bold)
+                
+                Spacer()
+            }
+        }
+
         var glucoseView: some View {
             CurrentGlucoseView(
                 recentGlucose: $state.recentGlucose,
@@ -647,19 +688,21 @@ extension Home {
             GeometryReader { geo in
                 VStack(spacing: 0) {
                     glucoseView
-                        .padding(.top, 90)
+                        .padding(.top, 80)
 
-                    infoPanel
-                        .padding(.top, 5)
+                    header2(geo)
+                        .padding(.vertical, 35)
+                        .padding([.leading, .trailing], 10)
 
-                    header(geo)
+                    infoPanel
+                        .padding([.leading, .trailing], 10)
 
                     RoundedRectangle(cornerRadius: 15)
                         .fill(colourChart)
                         .shadow(radius: 3)
                         .overlay(mainChart)
                         .padding([.leading, .trailing], 10)
-                        .padding(.top, 10)
+                        .padding(.top, 5)
                         .frame(height: UIScreen.main.bounds.height / 2.2) // with 2 chart was still too big
 
                     pickerPanel(geo)