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

TIR. Display even when 0 %, by request.

Jon Mårtensson 2 лет назад
Родитель
Сommit
9e16af44f5

+ 2 - 2
FreeAPS/Sources/APS/FetchAnnouncementsManager.swift

@@ -33,8 +33,8 @@ final class BaseFetchAnnouncementsManager: FetchAnnouncementsManager, Injectable
             }
             .sink { announcements in
                 guard let last = announcements.filter({ $0.createdAt > self.announcementsStorage.syncDate() })
-                                    .sorted(by: { $0.createdAt < $1.createdAt })
-                                    .last
+                    .sorted(by: { $0.createdAt < $1.createdAt })
+                    .last
                 else { return }
 
                 self.announcementsStorage.storeAnnouncements([last], enacted: false)

+ 18 - 34
FreeAPS/Sources/Modules/Stat/View/ChartsView.swift

@@ -213,32 +213,23 @@ struct ChartsView: View {
                 let mapGlucoseAcuteLow = mapGlucose.filter({ $0 < Int16(3.3 / 0.0555) })
                 let mapGlucoseHigh = mapGlucose.filter({ $0 > Int16(11 / 0.0555) })
                 let mapGlucoseNormal = mapGlucose.filter({ $0 > Int16(3.8 / 0.0555) && $0 < Int16(7.9 / 0.0555) })
-
                 HStack {
                     let value = Double(mapGlucoseHigh.count * 100 / mapGlucose.count)
-                    if value != 0 {
-                        Text(units == .mmolL ? ">  11  " : ">  200 ").foregroundColor(.secondary)
-                        Text(value.formatted()).foregroundColor(.orange)
-                        Text("%").foregroundColor(.secondary)
-                    }
+                    Text(units == .mmolL ? ">  11  " : ">  200 ").foregroundColor(.secondary)
+                    Text(value.formatted()).foregroundColor(.orange)
+                    Text("%").foregroundColor(.secondary)
                 }.font(.caption)
-
                 HStack {
                     let value = Double(mapGlucoseNormal.count * 100 / mapGlucose.count)
-                    if value != 0 {
-                        Text(units == .mmolL ? "3.9-7.8" : "70-140").foregroundColor(.secondary)
-                        Text(value.formatted()).foregroundColor(.green)
-                        Text("%").foregroundColor(.secondary)
-                    }
+                    Text(units == .mmolL ? "3.9-7.8" : "70-140").foregroundColor(.secondary)
+                    Text(value.formatted()).foregroundColor(.green)
+                    Text("%").foregroundColor(.secondary)
                 }.font(.caption)
-
                 HStack {
                     let value = Double(mapGlucoseAcuteLow.count * 100 / mapGlucose.count)
-                    if value != 0 {
-                        Text(units == .mmolL ? "<  3.3 " : "<  59  ").foregroundColor(.secondary)
-                        Text(value.formatted()).foregroundColor(.red)
-                        Text("%").foregroundColor(.secondary)
-                    }
+                    Text(units == .mmolL ? "<  3.3 " : "<  59  ").foregroundColor(.secondary)
+                    Text(value.formatted()).foregroundColor(.red)
+                    Text("%").foregroundColor(.secondary)
                 }.font(.caption)
             }
         }
@@ -252,32 +243,25 @@ struct ChartsView: View {
                 let mapGlucoseLow = mapGlucose.filter({ $0 < Int16(3.3 / 0.0555) })
                 let mapGlucoseNormal = mapGlucose.filter({ $0 > Int16(3.8 / 0.0555) && $0 < Int16(7.9 / 0.0555) })
                 let mapGlucoseAcuteHigh = mapGlucose.filter({ $0 > Int16(11 / 0.0555) })
-
                 HStack {
                     let value = Double(mapGlucoseLow.count * 100 / mapGlucose.count)
-                    if value != 0 {
-                        Text(units == .mmolL ? "< 3.3" : "< 59").font(.caption2).foregroundColor(.secondary)
-                        Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .red)
-                        Text("%").font(.caption)
-                    }
+                    Text(units == .mmolL ? "< 3.3" : "< 59").font(.caption2).foregroundColor(.secondary)
+                    Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .red)
+                    Text("%").font(.caption)
                 }
                 Spacer()
                 HStack {
                     let value = Double(mapGlucoseNormal.count * 100 / mapGlucose.count)
-                    if value != 0 {
-                        Text(units == .mmolL ? "3.9-7.8" : "70-140").foregroundColor(.secondary)
-                        Text(value.formatted()).foregroundColor(.green)
-                        Text("%").foregroundColor(.secondary)
-                    }
+                    Text(units == .mmolL ? "3.9-7.8" : "70-140").foregroundColor(.secondary)
+                    Text(value.formatted()).foregroundColor(.green)
+                    Text("%").foregroundColor(.secondary)
                 }.font(.caption)
                 Spacer()
                 HStack {
                     let value = Double(mapGlucoseAcuteHigh.count * 100 / mapGlucose.count)
-                    if value != 0 {
-                        Text(units == .mmolL ? "> 11.0" : "> 216").font(.caption).foregroundColor(.secondary)
-                        Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .orange)
-                        Text("%").font(.caption)
-                    }
+                    Text(units == .mmolL ? "> 11.0" : "> 216").font(.caption).foregroundColor(.secondary)
+                    Text(value.formatted()).font(.caption).foregroundColor(value == 0 ? .green : .orange)
+                    Text("%").font(.caption)
                 }
             }
         }