Explorar o código

home page new layout

Ivan Valkou %!s(int64=5) %!d(string=hai) anos
pai
achega
5c283786ca

+ 4 - 0
FreeAPS.xcodeproj/project.pbxproj

@@ -193,6 +193,7 @@
 		38E98A2D25F52DC400C0CED0 /* NSLocking+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E98A2C25F52DC400C0CED0 /* NSLocking+Extensions.swift */; };
 		38E98A3025F52FF700C0CED0 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E98A2F25F52FF700C0CED0 /* Config.swift */; };
 		38E98A3725F5509500C0CED0 /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38E98A3625F5509500C0CED0 /* String+Extensions.swift */; };
+		38F37828261260DC009DB701 /* Color+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38F37827261260DC009DB701 /* Color+Extensions.swift */; };
 		38F3B2EF25ED8E2A005C48AA /* TempTargetsStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38F3B2EE25ED8E2A005C48AA /* TempTargetsStorage.swift */; };
 		38FCF3D625E8FDF40078B0D1 /* MD5.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38FCF3D525E8FDF40078B0D1 /* MD5.swift */; };
 		38FCF3F925E902C20078B0D1 /* FileStorageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38FCF3F825E902C20078B0D1 /* FileStorageTests.swift */; };
@@ -467,6 +468,7 @@
 		38E98A2C25F52DC400C0CED0 /* NSLocking+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSLocking+Extensions.swift"; sourceTree = "<group>"; };
 		38E98A2F25F52FF700C0CED0 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
 		38E98A3625F5509500C0CED0 /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = "<group>"; };
+		38F37827261260DC009DB701 /* Color+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Color+Extensions.swift"; sourceTree = "<group>"; };
 		38F3B2EE25ED8E2A005C48AA /* TempTargetsStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TempTargetsStorage.swift; sourceTree = "<group>"; };
 		38FCF3D525E8FDF40078B0D1 /* MD5.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MD5.swift; sourceTree = "<group>"; };
 		38FCF3ED25E9028E0078B0D1 /* FreeAPSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FreeAPSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1062,6 +1064,7 @@
 				3811DE5525C9D4D500A708ED /* Publisher.swift */,
 				38E98A3625F5509500C0CED0 /* String+Extensions.swift */,
 				3811DEE325CA063400A708ED /* PropertyWrappers */,
+				38F37827261260DC009DB701 /* Color+Extensions.swift */,
 			);
 			path = Helpers;
 			sourceTree = "<group>";
@@ -1676,6 +1679,7 @@
 				3811DE6C25C9D62600A708ED /* OnboardingDataFlow.swift in Sources */,
 				38DAB28A260D349500F74C1A /* GlucoseManager.swift in Sources */,
 				3811DE2425C9D48300A708ED /* MainViewModel.swift in Sources */,
+				38F37828261260DC009DB701 /* Color+Extensions.swift in Sources */,
 				3811DE3F25C9D4A100A708ED /* SettingsViewModel.swift in Sources */,
 				38B4F3CB25E502E200E76A18 /* WeakObjectSet.swift in Sources */,
 				3811DEB725C9D88300A708ED /* AuthorizationManager.swift in Sources */,

+ 38 - 0
FreeAPS/Resources/Assets.xcassets/Colors/Basal.colorset/Contents.json

@@ -0,0 +1,38 @@
+{
+  "colors" : [
+    {
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "0.500",
+          "blue" : "0.988",
+          "green" : "0.588",
+          "red" : "0.118"
+        }
+      },
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "1.000",
+          "green" : "1.000",
+          "red" : "1.000"
+        }
+      },
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 38 - 0
FreeAPS/Resources/Assets.xcassets/Colors/Insulin.colorset/Contents.json

@@ -0,0 +1,38 @@
+{
+  "colors" : [
+    {
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "0.988",
+          "green" : "0.588",
+          "red" : "0.118"
+        }
+      },
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "0.988",
+          "green" : "0.588",
+          "red" : "0.118"
+        }
+      },
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 6 - 6
FreeAPS/Resources/Assets.xcassets/Colors/LoopYellow.colorset/Contents.json

@@ -5,9 +5,9 @@
         "color-space" : "srgb",
         "components" : {
           "alpha" : "1.000",
-          "blue" : "0.298",
-          "green" : "0.788",
-          "red" : "0.949"
+          "blue" : "0.271",
+          "green" : "0.757",
+          "red" : "1.000"
         }
       },
       "idiom" : "universal"
