Преглед на файлове

when notificationsDisabled, add alertSafetyNotificationsView to safeAreaInset and reduce size of mainChart

kskandis преди 1 година
родител
ревизия
1d0700783a

+ 1 - 1
FreeAPS/Sources/Modules/Adjustments/AdjustmentsStateModel+Extensions/AdjustmentsStateModel+Overrides.swift

@@ -32,7 +32,7 @@ extension Adjustments.StateModel {
     @MainActor func disableAllActiveOverrides(except overrideID: NSManagedObjectID? = nil, createOverrideRunEntry: Bool) async {
         // Get ALL NSManagedObject IDs of ALL active Override to cancel every single Override
         let ids = await overrideStorage.loadLatestOverrideConfigurations(fetchLimit: 0)
-        
+
         await viewContext.perform {
             do {
                 // Fetch the existing OverrideStored objects from the context

+ 3 - 1
FreeAPS/Sources/Modules/Home/View/Chart/DummyCharts.swift

@@ -38,7 +38,9 @@ extension MainChartView {
             }
         }
         .id("DummyMainChart")
-        .frame(minHeight: geo.size.height * 0.28)
+        .frame(
+            minHeight: geo.size.height * (0.28 - safeAreaSize)
+        )
         .frame(width: screenSize.width - 10)
         .chartXAxis { mainChartXAxis }
         .chartXScale(domain: startMarker ... endMarker)

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

@@ -7,6 +7,7 @@ let calendar = Calendar.current
 
 struct MainChartView: View {
     var geo: GeometryProxy
+    var safeAreaSize: CGFloat
     var units: GlucoseUnits
     var hours: Int
     var tempTargets: [TempTarget]
@@ -213,7 +214,9 @@ extension MainChartView {
             .onChange(of: state.insulinFromPersistence) {
                 state.roundedTotalBolus = state.calculateTINS()
             }
-            .frame(minHeight: geo.size.height * 0.28)
+            .frame(
+                minHeight: geo.size.height * (0.28 - safeAreaSize)
+            )
             .frame(width: fullWidth(viewWidth: screenSize.width))
             .chartXScale(domain: startMarker ... endMarker)
             .chartXAxis { mainChartXAxis }

+ 8 - 12
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -7,6 +7,7 @@ import Swinject
 extension Home {
     struct RootView: BaseView {
         let resolver: Resolver
+        let safeAreaSize: CGFloat = 0.08
 
         @State var state = StateModel()
         @State var isStatusPopupPresented = false
@@ -21,7 +22,6 @@ extension Home {
         @State private var statusTitle: String = ""
         @State var showPumpSelection: Bool = false
         @State var notificationsDisabled = false
-        @State var alertSafetyNotificationsViewHeight = 0
 
         struct Buttons: Identifiable {
             let label: String
@@ -335,6 +335,7 @@ extension Home {
             ZStack {
                 MainChartView(
                     geo: geo,
+                    safeAreaSize: notificationsDisabled == true ? safeAreaSize : 0,
                     units: state.units,
                     hours: state.filteredHours,
                     tempTargets: state.tempTargets,
@@ -792,7 +793,7 @@ extension Home {
                         )
                     )
                     .clipShape(RoundedRectangle(cornerRadius: 15))
-                    .frame(height: geo.size.height * 0.08)
+                    .frame(height: geo.size.height * safeAreaSize)
                     .coordinateSpace(name: "alertSafetyNotificationsView")
                     .shadow(
                         color: colorScheme == .dark ? Color(red: 0.02745098039, green: 0.1098039216, blue: 0.1411764706) :
@@ -843,17 +844,12 @@ extension Home {
                         pumpView
                         Spacer()
                     }.padding(.leading, 20)
-
-                    if notificationsDisabled {
-                        alertSafetyNotificationsView(geo: geo)
-                            // maybe experiment with safeAreaInset() or similar to avoid overlapping with the dynamic island
-                            .offset(
-                                y: -geo.size
-                                    .height *
-                                    0.075
-                            )
-                    }
                 }.padding(.top, 10)
+                    .safeAreaInset(edge: .top, spacing: 0) {
+                        if notificationsDisabled {
+                            alertSafetyNotificationsView(geo: geo)
+                        }
+                    }
 
                 mealPanel(geo).padding(.top, UIDevice.adjustPadding(min: nil, max: 30))
                     .padding(.bottom, UIDevice.adjustPadding(min: nil, max: 20))