Parcourir la source

Streamline navigation views (#269)

* Streamline home view navigation views:
* Add title to carb entry view, as it was missing
* Streamlines all buttons (centered alignment, same size) for all coming-from-home-view dialogs/views

* Some changes after PR discussion
* Change navigation title style from `.automatic` to `.inline` for all views accessible from home screen
* Save screen space by moving (i) icon in bolus entry next to `Insulin recommended`
* Change color styling for (i) icon in bolus entry

* Revert info icon in bolus entry view back to speech bubble style"
Deniz Cengiz il y a 2 ans
Parent
commit
967fce01c1

+ 8 - 6
FreeAPS/Sources/Modules/AddCarbs/View/AddCarbsRootView.swift

@@ -7,7 +7,7 @@ extension AddCarbs {
         let resolver: Resolver
         @StateObject var state = StateModel()
         @State var dish: String = ""
-        @State var isPromtPresented = false
+        @State var isPromptPresented = false
         @State var saved = false
         @State private var showAlert = false
         @FocusState private var isFocused: Bool
@@ -75,7 +75,7 @@ extension AddCarbs {
                             .controlSize(.mini)
                             .buttonStyle(BorderlessButtonStyle())
                         Button {
-                            isPromtPresented = true
+                            isPromptPresented = true
                         }
                         label: { Text("Save as Preset") }
                             .frame(maxWidth: .infinity, alignment: .trailing)
@@ -101,7 +101,7 @@ extension AddCarbs {
                                     )
                             )
                     }
-                    .popover(isPresented: $isPromtPresented) {
+                    .popover(isPresented: $isPromptPresented) {
                         presetPopover
                     }
                 }
@@ -118,7 +118,7 @@ extension AddCarbs {
 
                 Section {
                     Button { state.add() }
-                    label: { Text("Save and continue").font(.title3) }
+                    label: { Text("Save and continue") }
                         .disabled(state.carbs <= 0 && state.fat <= 0 && state.protein <= 0)
                         .frame(maxWidth: .infinity, alignment: .center)
                 } footer: { Text(state.waitersNotepad().description) }
@@ -130,6 +130,8 @@ extension AddCarbs {
                 }
             }
             .onAppear(perform: configureView)
+            .navigationTitle("Add Meals")
+            .navigationBarTitleDisplayMode(.inline)
             .navigationBarItems(leading: Button("Close", action: state.hideModal))
         }
 
@@ -148,14 +150,14 @@ extension AddCarbs {
                             try? moc.save()
                             state.addNewPresetToWaitersNotepad(dish)
                             saved = false
-                            isPromtPresented = false
+                            isPromptPresented = false
                         }
                     }
                     label: { Text("Save") }
                     Button {
                         dish = ""
                         saved = false
-                        isPromtPresented = false }
+                        isPromptPresented = false }
                     label: { Text("Cancel") }
                 } header: { Text("Enter Meal Preset Name") }
             }

+ 7 - 7
FreeAPS/Sources/Modules/AddTempTarget/View/AddTempTargetRootView.swift

@@ -6,7 +6,7 @@ extension AddTempTarget {
     struct RootView: BaseView {
         let resolver: Resolver
         @StateObject var state = StateModel()
-        @State private var isPromtPresented = false
+        @State private var isPromptPresented = false
         @State private var isRemoveAlertPresented = false
         @State private var removeAlert: Alert?
         @State private var isEditing = false
@@ -99,7 +99,7 @@ extension AddTempTarget {
                             Text("minutes").foregroundColor(.secondary)
                         }
                         DatePicker("Date", selection: $state.date)
-                        Button { isPromtPresented = true }
+                        Button { isPromptPresented = true }
                         label: { Text("Save as preset") }
                     }
                 }
@@ -112,7 +112,7 @@ extension AddTempTarget {
                             Text("minutes").foregroundColor(.secondary)
                         }
                         DatePicker("Date", selection: $state.date)
-                        Button { isPromtPresented = true }
+                        Button { isPromptPresented = true }
                         label: { Text("Save as preset") }
                             .disabled(state.duration == 0)
                     }
@@ -125,16 +125,16 @@ extension AddTempTarget {
                     label: { Text("Cancel Temp Target") }
                 }
             }
