Sfoglia il codice sorgente

Pass state instead of using Environment var

Mike Plante 11 mesi fa
parent
commit
8c7fa2423d

+ 6 - 4
Trio/Sources/Modules/Stat/View/StatRootView.swift

@@ -163,8 +163,9 @@ extension Stat {
                                 units: state.units,
                                 timeInRangeType: state.timeInRangeType,
                                 selectedInterval: interval,
-                                isDaySelected: $isGlucoseDaySelected
-                            ).environment(state)
+                                isDaySelected: $isGlucoseDaySelected,
+                                state: state
+                            )
                         } else { // if state.selectedGlucoseChartType == .distributionByDay
                             GlucoseDailyDistributionChart(
                                 glucose: state.glucoseReadings,
@@ -173,8 +174,9 @@ extension Stat {
                                 timeInRangeType: state.timeInRangeType,
                                 selectedInterval: interval,
                                 eA1cDisplayUnit: state.eA1cDisplayUnit,
-                                isDaySelected: $isGlucoseDaySelected
-                            ).environment(state)
+                                isDaySelected: $isGlucoseDaySelected,
+                                state: state
+                            )
                         }
 
                     case .percentileByTime:

+ 1 - 1
Trio/Sources/Modules/Stat/View/ViewElements/Glucose/GlucoseDailyDistributionChart.swift

@@ -18,7 +18,7 @@ struct GlucoseDailyDistributionChart: View {
     @State private var visibleGlucose: [GlucoseStored] = []
 
     // State model for accessing the shared data
-    @Environment(Stat.StateModel.self) private var state
+    let state: Stat.StateModel
 
     // Computes the visible date range based on the current scroll position
     @State private var visibleDateRange: (start: Date, end: Date) = (Date(), Date())

+ 1 - 1
Trio/Sources/Modules/Stat/View/ViewElements/Glucose/GlucoseDailyPercentileChart.swift

@@ -45,7 +45,7 @@ struct GlucoseDailyPercentileChart: View {
     @State private var selectedPercentile: GlucosePercentileType?
 
     // State model for accessing the shared calculations
-    @Environment(Stat.StateModel.self) private var state
+    let state: Stat.StateModel
 
     // Computes the visible date range based on the current scroll position
     @State private var visibleDateRange: (start: Date, end: Date) = (Date(), Date())