@@ -23,9 +23,9 @@
         "color-space" : "srgb",
         "components" : {
           "alpha" : "1.000",
-          "blue" : "0.298",
-          "green" : "0.788",
-          "red" : "0.949"
+          "blue" : "0.271",
+          "green" : "0.757",
+          "red" : "1.000"
         }
       },
       "idiom" : "universal"

+ 38 - 0
FreeAPS/Resources/Assets.xcassets/Colors/TempBasal.colorset/Contents.json

@@ -0,0 +1,38 @@
+{
+  "colors" : [
+    {
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "0.500",
+          "blue" : "0.976",
+          "green" : "0.839",
+          "red" : "0.635"
+        }
+      },
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "0.988",
+          "green" : "0.588",
+          "red" : "0.118"
+        }
+      },
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 38 - 0
FreeAPS/Resources/Assets.xcassets/Colors/UAM.colorset/Contents.json

@@ -0,0 +1,38 @@
+{
+  "colors" : [
+    {
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "0.271",
+          "green" : "0.518",
+          "red" : "1.000"
+        }
+      },
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "0.271",
+          "green" : "0.518",
+          "red" : "1.000"
+        }
+      },
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 38 - 0
FreeAPS/Resources/Assets.xcassets/Colors/ZT.colorset/Contents.json

@@ -0,0 +1,38 @@
+{
+  "colors" : [
+    {
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "0.937",
+          "green" : "0.380",
+          "red" : "0.443"
+        }
+      },
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "0.937",
+          "green" : "0.380",
+          "red" : "0.443"
+        }
+      },
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 11 - 0
FreeAPS/Sources/APS/Storage/TempTargetsStorage.swift

