Jon B Mårtensson 3 лет назад
Родитель
Сommit
bf4fec0e34

+ 1 - 1
Config.xcconfig

@@ -1,5 +1,5 @@
 APP_DISPLAY_NAME = FreeAPS X
-APP_VERSION = 0.6.3
+APP_VERSION = 0.6.4
 APP_BUILD_NUMBER = 1
 COPYRIGHT_NOTICE = 
 DEVELOPER_TEAM = ##TEAM_ID##

+ 3 - 0
FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings

@@ -1286,6 +1286,9 @@ Enact a temp Basal or a temp target */
 /* Description for Override HbA1c unit */
 "Change default HbA1c unit in statPanlel. The unit in statPanel will be updateded with next statistics.json update" = "Change default HbA1c unit in statPanlel. The unit in statPanel will be updateded with next statistics.json update";
 
+/* HbA1c for all glucose storage days */
+"all" = "all";
+
  /* --------------------------------------
 
   Infotexts from openaps.docs and androidaps.docs

+ 3 - 0
FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings

@@ -1282,6 +1282,9 @@ Enact a temp Basal or a temp target */
 /* Description for Override HbA1c unit */
 "Change default HbA1c unit in statPanlel. The unit in statPanel will be updateded with next statistics.json update" = "Ändra HbA1c-enhet. Enheten kommer att uppdateras nästa gång filen statistics.json uppdateras";
 
