diff --git a/iphone/Maps/Core/Theme/Core/ThemeManager.swift b/iphone/Maps/Core/Theme/Core/ThemeManager.swift index cf10fca0c..f00d5bba7 100644 --- a/iphone/Maps/Core/Theme/Core/ThemeManager.swift +++ b/iphone/Maps/Core/Theme/Core/ThemeManager.swift @@ -53,8 +53,21 @@ final class ThemeManager: NSObject { } }(actualTheme) - - FrameworkHelper.setTheme(actualTheme) + if Settings.mapAppearance == .light { + if actualTheme == .vehicleDay || actualTheme == .vehicleNight { + FrameworkHelper.setTheme(.vehicleDay) + } else { + FrameworkHelper.setTheme(.day) + } + } else if Settings.mapAppearance == .dark { + if actualTheme == .vehicleDay || actualTheme == .vehicleNight { + FrameworkHelper.setTheme(.vehicleNight) + } else { + FrameworkHelper.setTheme(.night) + } + } else { + FrameworkHelper.setTheme(actualTheme) + } if nightMode != newNightMode || StyleManager.shared.hasTheme() == false{ UIColor.setNightMode(newNightMode) if newNightMode { diff --git a/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings b/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings index 58a5223ac..91bb86e4e 100644 --- a/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings +++ b/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings @@ -209,6 +209,9 @@ "pref_zoom_title" = "Zoom buttons"; "pref_left_button_type" = "Left Main Button"; +/* Settings «Map» category: «Map Appearance» title */ +"pref_mapappearance_title" = "Map Appearance"; + /* Settings «Map» category: «Appearance» title */ "pref_appearance_title" = "Appearance"; diff --git a/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings b/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings index 86a8195bb..36cf58aa1 100644 --- a/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings +++ b/iphone/Maps/LocalizedStrings/en.lproj/Localizable.strings @@ -219,6 +219,9 @@ "pref_zoom_title" = "Zoom buttons"; "pref_left_button_type" = "Left Main Button"; +/* Settings «Map» category: «Map Appearance» title */ +"pref_mapappearance_title" = "Map Appearance"; + /* Settings «Map» category: «Appearance» title */ "pref_appearance_title" = "Appearance"; diff --git a/iphone/Maps/Model/Settings.swift b/iphone/Maps/Model/Settings.swift index 6b8e5529b..caa36e0b7 100644 --- a/iphone/Maps/Model/Settings.swift +++ b/iphone/Maps/Model/Settings.swift @@ -12,6 +12,10 @@ import Combine static private let userDefaultsKeyLeftButtonType = "LeftButtonType" + /// Key for storing the map appearance in the user defaults + static private let userDefaultsKeyMapAppearance = "MapAppearance" + + /// The current distance unit static var distanceUnit: DistanceUnit { get { @@ -147,6 +151,23 @@ import Combine } + /// The current map appearance + @objc static var mapAppearance: Appearance { + get { + let mapAppearanceRawValue = UserDefaults.standard.integer(forKey: userDefaultsKeyMapAppearance) + if mapAppearanceRawValue != 0, let mapAppearance = Appearance(rawValue: mapAppearanceRawValue) { + return mapAppearance + } + + return .auto + } + set { + UserDefaults.standard.set(newValue.rawValue, forKey: userDefaultsKeyMapAppearance) + ThemeManager.invalidate() + } + } + + /// The current appearance @objc static var appearance: Appearance { get { diff --git a/iphone/Maps/UI/Settings/SettingsView.swift b/iphone/Maps/UI/Settings/SettingsView.swift index ea8221500..39cc74e9a 100644 --- a/iphone/Maps/UI/Settings/SettingsView.swift +++ b/iphone/Maps/UI/Settings/SettingsView.swift @@ -36,6 +36,10 @@ struct SettingsView: View { @State private var shouldTransliterateToLatin: Bool = true + /// The selected map appearance + @State private var selectedMapAppearance: Settings.Appearance = .auto + + /// The selected appearance @State private var selectedAppearance: Settings.Appearance = .auto @@ -135,12 +139,12 @@ struct SettingsView: View { Toggle("transliteration_title", isOn: $shouldTransliterateToLatin) .tint(.accent) - Picker(selection: $selectedAppearance) { - ForEach(Settings.Appearance.allCases) { appearance in - Text(appearance.description) + Picker(selection: $selectedMapAppearance) { + ForEach(Settings.Appearance.allCases) { mapAppearance in + Text(mapAppearance.description) } } label: { - Text("pref_appearance_title") + Text("pref_mapappearance_title") } } @@ -198,6 +202,14 @@ struct SettingsView: View { } Section { + Picker(selection: $selectedAppearance) { + ForEach(Settings.Appearance.allCases) { appearance in + Text(appearance.description) + } + } label: { + Text("pref_appearance_title") + } + Toggle("pref_calibration_title", isOn: $shouldCalibrateCompass) .tint(.accent) @@ -256,6 +268,7 @@ struct SettingsView: View { hasAutomaticDownload = Settings.hasAutomaticDownload hasIncreasedFontsize = Settings.hasIncreasedFontsize shouldTransliterateToLatin = Settings.shouldTransliterateToLatin + selectedMapAppearance = Settings.mapAppearance selectedAppearance = Settings.appearance shouldSync = Settings.shouldSync shouldCalibrateCompass = Settings.shouldCalibrateCompass @@ -284,6 +297,9 @@ struct SettingsView: View { .onChange(of: shouldTransliterateToLatin) { changedShouldTransliterateToLatin in Settings.shouldTransliterateToLatin = changedShouldTransliterateToLatin } + .onChange(of: selectedMapAppearance) { changedSelectedMapAppearance in + Settings.mapAppearance = changedSelectedMapAppearance + } .onChange(of: selectedAppearance) { changedSelectedAppearance in Settings.appearance = changedSelectedAppearance }