@@ -13,6 +13,7 @@ protocol TempTargetsStorage {
     func nightscoutTretmentsNotUploaded() -> [NigtscoutTreatment]
     func storePresets(_ targets: [TempTarget])
     func presets() -> [TempTarget]
+    func current() -> TempTarget?
 }
 
 final class BaseTempTargetsStorage: TempTargetsStorage, Injectable {
@@ -61,6 +62,16 @@ final class BaseTempTargetsStorage: TempTargetsStorage, Injectable {
         storage.retrieve(OpenAPS.Settings.tempTargets, as: [TempTarget].self)?.reversed() ?? []
     }
 
+    func current() -> TempTarget? {
+        guard let last = recent().last else {
+            return nil
+        }
+        guard last.createdAt.addingTimeInterval(Int(last.duration).minutes.timeInterval) > Date() else {
+            return nil
+        }
+        return last
+    }
+
     func nightscoutTretmentsNotUploaded() -> [NigtscoutTreatment] {
         let uploaded = storage.retrieve(OpenAPS.Nightscout.uploadedTempTargets, as: [NigtscoutTreatment].self) ?? []
 

+ 13 - 0
FreeAPS/Sources/Helpers/Color+Extensions.swift

@@ -0,0 +1,13 @@
+import SwiftUI
+
+extension Color {
+    static let loopGray = Color("LoopGray")
+    static let loopGreen = Color("LoopGreen")
+    static let loopYellow = Color("LoopYellow")
+    static let loopRed = Color("LoopRed")
+    static let insulin = Color("Insulin")
+    static let uam = Color("UAM")
+    static let zt = Color("ZT")
+    static let tempBasal = Color("TempBasal")
+    static let basal = Color("Basal")
+}

+ 1 - 0
FreeAPS/Sources/Modules/Home/HomeDataFlow.swift

@@ -16,4 +16,5 @@ protocol HomeProvider: Provider {
     func carbs(hours: Int) -> [CarbsEntry]
     func pumpBattery() -> Battery?
     func pumpReservoir() -> Decimal?
+    func tempTarget() -> TempTarget?
 }

+ 4 - 0
FreeAPS/Sources/Modules/Home/HomeProvider.swift

@@ -39,6 +39,10 @@ extension Home {
             }
         }
 
+        func tempTarget() -> TempTarget? {
+            tempTargetsStorage.current()
+        }
+
         func carbs(hours: Int) -> [CarbsEntry] {
             carbsStorage.recent().filter {
                 $0.createdAt.addingTimeInterval(hours.hours.timeInterval) > Date()

+ 8 - 6
FreeAPS/Sources/Modules/Home/HomeViewModel.swift

@@ -30,6 +30,7 @@ extension Home {
         @Published var reservoir: Decimal?
         @Published var pumpName = "Pump"
         @Published var pumpExpiresAtDate: Date?
+        @Published var tempTargetName: String?
 
         @Published var allowManualTemp = false
         private(set) var units: GlucoseUnits = .mmolL
@@ -60,6 +61,8 @@ extension Home {
                 lastLoopDate = suggestion?.timestamp ?? .distantPast
             }
 
+            tempTargetName = provider.tempTarget()?.name
+
             broadcaster.register(GlucoseObserver.self, observer: self)
             broadcaster.register(SuggestionObserver.self, observer: self)
             broadcaster.register(SettingsObserver.self, observer: self)
@@ -72,7 +75,11 @@ extension Home {
             broadcaster.register(PumpBatteryObserver.self, observer: self)
             broadcaster.register(PumpReservoirObserver.self, observer: self)
 
-            timer.assign(to: \.timerDate, on: self)
+            timer
+                .sink { date in
+                    self.timerDate = date
+                    self.tempTargetName = self.provider.tempTarget()?.name
+                }
                 .store(in: &lifetime)
 
             apsManager.isLooping
@@ -90,7 +97,6 @@ extension Home {
                 .assign(to: \.pumpName, on: self)
                 .store(in: &lifetime)
 
-//            pumpExpiresAtDate = Date().addingTimeInterval(2.days.timeInterval + 3.hours.timeInterval)
             apsManager.pumpExpiresAtDate
                 .receive(on: DispatchQueue.main)
                 .assign(to: \.pumpExpiresAtDate, on: self)
@@ -121,10 +127,6 @@ extension Home {
             showModal(for: .settings)
         }
 
-        func setFilteredGlucoseHours(hours: Int) {
-            filteredHours = hours
-        }
-
         private func setupGlucose() {
             DispatchQueue.main.async {
                 self.glucose = self.provider.filteredGlucose(hours: self.filteredHours)

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

@@ -153,9 +153,9 @@ struct MainChartView: View {
 
     private func basalView(fullSize: CGSize) -> some View {
         ZStack {
-            tempBasalPath.fill(Color.blue)
-            tempBasalPath.stroke(Color.blue, lineWidth: 1)
-            regularBasalPath.stroke(Color.yellow, lineWidth: 1)
+            tempBasalPath.fill(Color.tempBasal)
+            tempBasalPath.stroke(Color.tempBasal, lineWidth: 1)
+            regularBasalPath.stroke(Color.basal, lineWidth: 1)
         }
         .drawingGroup()
         .frame(width: fullGlucoseWidth(viewWidth: fullSize.width) + additionalWidth(viewWidth: fullSize.width))
@@ -227,7 +227,7 @@ struct MainChartView: View {
                 path.addEllipse(in: rect)
             }
         }
-        .fill(Color.green)
+        .fill(Color.loopGreen)
         .onChange(of: glucose) { _ in
             calculateGlucoseDots(fullSize: fullSize)
         }
@@ -239,7 +239,7 @@ struct MainChartView: View {
     private func bolusView(fullSize: CGSize) -> some View {
         ZStack {
             bolusPath
-                .fill(Color.blue)
+                .fill(Color.insulin)
             bolusPath
                 .stroke(Color.primary, lineWidth: 0.5)
 
@@ -261,7 +261,7 @@ struct MainChartView: View {
     private func carbsView(fullSize: CGSize) -> some View {
         ZStack {
             carbsPath
-                .fill(Color.orange)
+                .fill(Color.loopYellow)
             carbsPath
                 .stroke(Color.primary, lineWidth: 0.5)
 
@@ -283,7 +283,7 @@ struct MainChartView: View {
     private func tempTargetsView(fullSize: CGSize) -> some View {
         ZStack {
             tempTargetsPath
-                .fill(Color.gray.opacity(0.5))
+                .fill(Color.tempBasal)
         }
         .onChange(of: glucose) { _ in
             calculateTempTargetsRects(fullSize: fullSize)
@@ -302,25 +302,25 @@ struct MainChartView: View {
                 for rect in predictionDots[.iob] ?? [] {
                     path.addEllipse(in: rect)
                 }
-            }.stroke(Color.blue)
+            }.fill(Color.insulin)
 
             Path { path in
                 for rect in predictionDots[.cob] ?? [] {
                     path.addEllipse(in: rect)
                 }
-            }.stroke(Color.yellow)
+            }.fill(Color.loopYellow)
 
             Path { path in
                 for rect in predictionDots[.zt] ?? [] {
                     path.addEllipse(in: rect)
                 }
-            }.stroke(Color.purple)
+            }.fill(Color.zt)
 
             Path { path in
                 for rect in predictionDots[.uam] ?? [] {
                     path.addEllipse(in: rect)
                 }
-            }.stroke(Color.orange)
+            }.fill(Color.uam)
         }
         .onChange(of: suggestion) { _ in
             calculatePredictionDots(fullSize: fullSize, type: .iob)

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

@@ -31,30 +31,30 @@ struct CurrentGlucoseView: View {
     }
 
     var body: some View {
-        HStack(spacing: 0) {
-            VStack {
+        VStack(alignment: .center, spacing: 6) {
+            HStack(spacing: 8) {
                 Text(
                     recentGlucose?.glucose
-                        .map { glucoseFormatter.string(from: Double(units == .mmolL ? $0.asMmolL : Decimal($0)) as NSNumber)! } ??
-                        "--"
+                        .map {
+                            glucoseFormatter
+                                .string(from: Double(units == .mmolL ? $0.asMmolL : Decimal($0)) as NSNumber)! }
+                        ?? "--"
                 )
-                .font(.largeTitle)
-                Spacer()
+                .font(.system(size: 24, weight: .bold))
+                image.padding(.bottom, 2)
+
+            }.padding(.leading, 4)
+            HStack(spacing: 2) {
                 Text(
                     recentGlucose.map { dateFormatter.string(from: $0.dateString) } ?? "--"
-                ).font(.caption)
-            }.padding(.leading, 4)
-            VStack {
-                Spacer()
-                image.padding(.bottom, 2)
+                ).font(.caption2).foregroundColor(.secondary)
                 Text(
                     delta
                         .map { deltaFormatter.string(from: Double(units == .mmolL ? $0.asMmolL : Decimal($0)) as NSNumber)!
                         } ??
                         "--"
 
-                ).font(.caption)
-                Text("\(units.rawValue)").font(.caption2)
+                ).font(.caption2).foregroundColor(.secondary)
             }
         }
     }

+ 9 - 10
FreeAPS/Sources/Modules/Home/View/Header/LoopView.swift

@@ -20,7 +20,7 @@ struct LoopView: View {
         return formatter
     }
 
-    private let rect = CGRect(x: 0, y: 0, width: 38, height: 38)
+    private let rect = CGRect(x: 0, y: 0, width: 32, height: 32)
     var body: some View {
         VStack(alignment: .center) {
             ZStack {
@@ -32,30 +32,29 @@ struct LoopView: View {
                     ProgressView()
                 }
             }
-
-            Spacer()
             if isLooping {
                 Text("looping").font(.caption2)
             } else if actualSuggestion?.timestamp != nil {
-                Text("\(Int((timerDate.timeIntervalSince(lastLoopDate) - Config.lag) / 60) + 1) min ago").font(.caption)
+                Text("\(Int((timerDate.timeIntervalSince(lastLoopDate) - Config.lag) / 60) + 1) min ago").font(.caption2)
+                    .foregroundColor(.secondary)
             } else {
-                Text("--").font(.caption)
+                Text("--").font(.caption2).foregroundColor(.secondary)
             }
-        }.padding(.trailing)
+        }.padding(.trailing, 4)
     }
 
     private var color: Color {
         guard actualSuggestion?.timestamp != nil else {
-            return Color(UIColor(named: "LoopGray")!)
+            return .loopGray
         }
         let delta = timerDate.timeIntervalSince(lastLoopDate) - Config.lag
 
         if delta <= 5.minutes.timeInterval {
-            return Color(UIColor(named: "LoopGreen")!)
+            return .loopGreen
         } else if delta <= 10.minutes.timeInterval {
-            return Color(UIColor(named: "LoopYellow")!)
+            return .loopYellow
         } else {
-            return Color(UIColor(named: "LoopRed")!)
+            return .loopRed
         }
     }
 

+ 12 - 16
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -10,7 +10,7 @@ struct PumpView: View {
     private var reservoirFormatter: NumberFormatter {
         let formatter = NumberFormatter()
         formatter.numberStyle = .decimal
-        formatter.maximumFractionDigits = 1
+        formatter.maximumFractionDigits = 0
         return formatter
     }
 
@@ -21,9 +21,7 @@ struct PumpView: View {
     }
 
     var body: some View {
-        VStack(alignment: .leading) {
-            Text(name).font(.caption)
-                .minimumScaleFactor(0.01)
+        VStack(alignment: .leading, spacing: 12) {
             if let reservoir = reservoir {
                 HStack {
                     Image(systemName: "drop.fill")
@@ -31,10 +29,9 @@ struct PumpView: View {
                         .aspectRatio(contentMode: .fit)
                         .frame(height: 8)
                         .foregroundColor(reservoirColor)
-                    Text(reservoirFormatter.string(from: reservoir as NSNumber)! + " U").font(.caption2)
+                    Text(reservoirFormatter.string(from: reservoir as NSNumber)! + " U").font(.system(size: 12, weight: .bold))
                 }
             }
-
             if let battery = battery, battery.display ?? false, expiresAtDate == nil {
                 HStack {
                     Image(systemName: "battery.100")
@@ -42,7 +39,7 @@ struct PumpView: View {
                         .aspectRatio(contentMode: .fit)
                         .frame(height: 8)
                         .foregroundColor(batteryColor)
-                    Text("\(Int(battery.percent ?? 100)) %").font(.caption2)
+                    Text("\(Int(battery.percent ?? 100)) %").font(.system(size: 12, weight: .bold))
                 }
             }
 
@@ -53,11 +50,10 @@ struct PumpView: View {
                         .aspectRatio(contentMode: .fit)
                         .frame(height: 8)
                         .foregroundColor(timerColor)
-                    Text(remainingTimeString(time: date.timeIntervalSince(timerDate))).font(.caption2)
+                    Text(remainingTimeString(time: date.timeIntervalSince(timerDate))).font(.system(size: 12, weight: .bold))
                 }
             }
-
-        }.padding(.leading)
+        }
     }
 
     private func remainingTimeString(time: TimeInterval) -> String {
@@ -86,11 +82,11 @@ struct PumpView: View {
 
         switch percent {
         case ...10:
-            return .red
+            return .loopRed
         case ...20:
-            return .orange
+            return .loopYellow
         default:
-            return .green
+            return .loopGreen
         }
     }
 
@@ -101,11 +97,11 @@ struct PumpView: View {
 
         switch reservoir {
         case ...10:
-            return .red
+            return .loopRed
         case ...30:
-            return .orange
+            return .loopYellow
         default:
-            return .blue
+            return .insulin
         }
     }
 

+ 42 - 29
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -9,11 +9,33 @@ extension Home {
         private var numberFormatter: NumberFormatter {
             let formatter = NumberFormatter()
             formatter.numberStyle = .decimal
+            formatter.maximumFractionDigits = 2
             return formatter
         }
 
         var header: some View {
-            HStack {
+            HStack(alignment: .bottom) {
+                VStack(alignment: .leading, spacing: 12) {
+                    HStack {
+                        Text("IOB").font(.caption2).foregroundColor(.secondary)
+                        Text((numberFormatter.string(from: (viewModel.suggestion?.iob ?? 0) as NSNumber) ?? "0") + " U")
+                            .font(.system(size: 12, weight: .bold))
+                    }
+                    HStack {
+                        Text("COB").font(.caption2).foregroundColor(.secondary)
+                        Text((numberFormatter.string(from: (viewModel.suggestion?.cob ?? 0) as NSNumber) ?? "0") + " g")
+                            .font(.system(size: 12, weight: .bold))
+                    }
+                }
+                .padding(.leading, 4)
+                Spacer()
+
+                CurrentGlucoseView(
+                    recentGlucose: $viewModel.recentGlucose,
+                    delta: $viewModel.glucoseDelta,
+                    units: viewModel.units
+                )
+                Spacer()
                 PumpView(
                     reservoir: $viewModel.reservoir,
                     battery: $viewModel.battery,
@@ -22,12 +44,6 @@ extension Home {
                     timerDate: $viewModel.timerDate
                 )
                 Spacer()
-                CurrentGlucoseView(
-                    recentGlucose: $viewModel.recentGlucose,
-                    delta: $viewModel.glucoseDelta,
-                    units: viewModel.units
-                ).frame(minWidth: 0, maxWidth: .infinity)
-                Spacer()
                 LoopView(
                     suggestion: $viewModel.suggestion,
                     enactedSuggestion: $viewModel.enactedSuggestion,
@@ -45,31 +61,28 @@ extension Home {
 
         var infoPanal: some View {
             HStack(alignment: .firstTextBaseline) {
-                Text("IOB").font(.caption)
-                    .padding(.leading)
-                Text((numberFormatter.string(from: (viewModel.suggestion?.iob ?? 0) as NSNumber) ?? "0") + " U")
-                    .font(.caption)
-
-                Text("COB").font(.caption)
-                Text((numberFormatter.string(from: (viewModel.suggestion?.cob ?? 0) as NSNumber) ?? "0") + " g")
-                    .font(.caption)
                 if let tempRate = viewModel.tempRate {
-                    Text("Temp basal").font(.caption).foregroundColor(.blue)
                     Text((numberFormatter.string(from: tempRate as NSNumber) ?? "0") + " U/hr")
-                        .font(.caption).foregroundColor(.blue)
+                        .font(.system(size: 12, weight: .bold)).foregroundColor(.insulin)
+                        .padding(.leading, 4)
                 }
 
+                if let tepmTargetName = viewModel.tempTargetName {
+                    Text(tepmTargetName).font(.caption).foregroundColor(.secondary)
+                }
                 Spacer()
-
-            }.frame(maxWidth: .infinity, maxHeight: 30)
-                .background(Rectangle().fill(Color.gray.opacity(0.2)))
+            }
+            .frame(maxWidth: .infinity, maxHeight: 30)
         }
 
         var body: some View {
-            viewModel.setFilteredGlucoseHours(hours: 24)
-            return GeometryReader { geo in
+            GeometryReader { geo in
                 VStack(spacing: 0) {
-                    header.padding(.vertical).frame(maxHeight: 70)
+                    header
+                        .frame(maxHeight: 70)
+                        .padding(.top, geo.safeAreaInsets.top)
+                        .background(Color.gray.opacity(0.2))
+
                     infoPanal
                     MainChartView(
                         glucose: $viewModel.glucose,
@@ -95,7 +108,7 @@ extension Home {
                                     .renderingMode(.template)
                                     .resizable()
                                     .frame(width: 24, height: 24)
-                            }.foregroundColor(.orange)
+                            }.foregroundColor(.loopGreen)
                             Spacer()
                             Button { viewModel.showModal(for: .addTempTarget) }
                             label: {
@@ -103,7 +116,7 @@ extension Home {
                                     .renderingMode(.template)
                                     .resizable()
                                     .frame(width: 24, height: 24)
-                            }.foregroundColor(.primary)
+                            }.foregroundColor(.loopYellow)
                             Spacer()
                             Button { viewModel.showModal(for: .bolus) }
                             label: {
@@ -111,7 +124,7 @@ extension Home {
                                     .renderingMode(.template)
                                     .resizable()
                                     .frame(width: 24, height: 24)
-                            }.foregroundColor(.blue)
+                            }.foregroundColor(.insulin)
                             Spacer()
                             if viewModel.allowManualTemp {
                                 Button { viewModel.showModal(for: .manualTempBasal) }
@@ -120,7 +133,7 @@ extension Home {
                                         .renderingMode(.template)
                                         .resizable()
                                         .frame(width: 24, height: 24)
-                                }.foregroundColor(.blue)
+                                }.foregroundColor(.insulin)
                                 Spacer()
                             }
                             Button { viewModel.showModal(for: .settings) }
@@ -129,13 +142,13 @@ extension Home {
                                     .renderingMode(.template)
                                     .resizable()
                                     .frame(width: 24, height: 24)
-                            }.foregroundColor(.gray)
+                            }.foregroundColor(.loopGray)
                         }
                         .padding(.horizontal, 24)
                         .padding(.bottom, geo.safeAreaInsets.bottom)
                     }
                 }
-                .edgesIgnoringSafeArea(.bottom)
+                .edgesIgnoringSafeArea(.vertical)
             }
             .navigationTitle("Home")
             .navigationBarHidden(true)