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

Consistently display Carbs, then Protein, then Fat

Deniz Cengiz 1 год назад
Родитель
Сommit
ad0935be54

+ 15 - 15
FreeAPS/Sources/Modules/MealSettings/View/MealSettingsRootView.swift

@@ -81,26 +81,26 @@ extension MealSettings {
                             if state.useFPUconversion {
                                 VStack {
                                     HStack {
-                                        Text("Max Fat")
+                                        Text("Max Protein")
 
                                         Spacer()
 
                                         Group {
-                                            Text(state.maxFat.description)
-                                                .foregroundColor(!displayPickerMaxFat ? .primary : .accentColor)
+                                            Text(state.maxProtein.description)
+                                                .foregroundColor(!displayPickerMaxProtein ? .primary : .accentColor)
 
                                             Text(" g").foregroundColor(.secondary)
                                         }
                                     }
                                     .onTapGesture {
-                                        displayPickerMaxFat.toggle()
+                                        displayPickerMaxProtein.toggle()
                                     }
                                 }
                                 .padding(.top)
 
-                                if displayPickerMaxFat {
-                                    let setting = PickerSettingsProvider.shared.settings.maxFat
-                                    Picker(selection: $state.maxFat, label: Text("")) {
+                                if displayPickerMaxProtein {
+                                    let setting = PickerSettingsProvider.shared.settings.maxProtein
+                                    Picker(selection: $state.maxProtein, label: Text("")) {
                                         ForEach(
                                             PickerSettingsProvider.shared.generatePickerValues(from: setting, units: state.units),
                                             id: \.self
@@ -111,29 +111,29 @@ extension MealSettings {
                                     .pickerStyle(WheelPickerStyle())
                                     .frame(maxWidth: .infinity)
                                 }
-
+                                
                                 VStack {
                                     HStack {
-                                        Text("Max Protein")
+                                        Text("Max Fat")
 
                                         Spacer()
 
                                         Group {
-                                            Text(state.maxProtein.description)
-                                                .foregroundColor(!displayPickerMaxProtein ? .primary : .accentColor)
+                                            Text(state.maxFat.description)
+                                                .foregroundColor(!displayPickerMaxFat ? .primary : .accentColor)
 
                                             Text(" g").foregroundColor(.secondary)
                                         }
                                     }
                                     .onTapGesture {
-                                        displayPickerMaxProtein.toggle()
+                                        displayPickerMaxFat.toggle()
                                     }
                                 }
                                 .padding(.top)
 
-                                if displayPickerMaxProtein {
-                                    let setting = PickerSettingsProvider.shared.settings.maxProtein
-                                    Picker(selection: $state.maxProtein, label: Text("")) {
+                                if displayPickerMaxFat {
+                                    let setting = PickerSettingsProvider.shared.settings.maxFat
+                                    Picker(selection: $state.maxFat, label: Text("")) {
                                         ForEach(
                                             PickerSettingsProvider.shared.generatePickerValues(from: setting, units: state.units),
                                             id: \.self

+ 9 - 4
FreeAPS/Sources/Modules/Treatments/View/MealPreset/AddMealPresetView.swift

@@ -74,16 +74,21 @@ struct AddMealPresetView: View {
 
     @ViewBuilder private func proteinAndFat() -> some View {
         HStack {
-            Text("Fat").foregroundColor(.orange)
+            Text("Protein").foregroundColor(.red)
             Spacer()
-            TextFieldWithToolBar(text: $presetFat, placeholder: "0", keyboardType: .numberPad, numberFormatter: mealFormatter)
+            TextFieldWithToolBar(
+                text: $presetProtein,
+                placeholder: "0",
+                keyboardType: .numberPad,
+                numberFormatter: mealFormatter
+            )
             Text("g").foregroundColor(.secondary)
         }
         HStack {
-            Text("Protein").foregroundColor(.red)
+            Text("Fat").foregroundColor(.orange)
             Spacer()
             TextFieldWithToolBar(
-                text: $presetProtein,
+                text: $presetFat,
                 placeholder: "0",
                 keyboardType: .numberPad,
                 numberFormatter: mealFormatter

+ 5 - 5
FreeAPS/Sources/Modules/Treatments/View/MealPreset/MealPresetView.swift

@@ -216,24 +216,24 @@ struct MealPresetView: View {
 
                     if state.useFPUconversion {
                         Group {
-                            Text("Fat: ")
+                            Text("Protein: ")
                                 .font(.footnote)
                                 .foregroundStyle(.secondary)
                             HStack(spacing: 2) {
-                                Text("\(fat as NSNumber, formatter: mealFormatter)")
+                                Text("\(protein as NSNumber, formatter: mealFormatter)")
                                     .font(.footnote)
                                 Text(" g")
                                     .font(.footnote)
                                     .foregroundStyle(.secondary)
                             }
                         }
-
+                        
                         Group {
-                            Text("Protein: ")
+                            Text("Fat: ")
                                 .font(.footnote)
                                 .foregroundStyle(.secondary)
                             HStack(spacing: 2) {
-                                Text("\(protein as NSNumber, formatter: mealFormatter)")
+                                Text("\(fat as NSNumber, formatter: mealFormatter)")
                                     .font(.footnote)
                                 Text(" g")
                                     .font(.footnote)