+/* HbA1c for all glucose storage days */
+"all" = "alla";
+
 /* --------------------------------------
 
   Infotexts from openaps.docs and androidaps.docs

+ 2 - 0
FreeAPS/Sources/Modules/Home/DurationButton.swift

@@ -35,5 +35,7 @@ struct durationButton<T: DurationButton>: View {
         .buttonBorderShape(.automatic)
         .controlSize(.mini)
         .buttonStyle(.bordered)
+        // .padding([.trailing], 15)
+        // .frame(maxWidth: .infinity, alignment: .trailing)
     }
 }

+ 84 - 82
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -11,6 +11,8 @@ extension Home {
         @State var isStatusPopupPresented = false
         @State var selectedState: durationState
 
+        public let paddingSpace: CGFloat = 15
+
         private var numberFormatter: NumberFormatter {
             let formatter = NumberFormatter()
             formatter.numberStyle = .decimal
@@ -227,15 +229,8 @@ extension Home {
 
         @ViewBuilder private func statPanel() -> some View {
             if state.displayStatistics {
-                VStack(alignment: .center, spacing: 5) {
-                    HStack {
-                        Group {
-                            durationButton(states: durationState.allCases, selectedState: $selectedState)
-
-                            Text("Updated").font(.caption2).foregroundColor(.secondary)
-                            Text(dateFormatter.string(from: state.statistics?.created_at ?? Date())).font(.system(size: 12))
-                        }
-                    }
+                VStack(spacing: 8) {
+                    durationButton(states: durationState.allCases, selectedState: $selectedState)
 
                     switch selectedState {
                     case .day:
@@ -360,14 +355,15 @@ extension Home {
                         averageTIRhca1c(hba1c_all, average_, median_, tir_low, tir_high, tir_, hba1c_, sd_, cv_)
                     }
                 }
-                .frame(maxWidth: .infinity, maxHeight: 130, alignment: .center)
+                .frame(maxWidth: .infinity)
+                .padding([.bottom], 20)
             }
         }
 
         @ViewBuilder private func averageTIRhca1c(
-            _ hba1c_all: String,
+            _: String,
             _ average_: String,
-            _ median_: String,
+            _: String,
             _ tir_low: String,
             _ tir_high: String,
             _ tir_: String,
@@ -377,98 +373,103 @@ extension Home {
         ) -> some View {
             HStack {
                 Group {
-                    Text(NSLocalizedString("Average", comment: "")).font(.caption2).foregroundColor(.secondary)
-
-                    Text(average_).font(.footnote)
-
-                    Text("Median")
-                        .font(.caption2).foregroundColor(.secondary)
+                    if selectedState != .total {
+                        HStack {
+                            Text("HbA1c").font(.footnote).foregroundColor(.secondary)
+                            Text(hba1c_).font(.footnote)
+                        }
+                    } else {
+                        HStack {
+                            Text(
+                                "\(NSLocalizedString("HbA1c", comment: "")) (\(targetFormatter.string(from: (state.statistics?.GlucoseStorage_Days ?? 0) as NSNumber) ?? "") \(NSLocalizedString("days", comment: "")))"
+                            )
+                            .font(.footnote).foregroundColor(.secondary)
+                            Text(hba1c_).font(.footnote)
+                        }
+                    }
 
-                    Text(median_).font(.footnote)
+                    HStack {
+                        Text(NSLocalizedString("Average", comment: "")).font(.footnote).foregroundColor(.secondary)
+                        Text(average_).font(.footnote)
+                    }.frame(minWidth: 110)
 
                     if !state.settingsManager.preferences.displaySD {
-                        Text(
-                            NSLocalizedString("CV", comment: "CV")
-                        ).font(.caption2).foregroundColor(.secondary)
+                        HStack {
+                            Text(
+                                NSLocalizedString("CV", comment: "CV")
+                            ).font(.footnote).foregroundColor(.secondary)
 
-                        Text(cv_).font(.footnote)
+                            Text(cv_).font(.footnote)
+                        }
                     } else {
-                        Text(
-                            NSLocalizedString("SD", comment: "SD")
-                        ).font(.caption2).foregroundColor(.secondary)
-                        Text(sd_).font(.footnote)
+                        HStack {
+                            Text(
+                                NSLocalizedString("SD", comment: "SD")
+                            ).font(.footnote).foregroundColor(.secondary)
+                            Text(sd_).font(.footnote)
+                        }
                     }
                 }
             }
             HStack {
                 Group {
-                    Text(
-                        NSLocalizedString("Low (<", comment: " ") +
-                            (
-                                targetFormatter
-                                    .string(from: state.settingsManager.preferences.low as NSNumber) ?? ""
-                            ) + ")"
-                    ).font(.caption2)
+                    HStack {
+                        Text(
+                            NSLocalizedString("Low", comment: " ")
+                        )
+                        .font(.footnote)
                         .foregroundColor(.secondary)
 
-                    Text(tir_low + " %").font(.footnote).foregroundColor(.loopRed)
-
-                    Text("Normal").font(.caption2).foregroundColor(.secondary)
-
-                    Text(tir_ + " %").font(.footnote).foregroundColor(.loopGreen)
-
-                    Text(
-                        NSLocalizedString("High (>", comment: " ") +
-                            (
-                                targetFormatter
-                                    .string(from: state.settingsManager.preferences.high as NSNumber) ?? ""
-                            ) + ")"
-                    )
-                    .font(.caption2).foregroundColor(.secondary)
-
-                    Text(tir_high + " %").font(.footnote).foregroundColor(.loopYellow)
-                }
-            }
-            HStack {
-                Group {
-                    Text("HbA1c").font(.caption2).foregroundColor(.secondary)
+                        Text(tir_low + " %").font(.footnote).foregroundColor(.loopRed)
+                    }
 
-                    if selectedState != .total {
-                        Text(hba1c_).font(.footnote)
+                    HStack {
+                        Text("Normal").font(.footnote).foregroundColor(.secondary)
+                        Text(tir_ + " %").font(.footnote).foregroundColor(.loopGreen)
                     }
 
-                    Text(
-                        "\(NSLocalizedString("All", comment: "")) \(targetFormatter.string(from: (state.statistics?.GlucoseStorage_Days ?? 0) as NSNumber) ?? "") \(NSLocalizedString("days", comment: ""))"
-                    )
-                    .font(.caption2).foregroundColor(.secondary)
+                    HStack {
+                        Text(
+                            NSLocalizedString("High", comment: " ")
+                        )
+                        .font(.footnote).foregroundColor(.secondary)
 
-                    Text(hba1c_all).font(.footnote)
+                        Text(tir_high + " %").font(.footnote).foregroundColor(.loopYellow)
+                    }
                 }
             }
 
             if state.settingsManager.preferences.displayLoops {
                 HStack {
                     Group {
-                        Text("Loops").font(.caption2).foregroundColor(.secondary)
-                        Text(
-                            tirFormatter
-                                .string(from: (state.statistics?.Statistics.LoopCycles.loops ?? 0) as NSNumber) ?? ""
-                        ).font(.footnote)
-                        Text("Average Interval").font(.caption2)
-                            .foregroundColor(.secondary)
-                        Text(
-                            targetFormatter
-                                .string(from: (state.statistics?.Statistics.LoopCycles.avg_interval ?? 0) as NSNumber) ??
-                                ""
-                        ).font(.footnote)
-                        Text("Median Duration").font(.caption2)
-                            .foregroundColor(.secondary)
-                        Text(
-                            numberFormatter
-                                .string(
-                                    from: (state.statistics?.Statistics.LoopCycles.median_duration ?? 0) as NSNumber
-                                ) ?? ""
-                        ).font(.footnote)
+                        HStack {
+                            Text("Loops").font(.footnote).foregroundColor(.secondary)
+                            Text(
+                                tirFormatter
+                                    .string(from: (state.statistics?.Statistics.LoopCycles.loops ?? 0) as NSNumber) ?? ""
+                            ).font(.footnote)
+                        }
+
+                        HStack {
+                            Text("Interval").font(.footnote)
+                                .foregroundColor(.secondary)
+                            Text(
+                                targetFormatter
+                                    .string(from: (state.statistics?.Statistics.LoopCycles.avg_interval ?? 0) as NSNumber) ??
+                                    ""
+                            ).font(.footnote)
+                        }
+
+                        HStack {
+                            Text("Duration").font(.footnote)
+                                .foregroundColor(.secondary)
+                            Text(
+                                numberFormatter
+                                    .string(
+                                        from: (state.statistics?.Statistics.LoopCycles.median_duration ?? 0) as NSNumber
+                                    ) ?? ""
+                            ).font(.footnote)
+                        }
                     }
                 }
             }
@@ -517,6 +518,7 @@ extension Home {
                     }
                 }
                 .frame(maxWidth: .infinity)
+                .padding([.bottom], 20)
             }
         }