Przeglądaj źródła

Background Color
* change background color in the most important views to new gradient for dark mode WiP ... to do: change all the other views and change stack color to new darker color

polscm32 2 lat temu
rodzic
commit
65931e39d2

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

@@ -21,6 +21,7 @@ extension AddCarbs {
         ) var carbPresets: FetchedResults<Presets>
 
         @Environment(\.managedObjectContext) var moc
+        @Environment(\.colorScheme) var colorScheme
 
         private var formatter: NumberFormatter {
             let formatter = NumberFormatter()
@@ -123,15 +124,15 @@ extension AddCarbs {
                 Section {
                     mealPresets
                 }
-            }
-            .onAppear {
-                configureView {
-                    state.loadEntries(editMode)
+            }.scrollContentBackground(.hidden).background(color)
+                .onAppear {
+                    configureView {
+                        state.loadEntries(editMode)
+                    }
                 }
-            }
-            .navigationTitle("Add Meal")
-            .navigationBarTitleDisplayMode(.inline)
-            .navigationBarItems(trailing: Button("Close", action: state.hideModal))
+                .navigationTitle("Add Meal")
+                .navigationBarTitleDisplayMode(.inline)
+                .navigationBarItems(trailing: Button("Close", action: state.hideModal))
         }
 
         private var presetPopover: some View {
@@ -162,6 +163,19 @@ extension AddCarbs {
             }
         }
 
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color(red: 0.011, green: 0.058, blue: 0.109),
+                    Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
+                ]),
+                startPoint: .bottom,
+                endPoint: .top
+            )
+                :
+                LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
+        }
+
         private var empty: Bool {
             state.carbs <= 0 && state.fat <= 0 && state.protein <= 0
         }

+ 34 - 19
FreeAPS/Sources/Modules/AddTempTarget/View/AddTempTargetRootView.swift

@@ -16,6 +16,8 @@ extension AddTempTarget {
             sortDescriptors: [NSSortDescriptor(key: "date", ascending: false)]
         ) var isEnabledArray: FetchedResults<TempTargetsSlider>
 
+        @Environment(\.colorScheme) var colorScheme
+
         private var formatter: NumberFormatter {
             let formatter = NumberFormatter()
             formatter.numberStyle = .decimal
@@ -120,28 +122,28 @@ extension AddTempTarget {
                     Button { state.cancel() }
                     label: { Text("Cancel Temp Target") }
                 }
-            }
-            .popover(isPresented: $isPromptPresented) {
-                Form {
-                    Section(header: Text("Enter preset name")) {
-                        TextField("Name", text: $state.newPresetName)
-                        Button {
-                            state.save()
-                            isPromptPresented = false
+            }.scrollContentBackground(.hidden).background(color)
+                .popover(isPresented: $isPromptPresented) {
+                    Form {
+                        Section(header: Text("Enter preset name")) {
+                            TextField("Name", text: $state.newPresetName)
+                            Button {
+                                state.save()
+                                isPromptPresented = false
+                            }
+                            label: { Text("Save") }
+                            Button { isPromptPresented = false }
+                            label: { Text("Cancel") }
                         }
-                        label: { Text("Save") }
-                        Button { isPromptPresented = false }
-                        label: { Text("Cancel") }
                     }
                 }
-            }
-            .onAppear {
-                configureView()
-                state.hbt = isEnabledArray.first?.hbt ?? 160
-            }
-            .navigationTitle("Enact Temp Target")
-            .navigationBarTitleDisplayMode(.inline)
-            .navigationBarItems(trailing: Button("Close", action: state.hideModal))
+                .onAppear {
+                    configureView()
+                    state.hbt = isEnabledArray.first?.hbt ?? 160
+                }
+                .navigationTitle("Enact Temp Target")
+                .navigationBarTitleDisplayMode(.inline)
+                .navigationBarItems(trailing: Button("Close", action: state.hideModal))
         }
 
         private func presetView(for preset: TempTarget) -> some View {
@@ -202,5 +204,18 @@ extension AddTempTarget {
                     }
             }
         }
+
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color(red: 0.011, green: 0.058, blue: 0.109),
+                    Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
+                ]),
+                startPoint: .bottom,
+                endPoint: .top
+            )
+                :
+                LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
+        }
     }
 }

+ 43 - 30
FreeAPS/Sources/Modules/Bolus/View/AlternativeBolusCalcRootView.swift

@@ -179,40 +179,53 @@ extension Bolus {
                         label: { Text("Continue without bolus") }.frame(maxWidth: .infinity, alignment: .center)
                     }
                 }
