فهرست منبع

Refactor TagCloudView, add conditional blur; cleanup WIP

Deniz Cengiz 1 سال پیش
والد
کامیت
cc982b5590

+ 12 - 10
FreeAPS/Sources/Modules/Home/View/Header/LoopStatusView.swift

@@ -12,7 +12,6 @@ struct LoopStatusView: View {
     var body: some View {
         NavigationStack {
             VStack(alignment: .leading, spacing: 10) {
-//                HStack {
                 Text("Current Loop Status").bold().padding(.top, 20)
 
                 Text(statusTitle)
@@ -23,9 +22,6 @@ struct LoopStatusView: View {
                     .background(statusBadgeColor)
                     .clipShape(Capsule())
 
-//                    Spacer()
-//                }
-
                 if let errorMessage = state.errorMessage, let date = state.errorDate {
                     Group {
                         Text("Error During Algorithm Run at \(Formatter.dateFormatter.string(from: date))").font(.headline)
@@ -35,11 +31,18 @@ struct LoopStatusView: View {
 
                 if let determination = state.determinationsFromPersistence.first {
                     if determination.glucose == 400 {
-                        Text("Invalid CGM reading (HIGH).").font(.callout).bold().foregroundColor(.loopRed)
-                            .padding(.top, 8)
-                        Text("SMBs and High Temps Disabled.").font(.caption).padding(.bottom, 4)
+                        Text("Invalid CGM reading (HIGH).")
+                            .bold()
+                            .padding(.top)
+                            .foregroundStyle(Color.loopRed)
+
+                        Text("SMBs and Non-Zero Temp. Basal Rates are disabled.")
+                            .font(.subheadline)
+
                     } else {
-                        Text("Latest Raw Algorithm Output").bold().padding(.top)
+                        Text("Latest Raw Algorithm Output")
+                            .bold()
+                            .padding(.top)
 
                         Text(
                             "Trio is currently using these metrics and values as determined by the oref algorithm:"
@@ -52,7 +55,6 @@ struct LoopStatusView: View {
                             tags: tags,
                             shouldParseToMmolL: state.units == .mmolL
                         )
-                        .animation(.none, value: false)
 
                         Text("Current Algorithm Reasoning").bold().padding(.top)
 
@@ -82,7 +84,7 @@ struct LoopStatusView: View {
             .padding(.vertical)
             .padding(.horizontal, 20)
             .presentationDetents(
-                [.fraction(0.75), .large],
+                [.fraction(0.8), .large],
                 selection: $sheetDetent
             )
             .ignoresSafeArea(edges: .top)

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

@@ -851,6 +851,7 @@ extension Home {
             .navigationTitle("Home")
             .navigationBarHidden(true)
             .ignoresSafeArea(.keyboard)
+            .blur(radius: state.isLoopStatusPresented ? 3 : 0)
             .sheet(isPresented: $state.isLoopStatusPresented) {
                 LoopStatusView(state: state)
             }

+ 9 - 7
FreeAPS/Sources/Views/TagCloudView.swift

@@ -7,7 +7,8 @@ struct TagCloudView: View {
     var tags: [String]
     var shouldParseToMmolL: Bool
 
-    @State private var totalHeight = CGFloat.infinity // << variant for VStack
+    @State private var totalHeight = CGFloat.zero // << variant for ScrollView/List
+//    = CGFloat.infinity // << variant for VStack
 
     var body: some View {
         VStack {
@@ -15,10 +16,11 @@ struct TagCloudView: View {
                 self.generateContent(in: geometry)
             }
         }
-        .frame(maxHeight: totalHeight) // << variant for VStack
+        .frame(height: totalHeight) // << variant for ScrollView/List
+//        .frame(maxHeight: totalHeight) // << variant for VStack
     }
 
-    private func generateContent(in g: GeometryProxy) -> some View {
+    private func generateContent(in geometry: GeometryProxy) -> some View {
         var width = CGFloat.zero
         var height = CGFloat.zero
 
@@ -26,16 +28,16 @@ struct TagCloudView: View {
             ForEach(self.tags, id: \.self) { tag in
                 self.drawTag(for: tag, isMmolL: shouldParseToMmolL)
                     .padding([.horizontal, .vertical], 2)
-                    .alignmentGuide(.leading, computeValue: { d in
-                        if abs(width - d.width) > g.size.width {
+                    .alignmentGuide(.leading, computeValue: { dimensions in
+                        if abs(width - dimensions.width) > geometry.size.width {
                             width = 0
-                            height -= d.height
+                            height -= dimensions.height
                         }
                         let result = width
                         if tag == self.tags.last! {
                             width = 0 // last item
                         } else {
-                            width -= d.width
+                            width -= dimensions.width
                         }
                         return result
                     })