Yakov Karpov před 5 roky
rodič
revize
cbcc4cb09c

+ 0 - 4
FreeAPS.xcodeproj/project.pbxproj

@@ -205,7 +205,6 @@
 		63E890B4D951EAA91C071D5C /* BasalProfileEditorViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAFF91130F2FCCC7EBBA11AD /* BasalProfileEditorViewModel.swift */; };
 		642F76A05A4FF530463A9FD0 /* NightscoutConfigRootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8782B44544F38F2B2D82C38E /* NightscoutConfigRootView.swift */; };
 		6610FA1525FAED29004781D7 /* SampleData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6610F9F325FAED29004781D7 /* SampleData.swift */; };
-		6610FA1625FAED29004781D7 /* BloodGlucose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6610F9F525FAED29004781D7 /* BloodGlucose.swift */; };
 		6610FA1725FAED29004781D7 /* PointData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6610F9F625FAED29004781D7 /* PointData.swift */; };
 		6610FA1825FAED29004781D7 /* BoundTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6610F9F725FAED29004781D7 /* BoundTypes.swift */; };
 		6610FA1925FAED29004781D7 /* InformationBarEntryData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6610F9F825FAED29004781D7 /* InformationBarEntryData.swift */; };
@@ -497,7 +496,6 @@
 		618E62C9757B2F95431B5DC0 /* AddCarbsProvider.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = AddCarbsProvider.swift; sourceTree = "<group>"; };
 		64AA5E04A2761F6EEA6568E1 /* CREditorViewModel.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = CREditorViewModel.swift; sourceTree = "<group>"; };
 		6610F9F325FAED29004781D7 /* SampleData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleData.swift; sourceTree = "<group>"; };
-		6610F9F525FAED29004781D7 /* BloodGlucose.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BloodGlucose.swift; sourceTree = "<group>"; };
 		6610F9F625FAED29004781D7 /* PointData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PointData.swift; sourceTree = "<group>"; };
 		6610F9F725FAED29004781D7 /* BoundTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoundTypes.swift; sourceTree = "<group>"; };
 		6610F9F825FAED29004781D7 /* InformationBarEntryData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InformationBarEntryData.swift; sourceTree = "<group>"; };
@@ -1296,7 +1294,6 @@
 		6610F9F425FAED29004781D7 /* Models */ = {
 			isa = PBXGroup;
 			children = (
-				6610F9F525FAED29004781D7 /* BloodGlucose.swift */,
 				6610F9F625FAED29004781D7 /* PointData.swift */,
 				6610F9F725FAED29004781D7 /* BoundTypes.swift */,
 				6610F9F825FAED29004781D7 /* InformationBarEntryData.swift */,
@@ -1703,7 +1700,6 @@
 				6610FA2A25FAED29004781D7 /* GlucosePointView.swift in Sources */,
 				3811DE8925C9D6DD00A708ED /* RequestPermissionsProvider.swift in Sources */,
 				6610FA1D25FAED29004781D7 /* PredictionLineData.swift in Sources */,
-				6610FA1625FAED29004781D7 /* BloodGlucose.swift in Sources */,
 				3811DE4225C9D4A100A708ED /* SettingsDataFlow.swift in Sources */,
 				3811DE8825C9D6DD00A708ED /* RequestPermissionsDataFlow.swift in Sources */,
 				3811DE8A25C9D6DD00A708ED /* RequestPermissionsRootView.swift in Sources */,

+ 1 - 1
FreeAPS/Sources/Charts/Extensions/Double+getBoundGlucose().swift

@@ -2,7 +2,7 @@ import Foundation
 
 extension Array where Element: Comparable {
     func getBoundGlucose(boundType: BoundTypes, bound: Element) -> Element {
-        guard let extremum = (boundType == .top) ? self.max() : self.min() else {
+        guard let extremum = (boundType == .top) ? max() : min() else {
             return bound
         }
         if (boundType == .top) ? extremum < bound : extremum > bound {

+ 1 - 5
FreeAPS/Sources/Charts/Extensions/View+Modifiers.swift

@@ -1,15 +1,11 @@
 import SwiftUI
 
-private enum Config {
-    static let defaultCornerRadius: CGFloat = 10
-}
-
 private struct InformationBarEntryModifier: ViewModifier {
     func body(content: Content) -> some View {
         content
             .frame(maxWidth: .infinity, maxHeight: .infinity)
             .background(Color(.systemGray6))
-            .cornerRadius(Config.defaultCornerRadius)
+            .cornerRadius(10)
     }
 }
 

+ 1 - 1
FreeAPS/Sources/Charts/Extensions/View+if().swift

@@ -1,7 +1,7 @@
 import SwiftUI
 
 extension View {
-    @ViewBuilder  func `if`<Transform: View>(
+    @ViewBuilder func `if`<Transform: View>(
         _ condition: Bool,
         transform: (Self) -> Transform
     ) -> some View {

+ 3 - 3
FreeAPS/Sources/Charts/Helpers/getGlucoseArrowImage().swift

@@ -2,14 +2,14 @@ import SwiftUI
 
 func getGlucoseArrowImage(for delta: BloodGlucose.Direction) -> Image {
     let arrow: String
-    
+
     let up = "arrow.up"
     let upForward = "arrow.up.forward"
     let forward = "arrow.forward"
     let downForward = "arrow.down.forward"
     let down = "arrow.down"
     let error = "arrow.left.arrow.right"
-    
+
     switch delta {
     case .tripleUp:
         arrow = up
@@ -36,6 +36,6 @@ func getGlucoseArrowImage(for delta: BloodGlucose.Direction) -> Image {
     case .rateOutOfRange:
         arrow = error
     }
-    
+
     return Image(systemName: arrow)
 }

+ 6 - 6
FreeAPS/Sources/Charts/Helpers/getPredictionColor().swift

@@ -2,17 +2,17 @@ import SwiftUI
 
 func getPredictionColor(for type: PredictionType, value: Int?) -> Color {
     let color: Color
-    
+
     switch type {
-    case .IOB:
+    case .iob:
         color = Color(.systemTeal)
-    case .COB:
+    case .cob:
         color = Color(.systemOrange)
-    case .ZT:
+    case .zt:
         color = Color(.systemPink)
-    case .UAM:
+    case .uam:
         color = Color(.systemIndigo)
     }
-    
+
     return color.opacity(value != nil ? 1 : 0)
 }

+ 0 - 38
FreeAPS/Sources/Charts/Models/BloodGlucose.swift

@@ -1,38 +0,0 @@
-//
-//  BloodGlucose.swift
-//  free-aps-charts-final
-//
-//  Created by Яков Карпов on 12.03.2021.
-//
-
-import Foundation
-
-struct BloodGlucose: Identifiable, Hashable {
-    var id = UUID()
-    
-    enum Direction: String {
-        case tripleUp = "TripleUp"
-        case doubleUp = "DoubleUp"
-        case singleUp = "SingleUp"
-        case fortyFiveUp = "FortyFiveUp"
-        case flat = "Flat"
-        case fortyFiveDown = "FortyFiveDown"
-        case singleDown = "SingleDown"
-        case doubleDown = "DoubleDown"
-        case tripleDown = "TripleDown"
-        case none = "NONE"
-        case notComputable = "NOT COMPUTABLE"
-        case rateOutOfRange = "RATE OUT OF RANGE"
-    }
-
-    var sgv: Int?
-    let direction: Direction?
-    let date: UInt64
-    let dateString: Date
-    let filtered: Double?
-    let noise: Int?
-
-    var glucose: Int?
-
-    var isStateValid: Bool { sgv ?? 0 >= 39 && noise ?? 1 != 4 }
-}

+ 0 - 7
FreeAPS/Sources/Charts/Models/GlucosePointData.swift

@@ -1,13 +1,6 @@
 import SwiftUI
 
 public struct GlucosePointData: PointData {
-    public init(id: UUID = UUID(), value: Int? = nil, xPosition: CGFloat, yPosition: CGFloat? = nil) {
-        self.id = id
-        self.value = value
-        self.xPosition = xPosition
-        self.yPosition = yPosition
-    }
-
     public var id = UUID()
     public let value: Int?
     public let xPosition: CGFloat

+ 0 - 7
FreeAPS/Sources/Charts/Models/InformationBarEntryData.swift

@@ -1,13 +1,6 @@
 import Foundation
 
 public struct InformationBarEntryData: Identifiable, Hashable {
-    public init(id: UUID = UUID(), label: String, type: APSDataTypes, value: Double) {
-        self.id = id
-        self.label = label
-        self.value = value
-        self.type = type
-    }
-
     public var id = UUID()
     let label: String
     let value: Double

+ 0 - 1
FreeAPS/Sources/Charts/Models/PredictionLineData.swift

@@ -1,7 +1,6 @@
 import Foundation
 
 public struct PredictionLineData: Identifiable, Hashable {
-
     public var id = UUID()
     let type: PredictionType
     let values: [BloodGlucose]

+ 4 - 4
FreeAPS/Sources/Charts/Models/PredictionType.swift

@@ -1,8 +1,8 @@
 import SwiftUI
 
 public enum PredictionType: String {
-    case IOB
-    case COB
-    case ZT
-    case UAM
+    case iob
+    case cob
+    case zt
+    case uam
 }

+ 19 - 21
FreeAPS/Sources/Charts/Sample Data/SampleData.swift

@@ -1,15 +1,7 @@
-//
-//  SampleData.swift
-//  FreeAPSCharts
-//
-//  Created by Яков Карпов on 08.03.2021.
-//
-
 import Foundation
 
 enum SampleData {
-    
-    static private var baseComponents: DateComponents = {
+    private static var baseComponents: DateComponents = {
         var dateComponents = DateComponents()
         dateComponents.year = 2021
         dateComponents.month = 3
@@ -18,36 +10,42 @@ enum SampleData {
         dateComponents.hour = 8
         return dateComponents
     }()
-    
-    static private func generateDate(baseDateComponents: DateComponents, minutes: Int) -> Date {
+
+    private static func generateDate(baseDateComponents: DateComponents, minutes: Int) -> Date {
         var localComponents = baseDateComponents
         localComponents.minute = minutes
         let userCalendar = Calendar(identifier: .gregorian)
         return userCalendar.date(from: localComponents)!
     }
-    
-    static private func generateGlucoseStream(startingPoint: Int, length: Int, amount: Int, direction: Int) -> [Int] {
-        
+
+    private static func generateGlucoseStream(startingPoint: Int, length: Int, amount: Int, direction: Int) -> [Int] {
         // Downwards
         if direction == 0 {
             return (1 ... length).map { startingPoint - $0 * amount }
         }
         return (1 ... length).map { startingPoint + $0 * amount }
     }
-    
+
     static var sampleData: [BloodGlucose] {
         let mediumUp = generateGlucoseStream(startingPoint: 77, length: 80, amount: 2, direction: 1)
         let fastUp = generateGlucoseStream(startingPoint: mediumUp.last!, length: 20, amount: 5, direction: 1)
         let fastDown = generateGlucoseStream(startingPoint: fastUp.last!, length: 12, amount: 13, direction: 0)
         let mediumDown = generateGlucoseStream(startingPoint: fastDown.last!, length: 33, amount: 3, direction: 0)
         let slowUp = generateGlucoseStream(startingPoint: mediumDown.last!, length: 144, amount: 1, direction: 1)
-        
+
         let glucose = mediumUp + fastUp + fastDown + mediumDown + slowUp
-        let normalTime = (0 ... 278).map{ generateDate(baseDateComponents: baseComponents, minutes: $0 * 5) }
-        let tenMinutes = (279 ... 288).map{ generateDate(baseDateComponents: baseComponents, minutes: $0 * 30) }
+        let normalTime = (0 ... 278).map { generateDate(baseDateComponents: baseComponents, minutes: $0 * 5) }
+        let tenMinutes = (279 ... 288).map { generateDate(baseDateComponents: baseComponents, minutes: $0 * 30) }
         let time = normalTime + tenMinutes
-        
-        
-        return zip(glucose, time).map { BloodGlucose(sgv: $0, direction: nil, date: UInt64($1.timeIntervalSince1970), dateString: $1, filtered: nil, noise: nil, glucose: nil) }
+
+        return zip(glucose, time).map { BloodGlucose(
+            sgv: $0,
+            direction: nil,
+            date: UInt64($1.timeIntervalSince1970),
+            dateString: $1,
+            filtered: nil,
+            noise: nil,
+            glucose: nil
+        ) }
     }
 }

+ 20 - 18
FreeAPS/Sources/Charts/Views/Charts/PointChartView.swift

@@ -13,14 +13,15 @@ struct PointChartView<PointEntry: View>: View {
                     data: glucoseData,
                     height: geometry.size.height,
                     width: width,
-                    showHours: showHours),
+                    showHours: showHours
+                ),
                 id: \.self
             ) { point in
                 pointEntry(point.value)
                     .position(x: point.xPosition, y: point.yPosition ?? 0)
             }
         }
-        .frame(width: 1000)
+        .frame(width: 10000)
     }
 }
 
@@ -30,14 +31,14 @@ private func getGlucosePoints(
     width: CGFloat,
     showHours: Int
 ) -> [GlucosePointData] {
-    let values = data.compactMap { $0.sgv }
-    
+    let values = data.compactMap(\.sgv)
+
     let maxValue = values.max() ?? 180
     let minValue = values.min() ?? 60
     let firstEntryTime = data
-        .compactMap { $0.date }
+        .map(\.date)
         .first ?? UInt64(Date().timeIntervalSince1970)
-    
+
     let pointSize: CGFloat = ChartsConfig.glucosePointSize / 2
 
     /// y = mx + b where m = scalingFactor, b = addendum, x = value, y = mapped value
@@ -47,12 +48,14 @@ private func getGlucosePoints(
 
     return data.map { glucose in
         let xPositionIndex = CGFloat(glucose.date - firstEntryTime) / CGFloat(300 * showHours)
-        
+
         let xPosition = (xPositionIndex * width / CGFloat(Double(showHours) * hoursMultiplier)) + pointSize
-        
+
         guard let value = glucose.sgv else {
             return GlucosePointData(
-                xPosition: xPosition
+                value: nil,
+                xPosition: xPosition,
+                yPosition: nil
             )
         }
         return GlucosePointData(
@@ -64,16 +67,15 @@ private func getGlucosePoints(
 }
 
 struct PointChartView_Previews: PreviewProvider {
-    
     static let sampleData = Array(SampleData.sampleData)
-    
+
     static let testingData = [
-        BloodGlucose(sgv: 3, direction: nil, date: 1615179600, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
-        BloodGlucose(sgv: 4, direction: nil, date: 1615179900, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
-        BloodGlucose(sgv: 5, direction: nil, date: 1615180200, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
-        BloodGlucose(sgv: 6, direction: nil, date: 1615180200, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
-        BloodGlucose(sgv: 7, direction: nil, date: 1615180800, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
-        BloodGlucose(sgv: 8, direction: nil, date: 1615181300, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
+        BloodGlucose(sgv: 3, direction: nil, date: 1_615_179_600, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
+        BloodGlucose(sgv: 4, direction: nil, date: 1_615_179_900, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
+        BloodGlucose(sgv: 5, direction: nil, date: 1_615_180_200, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
+        BloodGlucose(sgv: 6, direction: nil, date: 1_615_180_200, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
+        BloodGlucose(sgv: 7, direction: nil, date: 1_615_180_800, dateString: Date(), filtered: nil, noise: nil, glucose: nil),
+        BloodGlucose(sgv: 8, direction: nil, date: 1_615_181_300, dateString: Date(), filtered: nil, noise: nil, glucose: nil)
     ]
 
     static var previews: some View {
@@ -88,7 +90,7 @@ struct PointChartView_Previews: PreviewProvider {
                 }
             }
             .padding(.vertical)
-            
+
             .preferredColorScheme(/*@START_MENU_TOKEN@*/ .dark/*@END_MENU_TOKEN@*/)
         }
     }

+ 9 - 9
FreeAPS/Sources/Charts/Views/Charts/PredictionsChartView.swift

@@ -13,7 +13,7 @@ public struct PredictionsChartView: View {
                         width: 500,
                         showHours: 1,
                         glucoseData: predictionLine.values
-                    )  { value in
+                    ) { value in
                         PredictionPointView(predictionType: predictionLine.type, value: value)
                     }
                 }
@@ -25,21 +25,21 @@ public struct PredictionsChartView: View {
 struct PredictionsChartView_Previews: PreviewProvider {
     static let data = [
         PredictionLineData(
-            type: .COB,
-            values: Array(SampleData.sampleData[0...10])
+            type: .iob,
+            values: Array(SampleData.sampleData[0 ... 10])
         ),
-        PredictionLineData(type: .IOB, values: Array(SampleData.sampleData[1...20])),
+        PredictionLineData(type: .cob, values: Array(SampleData.sampleData[1 ... 20])),
         PredictionLineData(
-            type: .UAM,
-            values: Array(SampleData.sampleData[21...30])
+            type: .uam,
+            values: Array(SampleData.sampleData[21 ... 30])
         ),
-        PredictionLineData(type: .ZT, values: Array(SampleData.sampleData[31...40]))
+        PredictionLineData(type: .zt, values: Array(SampleData.sampleData[31 ... 40]))
     ]
 
     static var previews: some View {
         ScrollView(.horizontal) {
-        PredictionsChartView(data: data, width: 400, showHours: 1)
+            PredictionsChartView(data: data, width: 400, showHours: 1)
         }
-            .preferredColorScheme(/*@START_MENU_TOKEN@*/ .dark/*@END_MENU_TOKEN@*/)
+        .preferredColorScheme(/*@START_MENU_TOKEN@*/ .dark/*@END_MENU_TOKEN@*/)
     }
 }

+ 0 - 7
FreeAPS/Sources/Charts/Views/ChartsConfig.swift

@@ -1,10 +1,3 @@
-//
-//  Config.swift
-//  free-aps-charts-final
-//
-//  Created by Яков Карпов on 12.03.2021.
-//
-
 import SwiftUI
 
 enum ChartsConfig {

+ 1 - 1
FreeAPS/Sources/Charts/Views/Components/GlucoseArrowView.swift

@@ -16,7 +16,7 @@ struct GlucoseArrowView_Previews: PreviewProvider {
             .frame(
                 width: 100,
                 height: 100,
-                alignment:  .center
+                alignment: .center
             )
             .preferredColorScheme(/*@START_MENU_TOKEN@*/ .dark/*@END_MENU_TOKEN@*/)
     }

+ 20 - 21
FreeAPS/Sources/Charts/Views/Components/GlucoseInformationBarView.swift

@@ -13,31 +13,30 @@ public struct GlucoseInformationBarView: View {
                 ForEach(halvedEntryData, id: \.self) { half in
                     HStack {
                         ForEach(half, id: \.self) { dataEntry in
-                                Text(
-                                    dataEntry.label + "\n" +
-                                        APSDataFormatter.format(
-                                            inputValue: dataEntry.value,
-                                            to: dataEntry.type
-                                        )
-                                    
-                                )
-                                .font(.footnote)
-                                .informationBarEntryStyle()
-                                .padding(.bottom, 1)
+                            Text(
+                                dataEntry.label + "\n" +
+                                    APSDataFormatter.format(
+                                        inputValue: dataEntry.value,
+                                        to: dataEntry.type
+                                    )
+                            )
+                            .font(.footnote)
+                            .informationBarEntryStyle()
+                            .padding(.bottom, 1)
                         }
                     }
                 }
             }
-                Text(APSDataFormatter.format(inputValue: glucoseValue, to: .glucose))
-                    .font(.largeTitle)
-                    .foregroundColor(Color(.systemBlue))
-                    .informationBarEntryStyle()
+            Text(APSDataFormatter.format(inputValue: glucoseValue, to: .glucose))
+                .font(.largeTitle)
+                .foregroundColor(Color(.systemBlue))
+                .informationBarEntryStyle()
             VStack {
                 GlucoseArrowView(direction: direction)
                     .padding(.bottom, 1)
-                    Text(APSDataFormatter.format(inputValue: glucoseDelta, to: .delta))
-                        .informationBarEntryStyle()
-                .padding(.bottom, 1)
+                Text(APSDataFormatter.format(inputValue: glucoseDelta, to: .delta))
+                    .informationBarEntryStyle()
+                    .padding(.bottom, 1)
             }
         }
         .padding(.bottom, -1)
@@ -46,9 +45,9 @@ public struct GlucoseInformationBarView: View {
 
 struct GlucoseInformationBarView_Previews: PreviewProvider {
     static let data = [
-        InformationBarEntryData(label: "COB: ", type: .cob, value: 33),
-        InformationBarEntryData(label: "COB: ", type: .cob, value: 33),
-        InformationBarEntryData(label: "COB: ", type: .cob, value: 33),
+        InformationBarEntryData(label: "COB: ", value: 33, type: .cob),
+        InformationBarEntryData(label: "COB: ", value: 33, type: .cob),
+        InformationBarEntryData(label: "COB: ", value: 33, type: .cob)
 //        InformationBarEntryData(label: "COB: ", type: .cob, value: 33),
     ]
     static var previews: some View {

+ 1 - 2
FreeAPS/Sources/Charts/Views/Points/GlucosePointView.swift

@@ -2,7 +2,7 @@ import SwiftUI
 
 struct GlucosePointView: View {
     let value: Int?
-    
+
     var body: some View {
         Circle()
             .foregroundColor(
@@ -10,7 +10,6 @@ struct GlucosePointView: View {
             )
             .frame(width: ChartsConfig.glucosePointSize, height: ChartsConfig.glucosePointSize)
             .opacity(value != nil ? 1 : 0)
-            
     }
 }
 

+ 2 - 2
FreeAPS/Sources/Charts/Views/Points/PredictionPointView.swift

@@ -3,7 +3,7 @@ import SwiftUI
 struct PredictionPointView: View {
     let predictionType: PredictionType
     let value: Int?
-    
+
     var body: some View {
         Circle()
             .strokeBorder(
@@ -17,7 +17,7 @@ struct PredictionPointView: View {
 
 struct PredictionPointView_Previews: PreviewProvider {
     static var previews: some View {
-        PredictionPointView(predictionType: .COB, value: 3)
+        PredictionPointView(predictionType: .iob, value: 3)
             .preferredColorScheme(/*@START_MENU_TOKEN@*/ .dark/*@END_MENU_TOKEN@*/)
     }
 }

+ 2 - 1
FreeAPS/Sources/Models/BloodGlucose.swift

@@ -1,6 +1,6 @@
 import Foundation
 
-struct BloodGlucose: JSON {
+struct BloodGlucose: JSON, Identifiable, Hashable {
     enum Direction: String, JSON {
         case tripleUp = "TripleUp"
         case doubleUp = "DoubleUp"
@@ -16,6 +16,7 @@ struct BloodGlucose: JSON {
         case rateOutOfRange = "RATE OUT OF RANGE"
     }
 
+    var id = UUID().uuidString
     var sgv: Int?
     let direction: Direction?
     let date: UInt64

+ 13 - 1
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -3,6 +3,7 @@ import SwiftUI
 extension Home {
     struct RootView: BaseView {
         @EnvironmentObject var viewModel: ViewModel<Provider>
+        @State var showHours = 1
 
         var body: some View {
             GeometryReader { geo in
@@ -11,7 +12,18 @@ extension Home {
                         Text("Header")
                     }
                     ScrollView(.vertical, showsIndicators: false) {
-                        GlucoseChartView(glucose: $viewModel.glucose, suggestion: $viewModel.suggestion).frame(height: 150)
+                        HoursPickerView(selectedHour: $showHours)
+                        ScrollView(.horizontal, showsIndicators: false) {
+                            PointChartView(
+                                width: geo.size.width,
+                                showHours: showHours,
+                                glucoseData: SampleData.sampleData
+                            ) { value in
+                                GlucosePointView(value: value)
+                            }
+                        }.frame(height: 300)
+
+                        // GlucoseChartView(glucose: $viewModel.glucose, suggestion: $viewModel.suggestion).frame(height: 150)
                         if let reason = viewModel.suggestion?.reason {
                             Text(reason).font(.caption).padding()
                         }