-            }
-            .blur(radius: showInfo ? 3 : 0)
-            .navigationTitle("Enact Bolus")
-            .navigationBarTitleDisplayMode(.inline)
-            .navigationBarItems(
-                leading: Button {
-                    carbsView()
+            }.scrollContentBackground(.hidden).background(color)
+                .blur(radius: showInfo ? 3 : 0)
+                .navigationTitle("Enact Bolus")
+                .navigationBarTitleDisplayMode(.inline)
+                .navigationBarItems(
+                    leading: Button {
+                        carbsView()
+                    }
+                    label: {
+                        HStack {
+                            Image(systemName: "chevron.backward")
+                            Text("Meal")
+                        }
+                    },
+                    trailing: Button { state.hideModal() }
+                    label: { Text("Close") }
+                )
+                .onAppear {
+                    configureView {
+                        state.waitForSuggestionInitial = waitForSuggestion
+                        state.waitForSuggestion = waitForSuggestion
+                        state.insulinCalculated = state.calculateInsulin()
+                    }
                 }
-                label: {
-                    HStack {
-                        Image(systemName: "chevron.backward")
-                        Text("Meal")
+                .onDisappear {
+                    if fetch, hasFatOrProtein, !keepForNextWiew, state.useCalc {
+                        state.delete(deleteTwice: true, meal: meal)
+                    } else if fetch, !keepForNextWiew, state.useCalc {
+                        state.delete(deleteTwice: false, meal: meal)
                     }
-                },
-                trailing: Button { state.hideModal() }
-                label: { Text("Close") }
-            )
-            .onAppear {
-                configureView {
-                    state.waitForSuggestionInitial = waitForSuggestion
-                    state.waitForSuggestion = waitForSuggestion
-                    state.insulinCalculated = state.calculateInsulin()
                 }
-            }
-            .onDisappear {
-                if fetch, hasFatOrProtein, !keepForNextWiew, state.useCalc {
-                    state.delete(deleteTwice: true, meal: meal)
-                } else if fetch, !keepForNextWiew, state.useCalc {
-                    state.delete(deleteTwice: false, meal: meal)
+                .popup(isPresented: showInfo) {
+                    bolusInfoAlternativeCalculator
                 }
-            }
-            .popup(isPresented: showInfo) {
-                bolusInfoAlternativeCalculator
-            }
+        }
+
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color(red: 0.011, green: 0.058, blue: 0.109),
+                    Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
+                ]),
+                startPoint: .bottom,
+                endPoint: .top
+            )
+                :
+                LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
         }
 
         var predictionChart: some View {

+ 26 - 12
FreeAPS/Sources/Modules/DataTable/View/DataTableRootView.swift

@@ -72,19 +72,20 @@ extension DataTable {
                     case .treatments: treatmentsList
                     case .glucose: glucoseList
                     }
+                }.scrollContentBackground(.hidden)
+                    .background(color)
+            }.background(color)
+                .onAppear(perform: configureView)
+                .navigationTitle("History")
+                .navigationBarTitleDisplayMode(.inline)
+                .navigationBarItems(trailing: Button("Close", action: state.hideModal))
+                .sheet(isPresented: $showManualGlucose) {
+                    addGlucoseView
+                }
+                .sheet(isPresented: $showExternalInsulin, onDismiss: { if isAmountUnconfirmed { state.externalInsulinAmount = 0
+                    state.externalInsulinDate = Date() } }) {
+                    addExternalInsulinView
                 }
