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

(re)add loopView and small UI improvements in header

polscm32 2 лет назад
Родитель
Сommit
14565bc9ab

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

@@ -7,6 +7,8 @@ struct PumpView: View {
     @Binding var expiresAtDate: Date?
     @Binding var timerDate: Date
 
+    @State var state: Home.StateModel
+
     private var reservoirFormatter: NumberFormatter {
         let formatter = NumberFormatter()
         formatter.numberStyle = .decimal
@@ -20,8 +22,52 @@ struct PumpView: View {
         return formatter
     }
 
+    private var numberFormatter: NumberFormatter {
+        let formatter = NumberFormatter()
+        formatter.numberStyle = .decimal
+        formatter.maximumFractionDigits = 2
+        return formatter
+    }
+
     var body: some View {
         HStack {
+//            MARK: TEST
+
+//            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()
+//            }
+            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()
 
             if let reservoir = reservoir {

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

@@ -128,7 +128,7 @@ extension Home {
 
             HStack {
                 Spacer()
-                cobIobView2
+//                cobIobView2
 //                Spacer()
 //                        glucoseView
 //                        Spacer()
@@ -180,7 +180,7 @@ extension Home {
                         NSLocalizedString(" g", comment: "gram of carbs")
                 )
                 .font(.callout).fontWeight(.bold)
-                
+
                 Spacer()
             }
         }
@@ -219,7 +219,8 @@ extension Home {
                 battery: $state.battery,
                 name: $state.pumpName,
                 expiresAtDate: $state.pumpExpiresAtDate,
-                timerDate: $state.timerDate
+                timerDate: $state.timerDate,
+                state: state
             )
             .onTapGesture {
                 if state.pumpDisplayState != nil {
@@ -687,8 +688,13 @@ extension Home {
 
             GeometryReader { geo in
                 VStack(spacing: 0) {
-                    glucoseView
-                        .padding(.top, 80)
+                    ZStack {
+                        glucoseView
+                            .padding(.top, 80)
+
+                        loopView
+                            .offset(x: UIScreen.main.bounds.width * 0.35)
+                    }
 
                     header2(geo)
                         .padding(.vertical, 35)