-            .popover(isPresented: $isPromtPresented) {
+            .popover(isPresented: $isPromptPresented) {
                 Form {
                     Section(header: Text("Enter preset name")) {
                         TextField("Name", text: $state.newPresetName)
                         Button {
                             state.save()
-                            isPromtPresented = false
+                            isPromptPresented = false
                         }
                         label: { Text("Save") }
-                        Button { isPromtPresented = false }
+                        Button { isPromptPresented = false }
                         label: { Text("Cancel") }
                     }
                 }
@@ -144,7 +144,7 @@ extension AddTempTarget {
                 state.hbt = isEnabledArray.first?.hbt ?? 160
             }
             .navigationTitle("Enact Temp Target")
-            .navigationBarTitleDisplayMode(.automatic)
+            .navigationBarTitleDisplayMode(.inline)
             .navigationBarItems(leading: Button("Close", action: state.hideModal))
         }
 

+ 14 - 12
FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift

@@ -38,24 +38,25 @@ extension Bolus {
                     } else {
                         HStack {
                             Text("Insulin recommended")
+                            Image(systemName: "info.bubble")
+                                .symbolRenderingMode(.palette)
+                                .foregroundStyle(.primary, .blue)
+                                .onTapGesture {
+                                    presentInfo.toggle()
+                                }
+
                             Spacer()
+
                             Text(
                                 formatter
                                     .string(from: state.insulinRecommended as NSNumber)! +
                                     NSLocalizedString(" U", comment: "Insulin unit")
                             ).foregroundColor((state.error && state.insulinRecommended > 0) ? .red : .secondary)
+                                .onTapGesture {
+                                    if state.error, state.insulinRecommended > 0 { displayError = true }
+                                    else { state.amount = state.insulinRecommended }
+                                }
                         }.contentShape(Rectangle())
-                            .onTapGesture {
-                                if state.error, state.insulinRecommended > 0 { displayError = true }
-                                else { state.amount = state.insulinRecommended }
-                            }
-                        HStack {
-                            Image(systemName: "info.bubble").symbolRenderingMode(.palette).foregroundStyle(
-                                .primary, .blue
-                            )
-                        }.onTapGesture {
-                            presentInfo.toggle()
-                        }
                     }
                 }
                 header: { Text("Recommendation") }
@@ -79,6 +80,7 @@ extension Bolus {
                     Section {
                         Button { state.add() }
                         label: { Text(!(state.amount > state.maxBolus) ? "Enact bolus" : "Max Bolus exceeded!") }
+                            .frame(maxWidth: .infinity, alignment: .center)
                             .disabled(
                                 state.amount <= 0 || state.amount > state.maxBolus
                             )
@@ -153,7 +155,7 @@ extension Bolus {
                 }
             }
             .navigationTitle("Enact Bolus")
-            .navigationBarTitleDisplayMode(.automatic)
+            .navigationBarTitleDisplayMode(.inline)
             .navigationBarItems(leading: Button("Close", action: state.hideModal))
             .popup(isPresented: presentInfo, alignment: .center, direction: .bottom) {
                 bolusInfo

+ 1 - 1
FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift

@@ -54,7 +54,7 @@ extension DataTable {
             .onAppear(perform: configureView)
             .navigationTitle(isLayered ? "" : "History")
             .blur(radius: isLayered ? 4.0 : 0)
-            .navigationBarTitleDisplayMode(.automatic)
+            .navigationBarTitleDisplayMode(.inline)
             .navigationBarItems(leading: Button(isLayered ? "" : "Close", action: state.hideModal))
             .popup(isPresented: newGlucose, alignment: .center, direction: .top) {
                 addGlucose

+ 3 - 3
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -95,7 +95,7 @@ extension Home {
             .frame(maxWidth: .infinity)
             .padding(.top, 10 + geo.safeAreaInsets.top)
             .padding(.bottom, 10)
-            .background(Color.gray.opacity(0.2))
+            .background(Color.gray.opacity(0.3))
         }
 
         var cobIobView: some View {
@@ -415,7 +415,7 @@ extension Home {
             let colour: Color = colorScheme == .dark ? .black : .white
             // Rectangle().fill(colour).frame(maxHeight: 1)
             ZStack {
-                Rectangle().fill(Color.gray.opacity(0.2)).frame(maxHeight: 40)
+                Rectangle().fill(Color.gray.opacity(0.3)).frame(maxHeight: 40)
                 let cancel = fetchedPercent.first?.enabled ?? false
                 HStack(spacing: cancel ? 25 : 15) {
                     Text(selectedProfile().name).foregroundColor(.secondary)
@@ -478,7 +478,7 @@ extension Home {
 
         @ViewBuilder private func bottomPanel(_ geo: GeometryProxy) -> some View {
             ZStack {
-                Rectangle().fill(Color.gray.opacity(0.2)).frame(height: 50 + geo.safeAreaInsets.bottom)
+                Rectangle().fill(Color.gray.opacity(0.3)).frame(height: 50 + geo.safeAreaInsets.bottom)
 
                 HStack {
                     Button { state.showModal(for: .addCarbs) }

+ 1 - 1
FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift

@@ -126,7 +126,7 @@ extension Settings {
             .onAppear(perform: configureView)
             .navigationTitle("Settings")
             .navigationBarItems(leading: Button("Close", action: state.hideSettingsModal))
-            .navigationBarTitleDisplayMode(.automatic)
+            .navigationBarTitleDisplayMode(.inline)
             .onDisappear(perform: { state.uploadProfileAndSettings(false) })
         }
     }

+ 1 - 1
FreeAPS/Sources/Modules/Stat/View/StatRootView.swift

@@ -148,7 +148,7 @@ extension Stat {
             }
             .onAppear(perform: configureView)
             .navigationBarTitle("Statistics")
-            .navigationBarTitleDisplayMode(.automatic)
+            .navigationBarTitleDisplayMode(.inline)
             .navigationBarItems(leading: Button("Close", action: state.hideModal))
         }
     }