-            }
-            .onAppear(perform: configureView)
-            .navigationTitle("History")
-            .navigationBarTitleDisplayMode(.inline)
-            .navigationBarItems(trailing: Button("Close", action: state.hideModal))
-            .sheet(isPresented: $showManualGlucose) {
-                addGlucoseView
-            }
-            .sheet(isPresented: $showExternalInsulin, onDismiss: { if isAmountUnconfirmed { state.externalInsulinAmount = 0
-                state.externalInsulinDate = Date() } }) {
-                addExternalInsulinView
-            }
         }
 
         private var treatmentsList: some View {
@@ -197,6 +198,19 @@ extension DataTable {
             }
         }
 
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color(red: 0.011, green: 0.058, blue: 0.109),
+                    Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
+                ]),
+                startPoint: .bottom,
+                endPoint: .top
+            )
+                :
+                LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
+        }
+
         @ViewBuilder private func treatmentView(_ item: Treatment) -> some View {
             HStack {
                 if item.type == .bolus || item.type == .carbs {

+ 20 - 6
FreeAPS/Sources/Modules/OverrideProfilesConfig/View/OverrideProfilesRootView.swift

@@ -15,6 +15,7 @@ extension OverrideProfilesConfig {
 
         @Environment(\.dismiss) var dismiss
         @Environment(\.managedObjectContext) var moc
+        @Environment(\.colorScheme) var colorScheme
 
         @FetchRequest(
             entity: OverridePresets.entity(),
@@ -283,12 +284,12 @@ extension OverrideProfilesConfig {
                 .buttonStyle(BorderlessButtonStyle())
                 .disabled(!state.isEnabled)
                 .tint(.red)
-            }
-            .onAppear(perform: configureView)
-            .onAppear { state.savedSettings() }
-            .navigationBarTitle("Profiles")
-            .navigationBarTitleDisplayMode(.automatic)
-            .navigationBarItems(trailing: Button("Close", action: state.hideModal))
+            }.scrollContentBackground(.hidden).background(color)
+                .onAppear(perform: configureView)
+                .onAppear { state.savedSettings() }
+                .navigationBarTitle("Profiles")
+                .navigationBarTitleDisplayMode(.automatic)
+                .navigationBarItems(trailing: Button("Close", action: state.hideModal))
         }
 
         @ViewBuilder private func profilesView(for preset: OverridePresets) -> some View {
@@ -367,5 +368,18 @@ extension OverrideProfilesConfig {
                 // To do: add error
             }
         }
+
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color(red: 0.011, green: 0.058, blue: 0.109),
+                    Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
+                ]),
+                startPoint: .bottom,
+                endPoint: .top
+            )
+                :
+                LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
+        }
     }
 }

+ 24 - 9
FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift

@@ -8,6 +8,8 @@ extension Settings {
         @StateObject var state = StateModel()
         @State private var showShareSheet = false
 
+        @Environment(\.colorScheme) var colorScheme
+
         var body: some View {
             Form {
                 Section {
@@ -127,15 +129,28 @@ extension Settings {
                             showShareSheet = true
                         }
                 }
-            }
-            .sheet(isPresented: $showShareSheet) {
-                ShareSheet(activityItems: state.logItems())
-            }
-            .onAppear(perform: configureView)
-            .navigationTitle("Settings")
-            .navigationBarItems(trailing: Button("Close", action: state.hideSettingsModal))
-            .navigationBarTitleDisplayMode(.inline)
-            .onDisappear(perform: { state.uploadProfileAndSettings(false) })
+            }.scrollContentBackground(.hidden).background(color)
+                .sheet(isPresented: $showShareSheet) {
+                    ShareSheet(activityItems: state.logItems())
+                }
+                .onAppear(perform: configureView)
+                .navigationTitle("Settings")
+                .navigationBarItems(trailing: Button("Close", action: state.hideSettingsModal))
+                .navigationBarTitleDisplayMode(.inline)
+                .onDisappear(perform: { state.uploadProfileAndSettings(false) })
+        }
+
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color(red: 0.011, green: 0.058, blue: 0.109),
+                    Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
+                ]),
+                startPoint: .bottom,
+                endPoint: .top
+            )
+                :
+                LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
         }
     }
 }

+ 20 - 5
FreeAPS/Sources/Modules/Stat/View/StatRootView.swift

@@ -19,6 +19,8 @@ extension Stat {
             sortDescriptors: [NSSortDescriptor(key: "date", ascending: false)]
         ) var fetchedInsulin: FetchedResults<InsulinDistribution>
 
+        @Environment(\.colorScheme) var colorScheme
+
         enum Duration: String, CaseIterable, Identifiable {
             case Today
             case Day
@@ -145,11 +147,24 @@ extension Stat {
                 }
                 .pickerStyle(.segmented).background(.cyan.opacity(0.2))
                 stats()
-            }
-            .onAppear(perform: configureView)
-            .navigationBarTitle("Statistics")
-            .navigationBarTitleDisplayMode(.inline)
-            .navigationBarItems(trailing: Button("Close", action: state.hideModal))
+            }.background(color)
+                .onAppear(perform: configureView)
+                .navigationBarTitle("Statistics")
+                .navigationBarTitleDisplayMode(.inline)
+                .navigationBarItems(trailing: Button("Close", action: state.hideModal))
+        }
+
+        private var color: LinearGradient {
+            colorScheme == .dark ? LinearGradient(
+                gradient: Gradient(colors: [
+                    Color(red: 0.011, green: 0.058, blue: 0.109),
+                    Color(red: 0.03921568627, green: 0.1333333333, blue: 0.2156862745)
+                ]),
+                startPoint: .bottom,
+                endPoint: .top
+            )
+                :
+                LinearGradient(gradient: Gradient(colors: [Color.gray.opacity(0.1)]), startPoint: .top, endPoint: .bottom)
         }
     }
 }