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

try to adjust graph to current time when changing x axis scale in picker

polscm32 2 лет назад
Родитель
Сommit
09dfb42f38

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

@@ -99,6 +99,8 @@ struct MainChartView: View {
     @State private var offset: CGFloat = 0
     @State private var cachedMaxBasalRate: Decimal?
 
+    @State var state: Home.StateModel
+
     private let calculationQueue = DispatchQueue(label: "MainChartView.calculationQueue")
 
     private var dateFormatter: DateFormatter {
@@ -195,6 +197,9 @@ struct MainChartView: View {
                         .onChange(of: tempBasals) { _ in
                             scroll.scrollTo(Config.endID, anchor: .trailing)
                         }
+                        .onChange(of: state.scale) { _ in
+                            scroll.scrollTo(Config.endID, anchor: .trailing)
+                        }
                         .onAppear {
                             // add trigger to the end of main queue
                             DispatchQueue.main.async {

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

@@ -404,7 +404,8 @@ extension Home {
                     screenHours: $state.screenHours,
                     displayXgridLines: $state.displayXgridLines,
                     displayYgridLines: $state.displayYgridLines,
-                    thresholdLines: $state.thresholdLines
+                    thresholdLines: $state.thresholdLines,
+                    state: state
                 )
             }
             .padding(.bottom)