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

Profile override adaptive UI.
Visualise the max limit.
And improve override summation in confirmation alert.

(cherry picked from commit 4a60d3ed88a9482be40ae74749d6f814c1186d22)

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

+ 9 - 3
FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift

@@ -52,9 +52,13 @@ extension OverrideProfilesConfig {
                                 onEditingChanged: { editing in
                                     isEditing = editing
                                 }
-                            )
+                            ).accentColor(state.percentage >= 130 ? .red : .blue)
                             Text("\(state.percentage.formatted(.number)) %")
-                                .foregroundColor(isEditing ? .orange : .blue)
+                                .foregroundColor(
+                                    state
+                                        .percentage >= 130 ? .red :
+                                        (isEditing ? .orange : (state.percentage >= 150 ? .red : .blue))
+                                )
                                 .font(.largeTitle)
                             Spacer()
                             Toggle(isOn: $state._indefinite) {
@@ -81,7 +85,9 @@ extension OverrideProfilesConfig {
                         .frame(maxWidth: .infinity, alignment: .center)
                         .controlSize(.mini)
                         .alert(
-                            "Saving this override will change your basal insulin, ISF and CR during the entire selected duration. Tapping save will start your new overide or edit your current active override.",
+                            "Selected Override:\n\n\(state.percentage.formatted(.number)) %, " +
+                                (state.duration > 0 ? "\(state.duration) min" : " infinite duration.") + "\n\n" +
+                                "Saving this override will change your basal insulin, ISF and CR during the entire selected duration. Tapping save will start your new overide or edit your current active override.",
                             isPresented: $showAlert,
                             actions: {
                                 Button("Cancel", role: .cancel) {}