diff --git a/BrowserKit/Sources/Common/Theming/DarkTheme.swift b/BrowserKit/Sources/Common/Theming/DarkTheme.swift index ab150917aa2c..698fc861f99e 100644 --- a/BrowserKit/Sources/Common/Theming/DarkTheme.swift +++ b/BrowserKit/Sources/Common/Theming/DarkTheme.swift @@ -6,7 +6,10 @@ import UIKit public struct DarkTheme: Theme { public var type: ThemeType = .dark + /* Ecosia: Use Ecosia color palette subclass public var colors: ThemeColourPalette = DarkColourPalette() + */ + public var colors: EcosiaThemeColourPalette = DarkColourPalette() public init() {} } @@ -17,12 +20,22 @@ public struct DarkTheme: Theme { /// and a regular dark theme. public struct NightModeTheme: Theme { public var type: ThemeType = .nightMode + /* Ecosia: Use Ecosia color palette subclass public var colors: ThemeColourPalette = DarkColourPalette() + */ + public var colors: EcosiaThemeColourPalette = DarkColourPalette() public init() {} } +/* Ecosia: Use Ecosia color palette subclass private struct DarkColourPalette: ThemeColourPalette { + */ +private struct DarkColourPalette: EcosiaThemeColourPalette { + var ecosia: EcosiaSemanticColors { + FakeEcosiaSemanticColors() + } + // MARK: - Layers var layer1: UIColor = FXColors.DarkGrey60 var layer2: UIColor = FXColors.DarkGrey30 diff --git a/BrowserKit/Sources/Common/Theming/EcosiaThemeColourPalette.swift b/BrowserKit/Sources/Common/Theming/EcosiaThemeColourPalette.swift new file mode 100644 index 000000000000..08146c5a4c82 --- /dev/null +++ b/BrowserKit/Sources/Common/Theming/EcosiaThemeColourPalette.swift @@ -0,0 +1,114 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import UIKit + +// This file is owned by Ecosia, it is only part of BrowserKit.Common since it needs to be used inside it. +// It contains all of Ecosia official semantic color tokens referenced in the link below. Do not add a color that is not mapped there! +// https://www.figma.com/design/8T2rTBVwynJKSdY6MQo5PQ/%E2%9A%9B%EF%B8%8F--Foundations?node-id=2237-3418&t=UKHtrxcc9UtOihsm-0 +// They are adopted by `EcosiaLightTheme` and `EcosiaDarkTheme` and should use `EcosiaColorPrimitive`. +public protocol EcosiaSemanticColors { + // MARK: - Background + var backgroundPrimary: UIColor { get } + var backgroundSecondary: UIColor { get } + var backgroundTertiary: UIColor { get } + var backgroundQuaternary: UIColor { get } + + // MARK: - Border + var borderDecorative: UIColor { get } + + // MARK: - Brand + var brandPrimary: UIColor { get } + + // MARK: - Button + var buttonBackgroundPrimary: UIColor { get } + var buttonBackgroundPrimaryActive: UIColor { get } + var buttonBackgroundSecondary: UIColor { get } + var buttonBackgroundSecondaryHover: UIColor { get } + var buttonContentSecondary: UIColor { get } + var buttonBackgroundTransparentActive: UIColor { get } + + // MARK: - State + var stateInformation: UIColor { get } + var stateDisabled: UIColor { get } + + // MARK: - Text + var textPrimary: UIColor { get } + var textInversePrimary: UIColor { get } + var textSecondary: UIColor { get } + var textTertiary: UIColor { get } + + // MARK: - Snowflakes ⚠️ to be assessed ⚠️ + var iconPrimary: UIColor { get } + var iconSecondary: UIColor { get } + var iconDecorative: UIColor { get } + var stateError: UIColor { get } + var backgroundHighlighted: UIColor { get } // Mapped as "loading" + + // MARK: Unmapped Snowflakes + var barBackground: UIColor { get } // Light.backgroundPrimary + Dark.backgroundSecondary + var barSeparator: UIColor { get } + var ntpCellBackground: UIColor { get } + var ntpBackground: UIColor { get } // Light.backgroundTertiary + Dark.backgroundPrimary + var ntpIntroBackground: UIColor { get } // == barBackground + var impactMultiplyCardBackground: UIColor { get } // == ntpCellBackground + var newsPlaceholder: UIColor { get } + var modalBackground: UIColor { get } // Light.backgroundTertiary + Dark.backgroundSecondary + var secondarySelectedBackground: UIColor { get } + var buttonBackgroundNTPCustomization: UIColor { get } + var privateButtonBackground: UIColor { get } + var tabSelectedPrivateBackground: UIColor { get } + var toastImageTint: UIColor { get } + var newSeedCollectedCircle: UIColor { get } + var tabTrayScreenshotBackground: UIColor { get } + var tableViewRowText: UIColor { get } +} + +public protocol EcosiaThemeColourPalette: ThemeColourPalette { + var ecosia: EcosiaSemanticColors { get } +} + +/// Serves to make Firefox themes conform the new protocol. +/// Should never end up in production UI! +class FakeEcosiaSemanticColors: EcosiaSemanticColors { + var backgroundPrimary: UIColor = .systemGray + var backgroundSecondary: UIColor = .systemGray + var backgroundTertiary: UIColor = .systemGray + var backgroundQuaternary: UIColor = .systemGray + var borderDecorative: UIColor = .systemGray + var brandPrimary: UIColor = .systemGray + var buttonBackgroundPrimary: UIColor = .systemGray + var buttonBackgroundPrimaryActive: UIColor = .systemGray + var buttonBackgroundSecondary: UIColor = .systemGray + var buttonBackgroundSecondaryHover: UIColor = .systemGray + var buttonContentSecondary: UIColor = .systemGray + var buttonBackgroundTransparentActive: UIColor = .systemGray + var iconPrimary: UIColor = .systemGray + var iconSecondary: UIColor = .systemGray + var iconDecorative: UIColor = .systemGray + var stateError: UIColor = .systemGray + var stateInformation: UIColor = .systemGray + var stateDisabled: UIColor = .systemGray + var textPrimary: UIColor = .systemGray + var textInversePrimary: UIColor = .systemGray + var textSecondary: UIColor = .systemGray + var textTertiary: UIColor = .systemGray + var backgroundHighlighted: UIColor = .systemGray + var barBackground: UIColor = .systemGray + var barSeparator: UIColor = .systemGray + var ntpCellBackground: UIColor = .systemGray + var ntpBackground: UIColor = .systemGray + var ntpIntroBackground: UIColor = .systemGray + var impactMultiplyCardBackground: UIColor = .systemGray + var newsPlaceholder: UIColor = .systemGray + var modalBackground: UIColor = .systemGray + var secondarySelectedBackground: UIColor = .systemGray + var buttonBackgroundNTPCustomization: UIColor = .systemGray + var privateButtonBackground: UIColor = .systemGray + var tabSelectedPrivateBackground: UIColor = .systemGray + var toastImageTint: UIColor = .systemGray + var newSeedCollectedCircle: UIColor = .systemGray + var tabTrayScreenshotBackground: UIColor = .systemGray + var tableViewRowText: UIColor = .systemGray +} diff --git a/BrowserKit/Sources/Common/Theming/LightTheme.swift b/BrowserKit/Sources/Common/Theming/LightTheme.swift index 558c266f8fcd..b8a28bf7a332 100644 --- a/BrowserKit/Sources/Common/Theming/LightTheme.swift +++ b/BrowserKit/Sources/Common/Theming/LightTheme.swift @@ -6,12 +6,22 @@ import UIKit public struct LightTheme: Theme { public var type: ThemeType = .light + /* Ecosia: Use Ecosia color palette subclass public var colors: ThemeColourPalette = LightColourPalette() + */ + public var colors: EcosiaThemeColourPalette = LightColourPalette() public init() {} } +/* Ecosia: Use Ecosia color palette subclass private struct LightColourPalette: ThemeColourPalette { + */ +private struct LightColourPalette: EcosiaThemeColourPalette { + var ecosia: EcosiaSemanticColors { + FakeEcosiaSemanticColors() + } + // MARK: - Layers var layer1: UIColor = FXColors.LightGrey10 var layer2: UIColor = FXColors.White diff --git a/BrowserKit/Sources/Common/Theming/PrivateModeTheme.swift b/BrowserKit/Sources/Common/Theming/PrivateModeTheme.swift index 5365d535b247..f0bccac000a8 100644 --- a/BrowserKit/Sources/Common/Theming/PrivateModeTheme.swift +++ b/BrowserKit/Sources/Common/Theming/PrivateModeTheme.swift @@ -6,12 +6,22 @@ import UIKit public struct PrivateModeTheme: Theme { public var type: ThemeType = .privateMode + /* Ecosia: Use Ecosia color palette subclass public var colors: ThemeColourPalette = PrivateModeColorPalette() + */ + public var colors: EcosiaThemeColourPalette = PrivateModeColorPalette() public init() {} } +/* Ecosia: Use Ecosia color palette subclass private struct PrivateModeColorPalette: ThemeColourPalette { + */ +private struct PrivateModeColorPalette: EcosiaThemeColourPalette { + var ecosia: EcosiaSemanticColors { + FakeEcosiaSemanticColors() + } + // MARK: - Layers var layer1: UIColor = FXColors.Violet90 var layer2: UIColor = FXColors.Violet90 diff --git a/BrowserKit/Sources/Common/Theming/Theme.swift b/BrowserKit/Sources/Common/Theming/Theme.swift index 2c7db6d67f69..71a13c1eae21 100644 --- a/BrowserKit/Sources/Common/Theming/Theme.swift +++ b/BrowserKit/Sources/Common/Theming/Theme.swift @@ -9,5 +9,8 @@ import Foundation /// dark mode) and fonts for the application. public protocol Theme { var type: ThemeType { get } + /* Ecosia: Use Ecosia color palette subclass var colors: ThemeColourPalette { get } + */ + var colors: EcosiaThemeColourPalette { get } } diff --git a/BrowserKit/Sources/Common/Theming/ThemeColourPalette.swift b/BrowserKit/Sources/Common/Theming/ThemeColourPalette.swift index 32d7dcceb6f8..d2aa57b7184e 100644 --- a/BrowserKit/Sources/Common/Theming/ThemeColourPalette.swift +++ b/BrowserKit/Sources/Common/Theming/ThemeColourPalette.swift @@ -97,8 +97,4 @@ public protocol ThemeColourPalette { // MARK: - Shadow var shadowDefault: UIColor { get } - - // MARK: - Ecosia Legacy Colors - // TODO Ecosia Upgrade: Can we get rid of them? [MOB-3152] - var layer6: UIColor { get } } diff --git a/BrowserKit/Sources/ComponentLibrary/Buttons/PrimaryRoundedButton.swift b/BrowserKit/Sources/ComponentLibrary/Buttons/PrimaryRoundedButton.swift index 9b729cd0d3d9..e154055be464 100644 --- a/BrowserKit/Sources/ComponentLibrary/Buttons/PrimaryRoundedButton.swift +++ b/BrowserKit/Sources/ComponentLibrary/Buttons/PrimaryRoundedButton.swift @@ -104,7 +104,6 @@ public class PrimaryRoundedButton: ResizableButton, ThemeApplicable { backgroundColorNormal = theme.colors.actionPrimary backgroundColorHighlighted = theme.colors.actionPrimaryHover backgroundColorDisabled = theme.colors.actionPrimaryDisabled - // TODO Ecosia Upgrade: Review if button color needs updating [MOB-3152] foregroundColor = theme.colors.textInverted foregroundColorDisabled = theme.colors.textInvertedDisabled setNeedsUpdateConfiguration() diff --git a/firefox-ios/Client.xcodeproj/project.pbxproj b/firefox-ios/Client.xcodeproj/project.pbxproj index f3effa820529..b4c7e4ad9849 100644 --- a/firefox-ios/Client.xcodeproj/project.pbxproj +++ b/firefox-ios/Client.xcodeproj/project.pbxproj @@ -68,24 +68,21 @@ 0EC57D082CA6FCA5002E3F04 /* PasswordGeneratorHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EC57D072CA6FCA5002E3F04 /* PasswordGeneratorHeaderView.swift */; }; 0EC57D0A2CA6FCC5002E3F04 /* PasswordGeneratorPasswordFieldView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EC57D092CA6FCC5002E3F04 /* PasswordGeneratorPasswordFieldView.swift */; }; 0ECB6B6D2CCFF718006A7C82 /* DateGroupedTableDataTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ECB6B672CCFE663006A7C82 /* DateGroupedTableDataTests.swift */; }; + 120251112D439F4000039A2F /* EcosiaColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120251102D439F3600039A2F /* EcosiaColor.swift */; }; + 120251122D439F4000039A2F /* EcosiaColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120251102D439F3600039A2F /* EcosiaColor.swift */; }; + 1202511E2D47885D00039A2F /* EcosiaLightTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1202511D2D47885700039A2F /* EcosiaLightTheme.swift */; }; + 1202511F2D47885D00039A2F /* EcosiaLightTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1202511D2D47885700039A2F /* EcosiaLightTheme.swift */; }; + 120251212D48EF8D00039A2F /* EcosiaPrimaryButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 120251202D48EF8600039A2F /* EcosiaPrimaryButton.swift */; }; 121E65DF2D36514E00DFBFA2 /* BaseTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3BF4B8E81D38497A00493393 /* BaseTestCase.swift */; }; 121E65E02D36515700DFBFA2 /* FxScreenGraph.swift in Sources */ = {isa = PBXBuildFile; fileRef = 39EB46981E26DDB4006346E8 /* FxScreenGraph.swift */; }; 121E65E12D36585A00DFBFA2 /* LaunchArguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = E65075861E37F7AB006961AC /* LaunchArguments.swift */; }; 121E65E22D36588400DFBFA2 /* AccessibilityIdentifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C84266742728462900382274 /* AccessibilityIdentifiers.swift */; }; 121E65E32D36595900DFBFA2 /* ImageIdentifiers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8A9F0B5527C595F300FE09AE /* ImageIdentifiers.swift */; }; - 124DAE7F2D301B290050104C /* RecoveredLegacyTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124DAE7A2D2FD1330050104C /* RecoveredLegacyTheme.swift */; }; - 124DAE802D301C490050104C /* LegacyThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124DAE7B2D2FD1330050104C /* LegacyThemeManager.swift */; }; - 124DAE812D301C550050104C /* LegacyDarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124DAE792D2FD1330050104C /* LegacyDarkTheme.swift */; }; 124DAE822D350EFD0050104C /* String+Punycode.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6B2AC11D41F02D00429414 /* String+Punycode.swift */; }; 124DAE832D350F750050104C /* EcosiaThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E792D2825AF00E4DDBF /* EcosiaThemeManager.swift */; }; - 124DAE842D350F8A0050104C /* EcosiaThemeColourPalette.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E782D2825AF00E4DDBF /* EcosiaThemeColourPalette.swift */; }; - 124DAE852D350F8E0050104C /* EcosiaTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB288E52B07C8F000A8FCB3 /* EcosiaTheme.swift */; }; + 124DAE842D350F8A0050104C /* EcosiaDarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E782D2825AF00E4DDBF /* EcosiaDarkTheme.swift */; }; 124DAE862D3510330050104C /* SemanticColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB288DD2B07C8EF00A8FCB3 /* SemanticColor.swift */; }; - 124DAE872D35106F0050104C /* LegacyDarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124DAE792D2FD1330050104C /* LegacyDarkTheme.swift */; }; - 124DAE882D3510750050104C /* RecoveredLegacyTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124DAE7A2D2FD1330050104C /* RecoveredLegacyTheme.swift */; }; - 124DAE892D35107A0050104C /* LegacyThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 124DAE7B2D2FD1330050104C /* LegacyThemeManager.swift */; }; 124DAE8A2D3512FA0050104C /* DispatchQueueHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D83821FF1FC7961D00303C12 /* DispatchQueueHelper.swift */; }; - 124DAE8B2D35137C0050104C /* LegacyThemeManager+Ecosia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E9B2D28289900E4DDBF /* LegacyThemeManager+Ecosia.swift */; }; 126509852CD925B40011BA36 /* BrazeKit in Frameworks */ = {isa = PBXBuildFile; productRef = 126509842CD925B40011BA36 /* BrazeKit */; }; 126509872CD925B40011BA36 /* BrazeUI in Frameworks */ = {isa = PBXBuildFile; productRef = 126509862CD925B40011BA36 /* BrazeUI */; }; 1265098A2CDA32790011BA36 /* BrazeServiceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 126509882CDA31890011BA36 /* BrazeServiceTests.swift */; }; @@ -165,8 +162,7 @@ 12C11E762D28254A00E4DDBF /* AboutEcosiaSection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB2890F2B07C8F000A8FCB3 /* AboutEcosiaSection.swift */; }; 12C11E772D28254A00E4DDBF /* NTPAboutEcosiaCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB289112B07C8F000A8FCB3 /* NTPAboutEcosiaCell.swift */; }; 12C11E7A2D2825AF00E4DDBF /* EcosiaThemeManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E792D2825AF00E4DDBF /* EcosiaThemeManager.swift */; }; - 12C11E7B2D2825AF00E4DDBF /* EcosiaThemeColourPalette.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E782D2825AF00E4DDBF /* EcosiaThemeColourPalette.swift */; }; - 12C11E7C2D2825B300E4DDBF /* EcosiaTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB288E52B07C8F000A8FCB3 /* EcosiaTheme.swift */; }; + 12C11E7B2D2825AF00E4DDBF /* EcosiaDarkTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E782D2825AF00E4DDBF /* EcosiaDarkTheme.swift */; }; 12C11E7D2D28261400E4DDBF /* Colours.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2CB289122B07C8F000A8FCB3 /* Colours.xcassets */; }; 12C11E7E2D28261800E4DDBF /* EcosiaNavigation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB289132B07C8F000A8FCB3 /* EcosiaNavigation.swift */; }; 12C11E7F2D28267100E4DDBF /* FilterController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB289142B07C8F000A8FCB3 /* FilterController.swift */; }; @@ -192,7 +188,6 @@ 12C11E982D28279C00E4DDBF /* NewsletterCardExperiment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E952D28279C00E4DDBF /* NewsletterCardExperiment.swift */; }; 12C11E992D28279C00E4DDBF /* SeedCounterNTPExperiment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E962D28279C00E4DDBF /* SeedCounterNTPExperiment.swift */; }; 12C11E9A2D28281100E4DDBF /* WebsiteConnectionStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB289422B07C8F000A8FCB3 /* WebsiteConnectionStatus.swift */; }; - 12C11EA12D28291300E4DDBF /* LegacyThemeManager+Ecosia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E9B2D28289900E4DDBF /* LegacyThemeManager+Ecosia.swift */; }; 12C11EA22D28291300E4DDBF /* DeviceInfo+Ecosia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB2894E2B07C8F000A8FCB3 /* DeviceInfo+Ecosia.swift */; }; 12C11EA32D28291300E4DDBF /* AppInfo+Ecosia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB2894B2B07C8F000A8FCB3 /* AppInfo+Ecosia.swift */; }; 12C11EA42D28291300E4DDBF /* URL+Ecosia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB2894D2B07C8F000A8FCB3 /* URL+Ecosia.swift */; }; @@ -208,8 +203,6 @@ 12C11EAE2D28291300E4DDBF /* SimpleToast+Ecosia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E9D2D2828AA00E4DDBF /* SimpleToast+Ecosia.swift */; }; 12C11EAF2D28291300E4DDBF /* UIButton+Ecosia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11E9C2D28289900E4DDBF /* UIButton+Ecosia.swift */; }; 12C11EB02D28291900E4DDBF /* DispatchQueueHelper+BuildChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11EA02D2828EA00E4DDBF /* DispatchQueueHelper+BuildChannel.swift */; }; - 12C11EB12D28292000E4DDBF /* ConnectionStatusImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB289522B07C8F000A8FCB3 /* ConnectionStatusImage.swift */; }; - 12C11EB22D28292000E4DDBF /* ConnectionStatusImage+WebsiteConnectionTypeStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB289502B07C8F000A8FCB3 /* ConnectionStatusImage+WebsiteConnectionTypeStatus.swift */; }; 12C11EB92D2829B200E4DDBF /* BookmarksExchange.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CB289542B07C8F000A8FCB3 /* BookmarksExchange.swift */; }; 12C11EBA2D2829BC00E4DDBF /* markets.json in Resources */ = {isa = PBXBuildFile; fileRef = 2CB289562B07C8F000A8FCB3 /* markets.json */; }; 12C11EC82D282A3D00E4DDBF /* EcosiaInstallType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 12C11EC22D282A3D00E4DDBF /* EcosiaInstallType+Extensions.swift */; }; @@ -2415,11 +2408,11 @@ 109E4D959F25FF2F13848417 /* jv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = jv; path = jv.lproj/AuthenticationManager.strings; sourceTree = ""; }; 10CD44F0A402C84BB31E5474 /* gu-IN */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "gu-IN"; path = "gu-IN.lproj/Intro.strings"; sourceTree = ""; }; 11F747589EB8A55A47647C93 /* bn */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = bn; path = bn.lproj/ClearPrivateData.strings; sourceTree = ""; }; + 120251102D439F3600039A2F /* EcosiaColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaColor.swift; sourceTree = ""; }; + 1202511D2D47885700039A2F /* EcosiaLightTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaLightTheme.swift; sourceTree = ""; }; + 120251202D48EF8600039A2F /* EcosiaPrimaryButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaPrimaryButton.swift; sourceTree = ""; }; 120F42119EB30F217AB9493E /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/FindInPage.strings; sourceTree = ""; }; 123045959E0F295753B4B4DB /* lo */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = lo; path = lo.lproj/Today.strings; sourceTree = ""; }; - 124DAE792D2FD1330050104C /* LegacyDarkTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyDarkTheme.swift; sourceTree = ""; }; - 124DAE7A2D2FD1330050104C /* RecoveredLegacyTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecoveredLegacyTheme.swift; sourceTree = ""; }; - 124DAE7B2D2FD1330050104C /* LegacyThemeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyThemeManager.swift; sourceTree = ""; }; 126509882CDA31890011BA36 /* BrazeServiceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrazeServiceTests.swift; sourceTree = ""; }; 12674A038346A46589A0AC0B /* el */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = el; path = "el.lproj/Default Browser.strings"; sourceTree = ""; }; 126A40A4A5AFDFD655B0FDF4 /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/ClearHistoryConfirm.strings; sourceTree = ""; }; @@ -2463,12 +2456,11 @@ 12C11E562D28238700E4DDBF /* NTPNewsletterCardViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NTPNewsletterCardViewModel.swift; sourceTree = ""; }; 12C11E582D28238700E4DDBF /* NTPConfigurableNudgeCardCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NTPConfigurableNudgeCardCell.swift; sourceTree = ""; }; 12C11E592D28238700E4DDBF /* NTPConfigurableNudgeCardCellViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NTPConfigurableNudgeCardCellViewModel.swift; sourceTree = ""; }; - 12C11E782D2825AF00E4DDBF /* EcosiaThemeColourPalette.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaThemeColourPalette.swift; sourceTree = ""; }; + 12C11E782D2825AF00E4DDBF /* EcosiaDarkTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaDarkTheme.swift; sourceTree = ""; }; 12C11E792D2825AF00E4DDBF /* EcosiaThemeManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaThemeManager.swift; sourceTree = ""; }; 12C11E942D28279C00E4DDBF /* BrazeIntegrationExperiment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrazeIntegrationExperiment.swift; sourceTree = ""; }; 12C11E952D28279C00E4DDBF /* NewsletterCardExperiment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewsletterCardExperiment.swift; sourceTree = ""; }; 12C11E962D28279C00E4DDBF /* SeedCounterNTPExperiment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeedCounterNTPExperiment.swift; sourceTree = ""; }; - 12C11E9B2D28289900E4DDBF /* LegacyThemeManager+Ecosia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LegacyThemeManager+Ecosia.swift"; sourceTree = ""; }; 12C11E9C2D28289900E4DDBF /* UIButton+Ecosia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIButton+Ecosia.swift"; sourceTree = ""; }; 12C11E9D2D2828AA00E4DDBF /* SimpleToast+Ecosia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SimpleToast+Ecosia.swift"; sourceTree = ""; }; 12C11E9F2D2828C200E4DDBF /* BrowserCoordinator+Ecosia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BrowserCoordinator+Ecosia.swift"; sourceTree = ""; }; @@ -2885,7 +2877,6 @@ 2CB288E22B07C8EF00A8FCB3 /* EmptyBookmarksViewDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyBookmarksViewDelegate.swift; sourceTree = ""; }; 2CB288E32B07C8EF00A8FCB3 /* EcosiaFindInPageBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EcosiaFindInPageBar.swift; sourceTree = ""; }; 2CB288E42B07C8F000A8FCB3 /* Ecosia.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Ecosia.xcassets; sourceTree = ""; }; - 2CB288E52B07C8F000A8FCB3 /* EcosiaTheme.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EcosiaTheme.swift; sourceTree = ""; }; 2CB288E62B07C8F000A8FCB3 /* EmptyHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyHeader.swift; sourceTree = ""; }; 2CB288E82B07C8F000A8FCB3 /* WhatsNewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WhatsNewCell.swift; sourceTree = ""; }; 2CB288E92B07C8F000A8FCB3 /* WhatsNewViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WhatsNewViewModel.swift; sourceTree = ""; }; @@ -2962,8 +2953,6 @@ 2CB2894C2B07C8F000A8FCB3 /* NumberFormatter+Ecosia.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NumberFormatter+Ecosia.swift"; sourceTree = ""; }; 2CB2894D2B07C8F000A8FCB3 /* URL+Ecosia.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "URL+Ecosia.swift"; sourceTree = ""; }; 2CB2894E2B07C8F000A8FCB3 /* DeviceInfo+Ecosia.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DeviceInfo+Ecosia.swift"; sourceTree = ""; }; - 2CB289502B07C8F000A8FCB3 /* ConnectionStatusImage+WebsiteConnectionTypeStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConnectionStatusImage+WebsiteConnectionTypeStatus.swift"; sourceTree = ""; }; - 2CB289522B07C8F000A8FCB3 /* ConnectionStatusImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConnectionStatusImage.swift; sourceTree = ""; }; 2CB289542B07C8F000A8FCB3 /* BookmarksExchange.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BookmarksExchange.swift; sourceTree = ""; }; 2CB289562B07C8F000A8FCB3 /* markets.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = markets.json; sourceTree = ""; }; 2CB289582B07C8F000A8FCB3 /* FakeTelemetry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeTelemetry.swift; sourceTree = ""; }; @@ -2976,7 +2965,6 @@ 2CCF17522105E4FD00705AE5 /* DisplaySettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplaySettingsTests.swift; sourceTree = ""; }; 2CD368492C5BC31700972871 /* OnboardingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingTests.swift; sourceTree = ""; }; 2CD48B7E2C7F7E4100A70908 /* EcosiaOverlayModeManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaOverlayModeManagerTests.swift; sourceTree = ""; }; - 2CDF61902B56E7B6001186DB /* EcosiaLegacyTabTrayViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EcosiaLegacyTabTrayViewController.swift; sourceTree = ""; }; 2CE294672B7FC5A4006C22B2 /* EcosiaInstallTypeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EcosiaInstallTypeTests.swift; sourceTree = ""; }; 2CE294692B7FC5A5006C22B2 /* AnalyticsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnalyticsTests.swift; sourceTree = ""; }; 2CE2946B2B7FC5A5006C22B2 /* WhatsNewLocalDataProviderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WhatsNewLocalDataProviderTests.swift; sourceTree = ""; }; @@ -10013,10 +10001,7 @@ 124DAE782D2FD0C90050104C /* RecoveredFromUpgrade */ = { isa = PBXGroup; children = ( - 124DAE792D2FD1330050104C /* LegacyDarkTheme.swift */, 12AEB1252D3A51670035D7D8 /* LegacySessionData.swift */, - 124DAE7B2D2FD1330050104C /* LegacyThemeManager.swift */, - 124DAE7A2D2FD1330050104C /* RecoveredLegacyTheme.swift */, 12AEB1272D3A568D0035D7D8 /* SessionRestoreHandler.swift */, ); path = RecoveredFromUpgrade; @@ -10198,7 +10183,6 @@ C81AC6B526160091007800C5 /* LegacyTabTrayViewModel.swift */, 968BD7EA27DFF0F8003148B3 /* ASGroup.swift */, 216C133D29DCA8FF0097533B /* LegacyTabLayoutDelegate.swift */, - 2CDF61902B56E7B6001186DB /* EcosiaLegacyTabTrayViewController.swift */, ); path = Legacy; sourceTree = ""; @@ -10657,9 +10641,11 @@ 2C7DC2392B16352200C049C8 /* Theme */ = { isa = PBXGroup; children = ( - 2CB288E52B07C8F000A8FCB3 /* EcosiaTheme.swift */, - 12C11E782D2825AF00E4DDBF /* EcosiaThemeColourPalette.swift */, + 1202511D2D47885700039A2F /* EcosiaLightTheme.swift */, + 120251102D439F3600039A2F /* EcosiaColor.swift */, + 12C11E782D2825AF00E4DDBF /* EcosiaDarkTheme.swift */, 12C11E792D2825AF00E4DDBF /* EcosiaThemeManager.swift */, + 2CB288DD2B07C8EF00A8FCB3 /* SemanticColor.swift */, ); path = Theme; sourceTree = ""; @@ -10712,8 +10698,8 @@ 2CB288DC2B07C8EF00A8FCB3 /* UI */ = { isa = PBXGroup; children = ( + 120251202D48EF8600039A2F /* EcosiaPrimaryButton.swift */, 12C11E2A2D281E7600E4DDBF /* LoadingScreen.swift */, - 2CB288DD2B07C8EF00A8FCB3 /* SemanticColor.swift */, 2CB288DE2B07C8EF00A8FCB3 /* PageAction */, 2CB288E22B07C8EF00A8FCB3 /* EmptyBookmarksViewDelegate.swift */, 2CB288E32B07C8EF00A8FCB3 /* EcosiaFindInPageBar.swift */, @@ -10930,7 +10916,6 @@ isa = PBXGroup; children = ( 2CB289442B07C8F000A8FCB3 /* BrowserViewController+Ecosia.swift */, - 12C11E9B2D28289900E4DDBF /* LegacyThemeManager+Ecosia.swift */, 12C11E9C2D28289900E4DDBF /* UIButton+Ecosia.swift */, 2CB289452B07C8F000A8FCB3 /* UIFont+Ecosia.swift */, 2CB289462B07C8F000A8FCB3 /* ErrorPageHandler+Ecosia.swift */, @@ -10944,21 +10929,11 @@ 12C11E9F2D2828C200E4DDBF /* BrowserCoordinator+Ecosia.swift */, 2CF2206E2B72B0530038157D /* AppSettingsTableViewController+Ecosia.swift */, 2CB2894E2B07C8F000A8FCB3 /* DeviceInfo+Ecosia.swift */, - 2CB2894F2B07C8F000A8FCB3 /* Toolbar+URLBar */, 12C11EA02D2828EA00E4DDBF /* DispatchQueueHelper+BuildChannel.swift */, ); path = Extensions; sourceTree = ""; }; - 2CB2894F2B07C8F000A8FCB3 /* Toolbar+URLBar */ = { - isa = PBXGroup; - children = ( - 2CB289502B07C8F000A8FCB3 /* ConnectionStatusImage+WebsiteConnectionTypeStatus.swift */, - 2CB289522B07C8F000A8FCB3 /* ConnectionStatusImage.swift */, - ); - path = "Toolbar+URLBar"; - sourceTree = ""; - }; 2CB289532B07C8F000A8FCB3 /* Bookmarks */ = { isa = PBXGroup; children = ( @@ -16466,7 +16441,6 @@ 8A4AC0EC28C929D700439F83 /* URLSessionProtocol.swift in Sources */, C2A72A672A76938C002ACCE2 /* DownloadsCoordinator.swift in Sources */, 5FC276552894AEFF00AF2721 /* LibraryPanelHelper.swift in Sources */, - 124DAE812D301C550050104C /* LegacyDarkTheme.swift in Sources */, E1CD81C5290C6D5800124B27 /* HelpView.swift in Sources */, 5A47CFF52860FB8900B2B7BF /* AppLaunchUtil.swift in Sources */, C8B0F5ED283B7C9F007AE65D /* LegacyPocketStandardCell.swift in Sources */, @@ -16534,6 +16508,7 @@ EBF47E701F7979DF00899189 /* TelemetryWrapper.swift in Sources */, 8AD40FCF27BADC6B00672675 /* URLTextField.swift in Sources */, 31ADB5DA1E58CEC300E87909 /* ClipboardBarDisplayHandler.swift in Sources */, + 120251112D439F4000039A2F /* EcosiaColor.swift in Sources */, 8AD1980F27BEB3F100D64B0E /* PhotonActionSheetViewModel.swift in Sources */, EB9A179D20E69A7F00B12184 /* LegacyTheme.swift in Sources */, 2128E2802934FBB400FB91BE /* CopyLinkActivity.swift in Sources */, @@ -16590,7 +16565,6 @@ C2A72A692A769460002ACCE2 /* ReadingListCoordinator.swift in Sources */, 12AEB1262D3A51670035D7D8 /* LegacySessionData.swift in Sources */, EDC3C2562CCAC9CB005A047F /* SearchEnginesManager.swift in Sources */, - 124DAE802D301C490050104C /* LegacyThemeManager.swift in Sources */, F85C7F122721048E004BDBA4 /* Layout.swift in Sources */, DF036E43274FD434002E834E /* HistoryHighlightsCell.swift in Sources */, B2FEA68D2B460D390058E616 /* AddressAutofillSettingsViewController.swift in Sources */, @@ -16653,7 +16627,6 @@ 0BF0DB941A8545800039F300 /* URLBarView.swift in Sources */, DFACBF7F277B5F7B003D5F41 /* WallpaperBackgroundView.swift in Sources */, 8A7D08E32CAAF7C30035999C /* HomepageViewController.swift in Sources */, - 124DAE7F2D301B290050104C /* RecoveredLegacyTheme.swift in Sources */, D01017F5219CB6BD009CBB5A /* DownloadContentScript.swift in Sources */, 8A093D832A4B68940099ABA5 /* PrivacySettingsDelegate.swift in Sources */, C8DC90C32A066B4A0008832B /* MarkupToken.swift in Sources */, @@ -16817,6 +16790,7 @@ E19B38B328A42D5E00D8C541 /* WallpaperCollectionViewCell.swift in Sources */, 0BB5B30B1AC0AD1F0052877D /* LoginsHelper.swift in Sources */, 12C11E342D28205E00E4DDBF /* EmptyHeader.swift in Sources */, + 120251212D48EF8D00039A2F /* EcosiaPrimaryButton.swift in Sources */, 8A3EF8092A2FD02B00796E3A /* ExperimentsSettings.swift in Sources */, C87DF9DB267247190097E707 /* UIConstants+BottomInset.swift in Sources */, 8AD08D1527E9198E00B8E907 /* TabsTelemetry.swift in Sources */, @@ -16862,8 +16836,6 @@ 8C2937702BF79F0300146613 /* EditAddressLocalization.swift in Sources */, 742A56391D80B54A00BDB803 /* PhotonActionSheet.swift in Sources */, C4EFEECF1CEBB6F2009762A4 /* BackForwardTableViewCell.swift in Sources */, - 12C11EB12D28292000E4DDBF /* ConnectionStatusImage.swift in Sources */, - 12C11EB22D28292000E4DDBF /* ConnectionStatusImage+WebsiteConnectionTypeStatus.swift in Sources */, E1442FD3294782D9003680B0 /* UIView+Constraints.swift in Sources */, 5A70EF21295E3E0B00790249 /* UnitTestSceneDelegate.swift in Sources */, 2C49854E206173C800893DAE /* photon-colors.swift in Sources */, @@ -16915,7 +16887,6 @@ E17496402994302D0096900A /* PreferredFont.swift in Sources */, E1442FD4294782D9003680B0 /* URL+Mail.swift in Sources */, AB4FB4DD2C89FB10005EF0CC /* BlockedTrackersTableView.swift in Sources */, - 12C11E7C2D2825B300E4DDBF /* EcosiaTheme.swift in Sources */, 9636D92827F5D72D00771F5E /* GleanPlumbMessageManager.swift in Sources */, C80685D126A0C93900DCD895 /* UserResearch.swift in Sources */, B2999FF52B194AB200F0FEC1 /* FormAutofillHelperError.swift in Sources */, @@ -17253,7 +17224,6 @@ 8A5D1CC12A30DCA4005AD35C /* SettingDisclosureUtility.swift in Sources */, E1442FD5294782D9003680B0 /* UIView+SnapKit.swift in Sources */, E1ADE23C2B0649F200FD17AA /* FakespotState.swift in Sources */, - 12C11EA12D28291300E4DDBF /* LegacyThemeManager+Ecosia.swift in Sources */, 12C11EA22D28291300E4DDBF /* DeviceInfo+Ecosia.swift in Sources */, 12C11EA32D28291300E4DDBF /* AppInfo+Ecosia.swift in Sources */, 12C11EA42D28291300E4DDBF /* URL+Ecosia.swift in Sources */, @@ -17348,6 +17318,7 @@ 8AB8571F27D931B40075C173 /* EmptyTopSiteCell.swift in Sources */, CAC458F1249429C20042561A /* PasswordManagerSelectionHelper.swift in Sources */, C8656D75270F834600E199EA /* FlaggableFeatureOptions.swift in Sources */, + 1202511E2D47885D00039A2F /* EcosiaLightTheme.swift in Sources */, 1BE7A4922C636AEA00460798 /* URLSessionConfiguration+defaultMPTCP.swift in Sources */, C8CD80D82A1E31C20097C3AE /* NimbusOnboardingTestingConfigUtility.swift in Sources */, 81E1914D2BB8578600543D78 /* OnboardingMultipleChoiceSelectionDelegate.swift in Sources */, @@ -17471,7 +17442,7 @@ 12C11E5D2D28238700E4DDBF /* NTPConfigurableNudgeCardCell.swift in Sources */, 12C11E5E2D28238700E4DDBF /* NTPConfigurableNudgeCardCellViewModel.swift in Sources */, 12C11E7A2D2825AF00E4DDBF /* EcosiaThemeManager.swift in Sources */, - 12C11E7B2D2825AF00E4DDBF /* EcosiaThemeColourPalette.swift in Sources */, + 12C11E7B2D2825AF00E4DDBF /* EcosiaDarkTheme.swift in Sources */, 21F2A2D22B0BC85200626AEC /* InactiveTabsModel.swift in Sources */, D3E8EF101B97BE69001900FB /* ClearPrivateDataTableViewController.swift in Sources */, C8F457AA1F1FDD9B000CB895 /* BrowserViewController+KeyCommands.swift in Sources */, @@ -17869,12 +17840,11 @@ E1CD81C6290C6D5800124B27 /* HelpView.swift in Sources */, E1D6F2D828E325D100B2C8CC /* InstructionsView.swift in Sources */, BD2577982C9D85B5007B344C /* AnyHashable.swift in Sources */, - 124DAE882D3510750050104C /* RecoveredLegacyTheme.swift in Sources */, E1D6F2D928E32A5300B2C8CC /* ImageIdentifiers.swift in Sources */, 124DAE862D3510330050104C /* SemanticColor.swift in Sources */, + 1202511F2D47885D00039A2F /* EcosiaLightTheme.swift in Sources */, F8A0B08429AD64790091C75B /* RustSyncManager.swift in Sources */, EB6E0C60207E6C3100FBFF7E /* SendToDevice.swift in Sources */, - 124DAE892D35107A0050104C /* LegacyThemeManager.swift in Sources */, D3C744CF1A687D6C004CE85D /* URIFixup.swift in Sources */, 2C7DC2462B16493C00C049C8 /* UIConstants.swift in Sources */, EB94075320850C9F00702E05 /* photon-colors.swift in Sources */, @@ -17882,27 +17852,25 @@ D38B2D8C1A8D98D90040E6B5 /* OpenSearchParser.swift in Sources */, D04CD74D216CF86F004FF5B0 /* DevicePickerViewController.swift in Sources */, 124DAE832D350F750050104C /* EcosiaThemeManager.swift in Sources */, - 124DAE872D35106F0050104C /* LegacyDarkTheme.swift in Sources */, 6025B10F267B6C7F00F59F6B /* LoginRecordExtension.swift in Sources */, E418D0D91A251B3200CAE47A /* Profile.swift in Sources */, ED07C0E72CCACE18006C0627 /* Locale+possibilitiesForLanguageIdentifier.swift in Sources */, E1CD81C3290C670A00124B27 /* HostingTableViewCell.swift in Sources */, DDA24A451FD84D630098F159 /* DefaultSearchPrefs.swift in Sources */, - 124DAE852D350F8E0050104C /* EcosiaTheme.swift in Sources */, F8708D321A0970B70051AB07 /* ShareViewController.swift in Sources */, EB9407492081353100702E05 /* UXConstants.swift in Sources */, F8B710A02ABE38980029726E /* RustErrors.swift in Sources */, E60D03271D511554002FE3F6 /* SyncDisplayState.swift in Sources */, - 124DAE8B2D35137C0050104C /* LegacyThemeManager+Ecosia.swift in Sources */, 210E0EBB298D9D6600BB4F33 /* OpenSearchEngine.swift in Sources */, 2128E27C2930216F00FB91BE /* SendToDeviceHelper.swift in Sources */, E136D41A2B19D35D003D0302 /* EmbeddedNavController.swift in Sources */, + 120251122D439F4000039A2F /* EcosiaColor.swift in Sources */, 124DAE822D350EFD0050104C /* String+Punycode.swift in Sources */, E1CD81C0290C5C9800124B27 /* DevicePickerTableViewCell.swift in Sources */, E1CD81BA290C4ED900124B27 /* AccessibilityIdentifiers.swift in Sources */, E1CD81BF290C5C9500124B27 /* DevicePickerTableViewHeaderCell.swift in Sources */, 1D1933782AF2C8CE005089C9 /* AppEvent.swift in Sources */, - 124DAE842D350F8A0050104C /* EcosiaThemeColourPalette.swift in Sources */, + 124DAE842D350F8A0050104C /* EcosiaDarkTheme.swift in Sources */, 1D1933752AF2C8C9005089C9 /* EventQueue.swift in Sources */, E41A7D4B1A1BE04500245963 /* InitialViewController.swift in Sources */, ); diff --git a/firefox-ios/Client/Coordinators/Launch/LaunchCoordinator.swift b/firefox-ios/Client/Coordinators/Launch/LaunchCoordinator.swift index e6609b94b4e1..7fb281a192f1 100644 --- a/firefox-ios/Client/Coordinators/Launch/LaunchCoordinator.swift +++ b/firefox-ios/Client/Coordinators/Launch/LaunchCoordinator.swift @@ -60,7 +60,7 @@ class LaunchCoordinator: BaseCoordinator, self.parentCoordinator?.didFinishLaunch(from: self) } */ - let introViewController = WelcomeNavigation(rootViewController: Welcome(delegate: self)) + let introViewController = WelcomeNavigation(rootViewController: Welcome(delegate: self, windowUUID: windowUUID)) introViewController.isNavigationBarHidden = true introViewController.edgesForExtendedLayout = UIRectEdge(rawValue: 0) if isFullScreen { diff --git a/firefox-ios/Client/Ecosia/Bookmarks/BookmarksExchange.swift b/firefox-ios/Client/Ecosia/Bookmarks/BookmarksExchange.swift index 6839db8e5cf6..678c0c6b6ebd 100644 --- a/firefox-ios/Client/Ecosia/Bookmarks/BookmarksExchange.swift +++ b/firefox-ios/Client/Ecosia/Bookmarks/BookmarksExchange.swift @@ -6,6 +6,7 @@ import Foundation import Core import Shared import Storage +import Common import class MozillaAppServices.BookmarkFolderData @@ -36,8 +37,10 @@ final class BookmarksExchange: BookmarksExchangable { func export(bookmarks: [Core.BookmarkItem], in viewController: UIViewController, barButtonItem: UIBarButtonItem) async throws { guard let view = viewController.view else { return } + let theme = themeFromView(view: view) + let activityIndicator = UIActivityIndicatorView(style: .medium) - activityIndicator.color = UIColor.legacyTheme.ecosia.primaryBrand + activityIndicator.color = theme.colors.ecosia.brandPrimary activityIndicator.startAnimating() let toast = SimpleToast() @@ -46,6 +49,7 @@ final class BookmarksExchange: BookmarksExchangable { .localized(.exportingBookmarks), image: .view(activityIndicator), bottomContainer: view, + theme: theme, bottomInset: view.layoutMargins.bottom ) @@ -64,6 +68,7 @@ final class BookmarksExchange: BookmarksExchangable { .localized(.bookmarksExported), image: .named("bookmarkSuccess"), bottomContainer: view, + theme: theme, bottomInset: view.layoutMargins.bottom ) } @@ -84,6 +89,7 @@ final class BookmarksExchange: BookmarksExchangable { .localized(.importingBookmarks), image: .view(activityIndicator), bottomContainer: view, + theme: themeFromView(view: view), bottomInset: view.layoutMargins.bottom ) @@ -129,6 +135,7 @@ final class BookmarksExchange: BookmarksExchangable { .localized(.bookmarksImported), image: .named("bookmarkSuccess"), bottomContainer: view, + theme: themeFromView(view: view), bottomInset: view.layoutMargins.bottom ) } @@ -158,6 +165,11 @@ final class BookmarksExchange: BookmarksExchangable { } } } + + private func themeFromView(view: UIView) -> Theme { + let themeManager: ThemeManager = AppContainer.shared.resolve() + return themeManager.getCurrentTheme(for: view.currentWindowUUID) + } } private extension BookmarksExchange { diff --git a/firefox-ios/Client/Ecosia/Extensions/AppSettingsTableViewController+Ecosia.swift b/firefox-ios/Client/Ecosia/Extensions/AppSettingsTableViewController+Ecosia.swift index 0e195e5f13b6..6fd410071bda 100644 --- a/firefox-ios/Client/Ecosia/Extensions/AppSettingsTableViewController+Ecosia.swift +++ b/firefox-ios/Client/Ecosia/Extensions/AppSettingsTableViewController+Ecosia.swift @@ -141,7 +141,7 @@ extension AppSettingsTableViewController { PushBackInstallation(settings: self), OpenFiftyTabsDebugOption(settings: self, settingsDelegate: self), ToggleImpactIntro(settings: self), - ShowTour(settings: self), + ShowTour(settings: self, windowUUID: windowUUID), CreateReferralCode(settings: self), AddReferral(settings: self), AddClaim(settings: self), diff --git a/firefox-ios/Client/Ecosia/Extensions/BrowserViewController+Ecosia.swift b/firefox-ios/Client/Ecosia/Extensions/BrowserViewController+Ecosia.swift index c7903fcde20d..096c0fd2e87d 100644 --- a/firefox-ios/Client/Ecosia/Extensions/BrowserViewController+Ecosia.swift +++ b/firefox-ios/Client/Ecosia/Extensions/BrowserViewController+Ecosia.swift @@ -74,7 +74,7 @@ extension BrowserViewController { } private func presentLoadingScreen() { - present(LoadingScreen(profile: profile, referrals: referrals, referralCode: User.shared.referrals.pendingClaim), animated: true) + present(LoadingScreen(profile: profile, referrals: referrals, windowUUID: windowUUID, referralCode: User.shared.referrals.pendingClaim), animated: true) } private func handleFirstTimeUserActions() { diff --git a/firefox-ios/Client/Ecosia/Extensions/HomepageViewController+Ecosia.swift b/firefox-ios/Client/Ecosia/Extensions/HomepageViewController+Ecosia.swift index 25ee1456ea4f..06f00b76d433 100644 --- a/firefox-ios/Client/Ecosia/Extensions/HomepageViewController+Ecosia.swift +++ b/firefox-ios/Client/Ecosia/Extensions/HomepageViewController+Ecosia.swift @@ -118,7 +118,8 @@ extension LegacyHomepageViewController: NTPImpactCellDelegate { extension LegacyHomepageViewController: NTPNewsCellDelegate { func openSeeAllNews() { - let news = NewsController(windowUUID: windowUUID, items: viewModel.newsViewModel.items) + let news = NewsController(items: viewModel.newsViewModel.items, + windowUUID: windowUUID) news.delegate = self let nav = EcosiaNavigation(rootViewController: news) present(nav, animated: true) diff --git a/firefox-ios/Client/Ecosia/Extensions/LegacyThemeManager+Ecosia.swift b/firefox-ios/Client/Ecosia/Extensions/LegacyThemeManager+Ecosia.swift deleted file mode 100644 index cc85c9058c14..000000000000 --- a/firefox-ios/Client/Ecosia/Extensions/LegacyThemeManager+Ecosia.swift +++ /dev/null @@ -1,45 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import Foundation -import UIKit -import Common - -extension LegacyThemeManager { - /// Updates the theme based on the changes in the trait collection. - /// - /// - Parameters: - /// - from: The previous trait collection. This is optional as it may be nil when there's no previous state to compare to. - /// - to: The new trait collection after the change. This is used to determine the current theme settings. - /// - forceDark: A boolean indicating whether the dark theme should be forced on regardless of the system theme. The default value is `false`. - func themeChanged(from: UITraitCollection?, to: UITraitCollection, forceDark: Bool = false) { - // Determine if the color appearance has changed between the previous and new trait collections. - let colorHasChanged = to.hasDifferentColorAppearance(comparedTo: from) - - // Return early and do not change the theme if the color hasn't changed, dark mode is forced, - // or the system theme is already in effect. - guard colorHasChanged, - !forceDark, - systemThemeIsOn else { return } - - // Update the current theme based on the new user interface style. - let userInterfaceStyle = to.userInterfaceStyle - current = userInterfaceStyle == .dark ? LegacyDarkTheme() : LegacyNormalTheme() - } -} - -/* TODO Ecosia Upgrade: Re-add if LegacyThemeManager is kept [MOB-3152] -extension LegacyThemeManager { - - /// Updates the current theme based on the system theme type provided by the `EcosiaThemeManager`. - /// - /// This method retrieves the `EcosiaThemeManager` from the shared `AppContainer` and updates - /// the theme accordingly. It checks whether the system theme type is dark and sets the - /// `current` theme to `LegacyDarkTheme` or `LegacyNormalTheme` based on that. - static func updateBasedOnCurrentSystemThemeType() { - // Update the current theme based on the system theme type. - LegacyThemeManager.instance.current = EcosiaThemeManager.getSystemThemeType() == .dark ? LegacyDarkTheme() : LegacyNormalTheme() - } -} -*/ diff --git a/firefox-ios/Client/Ecosia/Extensions/SimpleToast+Ecosia.swift b/firefox-ios/Client/Ecosia/Extensions/SimpleToast+Ecosia.swift index 1c26fd07a922..891fb1ffbd53 100644 --- a/firefox-ios/Client/Ecosia/Extensions/SimpleToast+Ecosia.swift +++ b/firefox-ios/Client/Ecosia/Extensions/SimpleToast+Ecosia.swift @@ -3,6 +3,7 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/ import Foundation +import Common extension SimpleToast { @@ -16,9 +17,10 @@ extension SimpleToast { _ text: String, image: AccessoryImage, bottomContainer: UIView, + theme: Theme, bottomInset: CGFloat? = nil ) -> SimpleToast { - let toast = self.createView(text: text, image: image) + let toast = self.createView(text: text, image: image, theme: theme) toast.layer.cornerRadius = 10 toast.layer.masksToBounds = true @@ -33,19 +35,21 @@ extension SimpleToast { return self } - fileprivate func createView(text: String, image: AccessoryImage) -> UIStackView { + fileprivate func createView(text: String, + image: AccessoryImage, + theme: Theme) -> UIStackView { let stack = UIStackView() stack.axis = .horizontal stack.alignment = .center stack.distribution = .fill stack.spacing = 8 stack.layer.cornerRadius = 10 - stack.backgroundColor = UIColor.legacyTheme.ecosia.quarternaryBackground + stack.backgroundColor = theme.colors.ecosia.backgroundQuaternary let toast = UILabel() toast.text = text toast.numberOfLines = 1 - toast.textColor = UIColor.legacyTheme.ecosia.primaryTextInverted + toast.textColor = theme.colors.ecosia.textInversePrimary toast.font = UIFont.preferredFont(forTextStyle: .body) toast.adjustsFontForContentSizeCategory = true toast.adjustsFontSizeToFitWidth = true @@ -57,7 +61,7 @@ extension SimpleToast { switch image { case let .named(name): imageView = UIImageView(image: .init(named: name)?.withRenderingMode(.alwaysTemplate)) - imageView.tintColor = UIColor.legacyTheme.ecosia.toastImageTint + imageView.tintColor = theme.colors.ecosia.toastImageTint imageView.contentMode = .scaleAspectFit imageView.setContentHuggingPriority(.required, for: .horizontal) case let .view(view): diff --git a/firefox-ios/Client/Ecosia/Extensions/Toolbar+URLBar/ConnectionStatusImage+WebsiteConnectionTypeStatus.swift b/firefox-ios/Client/Ecosia/Extensions/Toolbar+URLBar/ConnectionStatusImage+WebsiteConnectionTypeStatus.swift deleted file mode 100644 index 66f95e3b3524..000000000000 --- a/firefox-ios/Client/Ecosia/Extensions/Toolbar+URLBar/ConnectionStatusImage+WebsiteConnectionTypeStatus.swift +++ /dev/null @@ -1,18 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import Shared - -extension ConnectionStatusImage { - - /// Retrieves the image with its appriate `tintColor` based on the website scheme (e.g. http or https) - static func getForStatus(status: WebsiteConnectionTypeStatus) -> UIImage? { - switch status { - case .secure: - return ConnectionStatusImage.connectionSecureImage - case .unsecure: - return ConnectionStatusImage.connectionUnsecureImage - } - } -} diff --git a/firefox-ios/Client/Ecosia/Extensions/Toolbar+URLBar/ConnectionStatusImage.swift b/firefox-ios/Client/Ecosia/Extensions/Toolbar+URLBar/ConnectionStatusImage.swift deleted file mode 100644 index f0b58927d67b..000000000000 --- a/firefox-ios/Client/Ecosia/Extensions/Toolbar+URLBar/ConnectionStatusImage.swift +++ /dev/null @@ -1,15 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import Foundation - -struct ConnectionStatusImage { - - static var connectionSecureImage: UIImage? { - UIImage.templateImageNamed("secureLock")?.tinted(withColor: .legacyTheme.ecosia.secondaryIcon) - } - static var connectionUnsecureImage: UIImage? { - UIImage.templateImageNamed("problem")?.tinted(withColor: .legacyTheme.ecosia.warning) - } -} diff --git a/firefox-ios/Client/Ecosia/Frontend/Home/TopSites/Cell/EcosiaTopSiteItemCell.swift b/firefox-ios/Client/Ecosia/Frontend/Home/TopSites/Cell/EcosiaTopSiteItemCell.swift index 63f670fc7311..b5dae4dbfc28 100644 --- a/firefox-ios/Client/Ecosia/Frontend/Home/TopSites/Cell/EcosiaTopSiteItemCell.swift +++ b/firefox-ios/Client/Ecosia/Frontend/Home/TopSites/Cell/EcosiaTopSiteItemCell.swift @@ -215,7 +215,7 @@ extension TopSiteItemCell: ThemeApplicable { pinImageView.tintColor = textColor ?? theme.colors.iconPrimary titleLabel.textColor = textColor ?? theme.colors.textPrimary selectedOverlay.backgroundColor = theme.colors.layer5Hover.withAlphaComponent(0.25) - rootContainer.backgroundColor = .legacyTheme.ecosia.secondaryButton + rootContainer.backgroundColor = theme.colors.ecosia.buttonBackgroundSecondary } } diff --git a/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/LegacyDarkTheme.swift b/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/LegacyDarkTheme.swift deleted file mode 100644 index cda0454120e0..000000000000 --- a/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/LegacyDarkTheme.swift +++ /dev/null @@ -1,38 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import UIKit - -private class DarkBrowserColor: BrowserColor { - override var background: UIColor { return UIColor.Photon.DarkGrey60 } -} - -private class DarkTableViewColor: TableViewColor { - override var rowText: UIColor { return UIColor.Photon.Grey10 } // textPrimary - override var disabledRowText: UIColor { return UIColor.Photon.Grey40 } // textDisabled - // Ecosia: Re enabling legacy colo references - override var accessoryViewTint: UIColor { return .Dark.Text.secondary } - override var headerBackground: UIColor { .Dark.Background.primary } - override var separator: UIColor { .Dark.border } - override var rowBackground: UIColor { return .Dark.Background.secondary } -} - -private class DarkTabTrayColor: TabTrayColor { - override var tabTitleBlur: UIBlurEffect.Style { return UIBlurEffect.Style.dark } - // Ecosia: Add legacy color references from 9.1.0 App Version - override var screenshotBackground: UIColor { return UIColor.Photon.DarkGrey30 } - override var cellBackground: UIColor { return UIColor.Dark.Background.primary } - override var background: UIColor { return UIColor.Photon.Grey80 } - override var tabTitleText: UIColor { return UIColor.Dark.Text.primary } -} - -class LegacyDarkTheme: LegacyNormalTheme { - override var name: String { return BuiltinThemeName.dark.rawValue } - override var tableView: TableViewColor { return DarkTableViewColor() } - override var browser: BrowserColor { return DarkBrowserColor() } - override var tabTray: TabTrayColor { return DarkTabTrayColor() } - override var snackbar: SnackBarColor { return SnackBarColor() } - // Ecosia: Adapt theme - override var ecosia: EcosiaTheme { DarkEcosiaTheme() } -} diff --git a/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/LegacyThemeManager.swift b/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/LegacyThemeManager.swift deleted file mode 100644 index 58594f03da9d..000000000000 --- a/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/LegacyThemeManager.swift +++ /dev/null @@ -1,117 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import UIKit - -enum LegacyThemeManagerPrefs: String { - case systemThemeIsOn = "prefKeySystemThemeSwitchOnOff" - case automaticSwitchIsOn = "prefKeyAutomaticSwitchOnOff" - case automaticSliderValue = "prefKeyAutomaticSliderValue" - case themeName = "prefKeyThemeName" -} - -class LegacyThemeManager { - static let instance = LegacyThemeManager() - - var current: LegacyTheme = themeFrom(name: UserDefaults.standard.string(forKey: LegacyThemeManagerPrefs.themeName.rawValue)) { - didSet { - ensureMainThread { - UserDefaults.standard.set(self.current.name, forKey: LegacyThemeManagerPrefs.themeName.rawValue) - } - } - } - - var currentName: BuiltinThemeName { - return BuiltinThemeName(rawValue: LegacyThemeManager.instance.current.name) ?? .normal - } - - var automaticBrightnessValue: Float = UserDefaults.standard.float(forKey: LegacyThemeManagerPrefs.automaticSliderValue.rawValue) { - didSet { - UserDefaults.standard.set(automaticBrightnessValue, forKey: LegacyThemeManagerPrefs.automaticSliderValue.rawValue) - } - } - - var automaticBrightnessIsOn: Bool = UserDefaults.standard.bool(forKey: LegacyThemeManagerPrefs.automaticSwitchIsOn.rawValue) { - didSet { - UserDefaults.standard.set(automaticBrightnessIsOn, forKey: LegacyThemeManagerPrefs.automaticSwitchIsOn.rawValue) - guard automaticBrightnessIsOn else { return } - updateCurrentThemeBasedOnScreenBrightness() - } - } - - var systemThemeIsOn: Bool { - didSet { - UserDefaults.standard.set(systemThemeIsOn, forKey: LegacyThemeManagerPrefs.systemThemeIsOn.rawValue) - } - } - - private init() { - UserDefaults.standard.register(defaults: [LegacyThemeManagerPrefs.systemThemeIsOn.rawValue: true]) - systemThemeIsOn = UserDefaults.standard.bool(forKey: LegacyThemeManagerPrefs.systemThemeIsOn.rawValue) - - NotificationCenter.default.addObserver(self, - selector: #selector(brightnessChanged), - name: UIScreen.brightnessDidChangeNotification, - object: nil) - NotificationCenter.default.addObserver(self, - selector: #selector(applicationDidBecomeActive), - name: UIApplication.didBecomeActiveNotification, - object: nil) - } - - // UIViewControllers / UINavigationControllers need to have `preferredStatusBarStyle` and call this. - var statusBarStyle: UIStatusBarStyle { - return .default - } - - var userInterfaceStyle: UIUserInterfaceStyle { - switch currentName { - case .dark: - return .dark - default: - return .light - } - } - - func updateCurrentThemeBasedOnScreenBrightness() { - let prefValue = UserDefaults.standard.float(forKey: LegacyThemeManagerPrefs.automaticSliderValue.rawValue) - - let screenLessThanPref = Float(UIScreen.main.brightness) < prefValue - - if screenLessThanPref, self.currentName == .normal { - self.current = LegacyDarkTheme() - } else if !screenLessThanPref, self.currentName == .dark { - self.current = LegacyNormalTheme() - } - } - - @objc - private func brightnessChanged() { - guard automaticBrightnessIsOn else { return } - updateCurrentThemeBasedOnScreenBrightness() - } - - @objc - private func applicationDidBecomeActive() { - let nightMode = UserDefaults.standard.bool(forKey: "profile.NightModeStatus") - if !nightMode && LegacyThemeManager.instance.systemThemeIsOn { - /* Ecosia: Update legacy theme to use the single source of truth - let userInterfaceStyle = UIScreen.main.traitCollection.userInterfaceStyle - LegacyThemeManager.instance.current = userInterfaceStyle == .dark ? LegacyDarkTheme() : LegacyNormalTheme() - */ - // TODO Ecosia Upgrade: Re-add if LegacyThemeManager is kept [MOB-3152] - // LegacyThemeManager.updateBasedOnCurrentSystemThemeType() - } - } -} - -private func themeFrom(name: String?) -> LegacyTheme { - guard let name = name, let theme = BuiltinThemeName(rawValue: name) else { return LegacyNormalTheme() } - switch theme { - case .dark: - return LegacyDarkTheme() - default: - return LegacyNormalTheme() - } -} diff --git a/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/RecoveredLegacyTheme.swift b/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/RecoveredLegacyTheme.swift deleted file mode 100644 index d41c1170691c..000000000000 --- a/firefox-ios/Client/Ecosia/RecoveredFromUpgrade/RecoveredLegacyTheme.swift +++ /dev/null @@ -1,70 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import Common -import UIKit -import Shared - -// TODO Ecosia Upgrade: Can we also get rid of this now that Firefox has? [MOB-3152] -extension UIColor { - static var legacyTheme: LegacyTheme { - return LegacyThemeManager.instance.current - } -} - -enum BuiltinThemeName: String { - case normal - case dark -} - -class TableViewColor { - var rowText: UIColor { return UIColor.Photon.Grey90 } // textPrimary - var disabledRowText: UIColor { return UIColor.Photon.Grey40 } // textDisabled - // Ecosia: Re enabling legacy colo references - var accessoryViewTint: UIColor { return .Light.Text.secondary } - var headerBackground: UIColor { .Light.Background.tertiary } - var separator: UIColor { .Light.border } - var rowBackground: UIColor { return .Light.Background.primary } -} - -class BrowserColor { - var background: UIColor { return UIColor.Photon.Grey10 } // layer1 -} - -class TabTrayColor { - var tabTitleBlur: UIBlurEffect.Style { return UIBlurEffect.Style.extraLight } - // Ecosia: Add legacy color references from 9.1.0 App Version - var cellBackground: UIColor { return UIColor.white } - var screenshotBackground: UIColor { return UIColor.white } - var background: UIColor { return UIColor.Photon.Grey10 } - var tabTitleText: UIColor { return UIColor.black } -} - -class SnackBarColor { - // TODO Ecosia Upgrade: UIColor.LegacyDefaults no longer exists, is it needed? [MOB-3152] -// var highlight: UIColor { return UIColor.LegacyDefaults.iOSTextHighlightBlue.withAlphaComponent(0.9) } - var highlightText: UIColor { return UIColor.Photon.Blue40 } - var border: UIColor { return UIColor.Photon.Grey30 } - var title: UIColor { return UIColor.Photon.Blue40 } -} - -protocol LegacyTheme { - var name: String { get } - var tableView: TableViewColor { get } - var browser: BrowserColor { get } - var tabTray: TabTrayColor { get } - var snackbar: SnackBarColor { get } - // Ecosia: Adapt theme - var ecosia: EcosiaTheme { get } -} - -class LegacyNormalTheme: LegacyTheme { - var name: String { return BuiltinThemeName.normal.rawValue } - var tableView: TableViewColor { return TableViewColor() } - var browser: BrowserColor { return BrowserColor() } - var tabTray: TabTrayColor { return TabTrayColor() } - var snackbar: SnackBarColor { return SnackBarColor() } - // Ecosia: Adapt theme - var ecosia: EcosiaTheme { return EcosiaTheme() } -} diff --git a/firefox-ios/Client/Ecosia/Settings/EcosiaDebugSettings.swift b/firefox-ios/Client/Ecosia/Settings/EcosiaDebugSettings.swift index 8efd4a0190a9..17a554338168 100644 --- a/firefox-ios/Client/Ecosia/Settings/EcosiaDebugSettings.swift +++ b/firefox-ios/Client/Ecosia/Settings/EcosiaDebugSettings.swift @@ -10,7 +10,7 @@ import Common final class PushBackInstallation: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Push back installation by 3 days (needs restart).", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Push back installation by 3 days (needs restart).", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -22,12 +22,12 @@ final class PushBackInstallation: HiddenSetting { final class ToggleImpactIntro: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Toggle - Show Impact intro", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Toggle - Show Impact intro", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var status: NSAttributedString? { let isOn = User.shared.shouldShowImpactIntro - return NSAttributedString(string: isOn ? "True" : "False", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: isOn ? "True" : "False", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -42,11 +42,17 @@ final class ToggleImpactIntro: HiddenSetting { final class ShowTour: HiddenSetting, WelcomeDelegate { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Show Intro", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Show Intro", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) + } + + let windowUUID: WindowUUID + init(settings: SettingsTableViewController, windowUUID: WindowUUID) { + self.windowUUID = windowUUID + super.init(settings: settings) } override func onClick(_ navigationController: UINavigationController?) { - let welcome = Welcome(delegate: self) + let welcome = Welcome(delegate: self, windowUUID: windowUUID) welcome.modalPresentationStyle = .fullScreen welcome.modalTransitionStyle = .coverVertical navigationController?.present(welcome, animated: true) @@ -59,7 +65,7 @@ final class ShowTour: HiddenSetting, WelcomeDelegate { final class CreateReferralCode: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Referral Code \(User.shared.referrals.code ?? "-")", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Referral Code \(User.shared.referrals.code ?? "-")", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var status: NSAttributedString? { @@ -95,7 +101,7 @@ final class CreateReferralCode: HiddenSetting { final class AddReferral: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Add Referral", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Add Referral", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -113,7 +119,7 @@ final class AddReferral: HiddenSetting { final class AddClaim: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Add Referral Claim", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Add Referral Claim", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -132,11 +138,11 @@ final class AddClaim: HiddenSetting { final class ResetSearchCount: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Set search count to 0", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Set search count to 0", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var status: NSAttributedString? { - return NSAttributedString(string: "\(User.shared.searchCount)", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "\(User.shared.searchCount)", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -148,11 +154,11 @@ final class ResetSearchCount: HiddenSetting { final class ChangeSearchCount: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Increase search count by 10", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Increase search count by 10", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var status: NSAttributedString? { - return NSAttributedString(string: "\(User.shared.searchCount)", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "\(User.shared.searchCount)", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -168,7 +174,7 @@ class UnleashVariantResetSetting: HiddenSetting { var unleashEnabled: Bool? { return nil } override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Unleash \(titleName ?? "Unknown") variant", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Unleash \(titleName ?? "Unknown") variant", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var status: NSAttributedString? { @@ -176,7 +182,7 @@ class UnleashVariantResetSetting: HiddenSetting { if statusName == "Unknown", let unleashEnabled = unleashEnabled { statusName = unleashEnabled ? "enabled" : "disabled" } - return NSAttributedString(string: "\(statusName) (Click to reset)", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "\(statusName) (Click to reset)", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -220,13 +226,13 @@ final class UnleashAPNConsent: UnleashVariantResetSetting { final class AnalyticsIdentifierSetting: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Analytics Identifier", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Analytics Identifier", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } var analyticsIdentifier: String { User.shared.analyticsId.uuidString } override var status: NSAttributedString? { - let attributes = [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + let attributes = [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] return NSAttributedString(string: "\(analyticsIdentifier) (Click to copy)", attributes: attributes) } @@ -247,11 +253,11 @@ final class UnleashNewsletterCardSetting: UnleashVariantResetSetting { final class NewsletterCardDismissSetting: HiddenSetting { override var title: NSAttributedString? { - return NSAttributedString(string: "Debug: Unset Newsletter card dismissed", attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: "Debug: Unset Newsletter card dismissed", attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var status: NSAttributedString? { - let attributes = [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + let attributes = [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] let hintText = NewsletterCardExperiment.isDismissed ? "dismissed (Click to unset)" : "showing (Nothing to do here)" return NSAttributedString(string: "Card is currently \(hintText)", attributes: attributes) } diff --git a/firefox-ios/Client/Ecosia/Settings/EcosiaSettings.swift b/firefox-ios/Client/Ecosia/Settings/EcosiaSettings.swift index 3f1ad03bbb99..f1ab96093661 100644 --- a/firefox-ios/Client/Ecosia/Settings/EcosiaSettings.swift +++ b/firefox-ios/Client/Ecosia/Settings/EcosiaSettings.swift @@ -7,17 +7,21 @@ import Core import Shared import Common -var ecosiaDisclosureIndicator: UIImageView { +func ecosiaDisclosureIndicator(theme: Theme) -> UIImageView { let config = UIImage.SymbolConfiguration(pointSize: 16) let disclosureIndicator = UIImageView(image: .init(systemName: "chevron.right", withConfiguration: config)) disclosureIndicator.contentMode = .center - disclosureIndicator.tintColor = UIColor.legacyTheme.tableView.accessoryViewTint + disclosureIndicator.tintColor = theme.colors.ecosia.textSecondary disclosureIndicator.sizeToFit() return disclosureIndicator } final class SearchAreaSetting: Setting { - override var accessoryView: UIImageView? { return ecosiaDisclosureIndicator } + override var title: NSAttributedString? { + NSAttributedString(string: .localized(.searchRegion), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) + } + + override var accessoryView: UIImageView? { return ecosiaDisclosureIndicator(theme: theme) } override var style: UITableViewCell.CellStyle { return .value1 } @@ -28,7 +32,7 @@ final class SearchAreaSetting: Setting { let windowUUID: UUID init(settings: SettingsTableViewController) { self.windowUUID = settings.windowUUID - super.init(title: NSAttributedString(string: .localized(.searchRegion), attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText])) + super.init() } override func onClick(_ navigationController: UINavigationController?) { @@ -46,7 +50,11 @@ final class SearchAreaSetting: Setting { } final class SafeSearchSettings: Setting { - override var accessoryView: UIImageView? { return ecosiaDisclosureIndicator } + override var title: NSAttributedString? { + NSAttributedString(string: .localized(.safeSearch), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) + } + + override var accessoryView: UIImageView? { return ecosiaDisclosureIndicator(theme: theme) } override var style: UITableViewCell.CellStyle { return .value1 } @@ -57,7 +65,7 @@ final class SafeSearchSettings: Setting { let windowUUID: UUID init(settings: SettingsTableViewController) { self.windowUUID = settings.windowUUID - super.init(title: NSAttributedString(string: .localized(.safeSearch), attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText])) + super.init() } override func onClick(_ navigationController: UINavigationController?) { @@ -117,7 +125,7 @@ final class PersonalSearchSettings: BoolSetting { final class EcosiaPrivacyPolicySetting: Setting { override var title: NSAttributedString? { - return NSAttributedString(string: .localized(.privacy), attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: .localized(.privacy), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var url: URL? { @@ -159,7 +167,7 @@ final class EcosiaSendFeedbackSetting: Setting { } override var title: NSAttributedString? { - return NSAttributedString(string: .localized(.sendFeedback), attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: .localized(.sendFeedback), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override func onClick(_ navigationController: UINavigationController?) { @@ -172,7 +180,7 @@ final class EcosiaSendFeedbackSetting: Setting { final class EcosiaTermsSetting: Setting { override var title: NSAttributedString? { - return NSAttributedString(string: .localized(.terms), attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText]) + return NSAttributedString(string: .localized(.terms), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText]) } override var url: URL? { @@ -217,7 +225,7 @@ final class EcosiaSendAnonymousUsageDataSetting: BoolSetting { final class HomepageSettings: Setting { private var profile: Profile - override var accessoryView: UIImageView? { ecosiaDisclosureIndicator } + override var accessoryView: UIImageView? { ecosiaDisclosureIndicator(theme: theme) } let windowUUID: WindowUUID init(settings: SettingsTableViewController, settingsDelegate: SettingsDelegate?) { diff --git a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogo.imageset/Contents.json b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogo.imageset/Contents.json index 840d52940ed3..361954bcee44 100644 --- a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogo.imageset/Contents.json +++ b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogo.imageset/Contents.json @@ -3,6 +3,16 @@ { "filename" : "Logo.pdf", "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "Logo 1.pdf", + "idiom" : "universal" } ], "info" : { diff --git a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogoDark.imageset/Logo.pdf b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogo.imageset/Logo 1.pdf similarity index 100% rename from firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogoDark.imageset/Logo.pdf rename to firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogo.imageset/Logo 1.pdf diff --git a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogoDark.imageset/Contents.json b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogoDark.imageset/Contents.json deleted file mode 100644 index 840d52940ed3..000000000000 --- a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/searchLogoDark.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "Logo.pdf", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "preserves-vector-representation" : true - } -} diff --git a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpact.imageset/Contents.json b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpact.imageset/Contents.json index db5695e4f0ca..380446377d31 100644 --- a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpact.imageset/Contents.json +++ b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpact.imageset/Contents.json @@ -3,6 +3,16 @@ { "filename" : "yourImpact.pdf", "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "filename" : "yourImpactDark.pdf", + "idiom" : "universal" } ], "info" : { diff --git a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpactDark.imageset/yourImpactDark.pdf b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpact.imageset/yourImpactDark.pdf similarity index 100% rename from firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpactDark.imageset/yourImpactDark.pdf rename to firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpact.imageset/yourImpactDark.pdf diff --git a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpactDark.imageset/Contents.json b/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpactDark.imageset/Contents.json deleted file mode 100644 index 2d7c1b460b5e..000000000000 --- a/firefox-ios/Client/Ecosia/UI/Ecosia.xcassets/yourImpactDark.imageset/Contents.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "images" : [ - { - "filename" : "yourImpactDark.pdf", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "preserves-vector-representation" : true, - "template-rendering-intent" : "original" - } -} diff --git a/firefox-ios/Client/Ecosia/UI/EcosiaFindInPageBar.swift b/firefox-ios/Client/Ecosia/UI/EcosiaFindInPageBar.swift index 0106cdfa3ad7..a2fbacd75308 100644 --- a/firefox-ios/Client/Ecosia/UI/EcosiaFindInPageBar.swift +++ b/firefox-ios/Client/Ecosia/UI/EcosiaFindInPageBar.swift @@ -16,7 +16,7 @@ protocol EcosiaFindInPageBarDelegate: AnyObject { /// Ecosia's custom UI for FindInPageBar. /// /// You can find the Firefox original view in Client/Frontend/Browser/FindInPageBar (removed from Target since no longer used) -final class EcosiaFindInPageBar: UIView, Themeable { +final class EcosiaFindInPageBar: UIView, ThemeApplicable { private struct UX { static let barHeight: CGFloat = 60 static let searchViewTopBottomSpacing: CGFloat = 8 @@ -120,12 +120,6 @@ final class EcosiaFindInPageBar: UIView, Themeable { } } - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { @@ -139,10 +133,7 @@ final class EcosiaFindInPageBar: UIView, Themeable { addSubview(closeButton) addSubview(topBorder) - applyTheme() setupConstraints() - - listenForThemeChange(self) } required init?(coder aDecoder: NSCoder) { @@ -158,17 +149,17 @@ final class EcosiaFindInPageBar: UIView, Themeable { return super.becomeFirstResponder() } - @objc func applyTheme() { - backgroundColor = .legacyTheme.ecosia.secondaryBackground - searchView.backgroundColor = .legacyTheme.ecosia.tertiaryBackground - searchTextField.textColor = .legacyTheme.ecosia.primaryText + func applyTheme(theme: Theme) { + backgroundColor = theme.colors.ecosia.backgroundSecondary + searchView.backgroundColor = theme.colors.ecosia.backgroundTertiary + searchTextField.textColor = theme.colors.ecosia.textPrimary searchTextField.attributedPlaceholder = .init(string: .localized(.findInPage), - attributes: [.foregroundColor: UIColor.legacyTheme.ecosia.secondaryText]) - matchCountLabel.textColor = .legacyTheme.ecosia.secondaryText - previousButton.tintColor = .legacyTheme.ecosia.primaryIcon - nextButton.tintColor = .legacyTheme.ecosia.primaryIcon - closeButton.setTitleColor(.legacyTheme.ecosia.primaryButton, for: .normal) - topBorder.backgroundColor = .legacyTheme.ecosia.border + attributes: [.foregroundColor: theme.colors.ecosia.textSecondary]) + matchCountLabel.textColor = theme.colors.ecosia.textSecondary + previousButton.tintColor = theme.colors.ecosia.iconPrimary + nextButton.tintColor = theme.colors.ecosia.iconPrimary + closeButton.setTitleColor(theme.colors.ecosia.buttonBackgroundPrimary, for: .normal) + topBorder.backgroundColor = theme.colors.ecosia.borderDecorative } private func setupConstraints() { diff --git a/firefox-ios/Client/Ecosia/UI/EcosiaPrimaryButton.swift b/firefox-ios/Client/Ecosia/UI/EcosiaPrimaryButton.swift new file mode 100644 index 000000000000..6aabefbdcc1e --- /dev/null +++ b/firefox-ios/Client/Ecosia/UI/EcosiaPrimaryButton.swift @@ -0,0 +1,41 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import UIKit +import Common + +class EcosiaPrimaryButton: UIButton { + let windowUUID: WindowUUID + init(windowUUID: WindowUUID) { + self.windowUUID = windowUUID + super.init(type: .custom) + } + required init?(coder: NSCoder) { nil } + + override var isSelected: Bool { + get { + return super.isSelected + } + set { + super.isSelected = newValue + update() + } + } + + override var isHighlighted: Bool { + get { + return super.isHighlighted + } + set { + super.isHighlighted = newValue + update() + } + } + + private func update() { + let themeManager: ThemeManager = AppContainer.shared.resolve() + let theme = themeManager.getCurrentTheme(for: windowUUID) + backgroundColor = (isSelected || isHighlighted) ? theme.colors.ecosia.buttonBackgroundPrimaryActive : theme.colors.ecosia.buttonBackgroundPrimary + } +} diff --git a/firefox-ios/Client/Ecosia/UI/EmptyBookmarksView.swift b/firefox-ios/Client/Ecosia/UI/EmptyBookmarksView.swift index ff9ba0cfcf32..75e00377ed60 100644 --- a/firefox-ios/Client/Ecosia/UI/EmptyBookmarksView.swift +++ b/firefox-ios/Client/Ecosia/UI/EmptyBookmarksView.swift @@ -5,7 +5,7 @@ import UIKit import Common -final class EmptyBookmarksView: UIView, Themeable { +final class EmptyBookmarksView: UIView, ThemeApplicable { private enum UX { static let TitleLabelFont = UIFontMetrics(forTextStyle: .body).scaledFont(for: .systemFont(ofSize: 17, weight: .semibold)) @@ -69,12 +69,6 @@ final class EmptyBookmarksView: UIView, Themeable { var bottomMarginConstraint: NSLayoutConstraint? - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init required init?(coder: NSCoder) { @@ -143,10 +137,6 @@ final class EmptyBookmarksView: UIView, Themeable { // setup buttons learnMoreButton.addTarget(self, action: #selector(onLearnMoreTapped), for: .touchUpInside) importBookmarksButton.addTarget(self, action: #selector(onImportTapped), for: .touchUpInside) - - applyTheme() - - listenForThemeChange(self) } private func addSection(imageNamed: String, text: String, listItems: [String]? = nil) { @@ -248,18 +238,18 @@ final class EmptyBookmarksView: UIView, Themeable { delegate?.emptyBookmarksViewImportBookmarksTapped(self) } - @objc func applyTheme() { - backgroundColor = .legacyTheme.ecosia.homePanelBackground - importBookmarksButton.layer.borderColor = UIColor.legacyTheme.ecosia.primaryText.cgColor - learnMoreButton.setTitleColor(.legacyTheme.ecosia.primaryText, for: .normal) + func applyTheme(theme: Theme) { + backgroundColor = theme.colors.ecosia.modalBackground + importBookmarksButton.layer.borderColor = theme.colors.ecosia.textPrimary.cgColor + learnMoreButton.setTitleColor(theme.colors.ecosia.textPrimary, for: .normal) learnMoreButton.titleLabel?.font = UX.LearnMoreButtonLabelFont - importBookmarksButton.setTitleColor(.legacyTheme.ecosia.primaryText, for: .normal) + importBookmarksButton.setTitleColor(theme.colors.ecosia.textPrimary, for: .normal) importBookmarksButton.titleLabel?.font = UX.ImportButtonLabelFont - titleLabel.textColor = .legacyTheme.ecosia.primaryText - applyThemeToSectionsIn(containerStackView) + titleLabel.textColor = theme.colors.ecosia.textPrimary + applyThemeToSectionsIn(containerStackView, theme: theme) } - func applyThemeToSectionsIn(_ stackView: UIStackView) { + func applyThemeToSectionsIn(_ stackView: UIStackView, theme: Theme) { var finalResult = [UIView]() var iterateThroughSubviews: ((UIStackView) -> Void)? @@ -282,9 +272,9 @@ final class EmptyBookmarksView: UIView, Themeable { finalResult.forEach { switch $0 { case let label as UILabel: - label.textColor = .legacyTheme.ecosia.secondaryText + label.textColor = theme.colors.ecosia.textSecondary default: - $0.tintColor = .legacyTheme.ecosia.secondaryText + $0.tintColor = theme.colors.ecosia.textSecondary break } } diff --git a/firefox-ios/Client/Ecosia/UI/EmptyHeader.swift b/firefox-ios/Client/Ecosia/UI/EmptyHeader.swift index 88a892815030..135b74e78353 100644 --- a/firefox-ios/Client/Ecosia/UI/EmptyHeader.swift +++ b/firefox-ios/Client/Ecosia/UI/EmptyHeader.swift @@ -5,18 +5,12 @@ import UIKit import Common -final class EmptyHeader: UITableViewHeaderFooterView, Themeable { +final class EmptyHeader: UITableViewHeaderFooterView, ThemeApplicable { private let icon: String private weak var labelTitle: UILabel? private weak var labelSubtitle: UILabel? private weak var image: UIImageView? - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init required init?(coder: NSCoder) { nil } @@ -67,12 +61,12 @@ final class EmptyHeader: UITableViewHeaderFooterView, Themeable { labelSubtitle.widthAnchor.constraint(lessThanOrEqualToConstant: 180).isActive = true } - // MARK: - Themeable + // MARK: - ThemeApplicable - func applyTheme() { + func applyTheme(theme: Theme) { image?.image = .init(named: icon)?.withRenderingMode(.alwaysTemplate) - image?.tintColor = UIColor.legacyTheme.ecosia.secondaryText - labelTitle?.textColor = .legacyTheme.ecosia.primaryText - labelSubtitle?.textColor = .legacyTheme.ecosia.secondaryText + image?.tintColor = theme.colors.ecosia.textSecondary + labelTitle?.textColor = theme.colors.ecosia.textPrimary + labelSubtitle?.textColor = theme.colors.ecosia.textSecondary } } diff --git a/firefox-ios/Client/Ecosia/UI/FilterController.swift b/firefox-ios/Client/Ecosia/UI/FilterController.swift index f876836eeafc..8d4801f27051 100644 --- a/firefox-ios/Client/Ecosia/UI/FilterController.swift +++ b/firefox-ios/Client/Ecosia/UI/FilterController.swift @@ -11,6 +11,7 @@ private let items: [(AdultFilter, String)] = [ (.moderate, .localized(.moderate)), (.off, .localized(.off))] +// TODO: Can we use ThemedTableViewController? final class FilterController: UIViewController, UITableViewDataSource, UITableViewDelegate, Themeable { private weak var table: UITableView! @@ -19,21 +20,19 @@ final class FilterController: UIViewController, UITableViewDataSource, UITableVi items.first(where: { $0.0 == User.shared.adultFilter }).map { $0.1 } } - init(windowUUID: WindowUUID) { + required init?(coder: NSCoder) { nil } + init(windowUUID: WindowUUID, + themeManager: ThemeManager = AppContainer.shared.resolve()) { self.windowUUID = windowUUID + self.themeManager = themeManager super.init() } - required init?(coder: NSCoder) { - self.windowUUID = nil - super.init(coder: coder) - } - // MARK: - Themeable Properties let windowUUID: WindowUUID? var currentWindowUUID: Common.WindowUUID? { return windowUUID } - var themeManager: ThemeManager { AppContainer.shared.resolve() } + var themeManager: ThemeManager var themeObserver: NSObjectProtocol? var notificationCenter: NotificationProtocol = NotificationCenter.default @@ -79,13 +78,15 @@ final class FilterController: UIViewController, UITableViewDataSource, UITableVi } func applyTheme() { + let theme = themeManager.getCurrentTheme(for: windowUUID) table.visibleCells.forEach { ($0 as? Themeable)?.applyTheme() + ($0 as? ThemeApplicable)?.applyTheme(theme: theme) } - view.backgroundColor = UIColor.legacyTheme.tableView.headerBackground - table.tintColor = UIColor.legacyTheme.ecosia.primaryBrand - table.separatorColor = UIColor.legacyTheme.tableView.separator - table.backgroundColor = UIColor.legacyTheme.tableView.headerBackground + view.backgroundColor = theme.colors.ecosia.ntpBackground + table.tintColor = theme.colors.ecosia.brandPrimary + table.separatorColor = theme.colors.ecosia.borderDecorative + table.backgroundColor = theme.colors.ecosia.ntpBackground } } diff --git a/firefox-ios/Client/Ecosia/UI/LoadingScreen.swift b/firefox-ios/Client/Ecosia/UI/LoadingScreen.swift index 63f5d4a8d8aa..657409c8cf29 100644 --- a/firefox-ios/Client/Ecosia/UI/LoadingScreen.swift +++ b/firefox-ios/Client/Ecosia/UI/LoadingScreen.swift @@ -4,6 +4,7 @@ import UIKit import Core +import Common final class LoadingScreen: UIViewController { private weak var profile: Profile! @@ -11,12 +12,20 @@ final class LoadingScreen: UIViewController { private weak var referrals: Referrals! private var referralCode: String? + var themeManager: ThemeManager + let windowUUID: WindowUUID let loadingGroup = DispatchGroup() required init?(coder: NSCoder) { nil } - init(profile: Profile, referrals: Referrals, referralCode: String? = nil) { + init(profile: Profile, + referrals: Referrals, + windowUUID: WindowUUID, + themeManager: ThemeManager = AppContainer.shared.resolve(), + referralCode: String? = nil) { self.profile = profile self.referrals = referrals + self.windowUUID = windowUUID + self.themeManager = themeManager self.referralCode = referralCode super.init(nibName: nil, bundle: nil) modalPresentationStyle = .fullScreen @@ -25,7 +34,8 @@ final class LoadingScreen: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor.legacyTheme.ecosia.primaryBackground + let theme = themeManager.getCurrentTheme(for: windowUUID) + view.backgroundColor = theme.colors.ecosia.backgroundPrimary let logo = UIImageView(image: UIImage(named: "ecosiaLogoLaunch")) logo.translatesAutoresizingMaskIntoConstraints = false @@ -35,7 +45,7 @@ final class LoadingScreen: UIViewController { let progress = UIProgressView() progress.translatesAutoresizingMaskIntoConstraints = false - progress.progressTintColor = UIColor.legacyTheme.ecosia.primaryBrand + progress.progressTintColor = theme.colors.ecosia.brandPrimary view.addSubview(progress) self.progress = progress @@ -45,7 +55,7 @@ final class LoadingScreen: UIViewController { message.font = .preferredFont(forTextStyle: .footnote) message.numberOfLines = 0 message.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) - message.textColor = UIColor.legacyTheme.ecosia.primaryText + message.textColor = theme.colors.ecosia.textPrimary message.textAlignment = .center view.addSubview(message) diff --git a/firefox-ios/Client/Ecosia/UI/MarketsController.swift b/firefox-ios/Client/Ecosia/UI/MarketsController.swift index cf1f2bb1eb1b..8039cc46f857 100644 --- a/firefox-ios/Client/Ecosia/UI/MarketsController.swift +++ b/firefox-ios/Client/Ecosia/UI/MarketsController.swift @@ -74,7 +74,8 @@ final class MarketsController: ThemedTableViewController { override func applyTheme() { super.applyTheme() - tableView.tintColor = UIColor.legacyTheme.ecosia.primaryBrand - view.backgroundColor = UIColor.legacyTheme.tableView.headerBackground + let theme = themeManager.getCurrentTheme(for: windowUUID) + tableView.tintColor = theme.colors.ecosia.brandPrimary + view.backgroundColor = theme.colors.ecosia.ntpBackground } } diff --git a/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpact.swift b/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpact.swift index 8ac0a29359d2..bc2678215d38 100644 --- a/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpact.swift +++ b/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpact.swift @@ -104,16 +104,19 @@ class MultiplyImpact: UIViewController, Themeable { let windowUUID: WindowUUID var currentWindowUUID: WindowUUID? { windowUUID } - var themeManager: ThemeManager { AppContainer.shared.resolve() } + var themeManager: ThemeManager var themeObserver: NSObjectProtocol? var notificationCenter: NotificationProtocol = NotificationCenter.default // MARK: - Init required init?(coder: NSCoder) { nil } - init(referrals: Referrals, windowUUID: WindowUUID) { + init(referrals: Referrals, + windowUUID: WindowUUID, + themeManager: ThemeManager = AppContainer.shared.resolve()) { self.referrals = referrals self.windowUUID = windowUUID + self.themeManager = themeManager super.init(nibName: nil, bundle: nil) } @@ -135,7 +138,6 @@ class MultiplyImpact: UIViewController, Themeable { let topBackground = UIView() topBackground.translatesAutoresizingMaskIntoConstraints = false - topBackground.backgroundColor = .legacyTheme.ecosia.primaryBrand.withAlphaComponent(0.2) content.addSubview(topBackground) self.topBackground = topBackground @@ -221,7 +223,7 @@ class MultiplyImpact: UIViewController, Themeable { sharing.addSubview(moreSharingMethods) self.moreSharingMethods = moreSharingMethods - let inviteFriends = EcosiaPrimaryButton(type: .custom) + let inviteFriends = EcosiaPrimaryButton(windowUUID: windowUUID) inviteFriends.setTitle(.localized(.inviteFriends), for: []) inviteFriends.titleLabel!.font = .preferredFont(forTextStyle: .callout) inviteFriends.titleLabel!.adjustsFontForContentSizeCategory = true @@ -420,55 +422,57 @@ class MultiplyImpact: UIViewController, Themeable { } func applyTheme() { - view.backgroundColor = .legacyTheme.ecosia.modalBackground - inviteButton.backgroundColor = .legacyTheme.ecosia.primaryBrand - inviteButton.setTitleColor(.legacyTheme.ecosia.primaryTextInverted, for: .normal) - inviteButton.setTitleColor(.legacyTheme.ecosia.primaryTextInverted, for: .highlighted) - inviteButton.setTitleColor(.legacyTheme.ecosia.primaryTextInverted, for: .selected) - learnMoreButton?.setTitleColor(.legacyTheme.ecosia.primaryBrand, for: .normal) - waves?.tintColor = .legacyTheme.ecosia.modalBackground - topBackground?.backgroundColor = .legacyTheme.ecosia.modalHeader - forestOverlay?.backgroundColor = .legacyTheme.ecosia.modalBackground + let theme = themeManager.getCurrentTheme(for: windowUUID) + + view.backgroundColor = theme.colors.ecosia.modalBackground + topBackground?.backgroundColor = theme.colors.ecosia.brandPrimary.withAlphaComponent(0.2) + inviteButton.backgroundColor = theme.colors.ecosia.brandPrimary + inviteButton.setTitleColor(theme.colors.ecosia.textInversePrimary, for: .normal) + inviteButton.setTitleColor(theme.colors.ecosia.textInversePrimary, for: .highlighted) + inviteButton.setTitleColor(theme.colors.ecosia.textInversePrimary, for: .selected) + learnMoreButton?.setTitleColor(theme.colors.ecosia.brandPrimary, for: .normal) + waves?.tintColor = theme.colors.ecosia.modalBackground + topBackground?.backgroundColor = theme.colors.ecosia.modalBackground + forestOverlay?.backgroundColor = theme.colors.ecosia.modalBackground subtitle?.textColor = .Dark.Text.primary - copyControl?.backgroundColor = .legacyTheme.ecosia.secondaryBackground - copyControl?.layer.borderColor = UIColor.legacyTheme.ecosia.border.cgColor - moreSharingMethods?.textColor = .legacyTheme.ecosia.secondaryText - copyText?.textColor = .legacyTheme.ecosia.primaryBrand + copyControl?.backgroundColor = theme.colors.ecosia.backgroundSecondary + copyControl?.layer.borderColor = theme.colors.ecosia.borderDecorative.cgColor + moreSharingMethods?.textColor = theme.colors.ecosia.textSecondary + copyText?.textColor = theme.colors.ecosia.brandPrimary [yourInvites, sharingYourLink, flowTitle, copyLink].forEach { - $0?.textColor = .legacyTheme.ecosia.primaryText + $0?.textColor = theme.colors.ecosia.textPrimary } [sharing, flowBackground].forEach { - $0?.backgroundColor = .legacyTheme.ecosia.impactMultiplyCardBackground + $0?.backgroundColor = theme.colors.ecosia.impactMultiplyCardBackground } [firstStep, secondStep, thirdStep, fourthStep].forEach { - $0?.applyTheme() + $0?.applyTheme(theme: theme) } [copyDividerLeft, copyDividerRight].forEach { - $0?.backgroundColor = .legacyTheme.ecosia.border + $0?.backgroundColor = theme.colors.ecosia.borderDecorative } - referralImpactRowView.customBackgroundColor = .legacyTheme.ecosia.impactMultiplyCardBackground - referralImpactRowView.applyTheme() + referralImpactRowView.customBackgroundColor = theme.colors.ecosia.impactMultiplyCardBackground + referralImpactRowView.applyTheme(theme: theme) - updateBarAppearance() + updateBarAppearance(theme: theme) } - private func updateBarAppearance() { + private func updateBarAppearance(theme: Theme) { let appearance = UINavigationBarAppearance() appearance.configureWithOpaqueBackground() appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.Dark.Text.primary] appearance.titleTextAttributes = [.foregroundColor: UIColor.Dark.Text.primary] - appearance.backgroundColor = .legacyTheme.ecosia.modalHeader + appearance.backgroundColor = theme.colors.ecosia.modalBackground appearance.shadowColor = nil navigationItem.standardAppearance = appearance navigationItem.scrollEdgeAppearance = appearance - navigationController?.navigationBar.backgroundColor = .legacyTheme.ecosia.modalHeader - navigationController?.navigationBar.tintColor = themeManager - .getCurrentTheme(for: currentWindowUUID).type == .light ? UIColor.Dark.Text.primary : .legacyTheme.ecosia.primaryBrand + navigationController?.navigationBar.backgroundColor = theme.colors.ecosia.modalBackground + navigationController?.navigationBar.tintColor = theme.type == .light ? UIColor.Dark.Text.primary : theme.colors.ecosia.brandPrimary } private func updateInviteLink() { diff --git a/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpactStep.swift b/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpactStep.swift index e42fd635267f..d5c954d5a5f7 100644 --- a/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpactStep.swift +++ b/firefox-ios/Client/Ecosia/UI/MultiplyImpact/MultiplyImpactStep.swift @@ -5,17 +5,11 @@ import UIKit import Common -final class MultiplyImpactStep: UIView, Themeable { +final class MultiplyImpactStep: UIView, ThemeApplicable { private weak var indicator: UIImageView? private weak var titleLabel: UILabel? private weak var subtitleLabel: UILabel? - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init required init?(coder: NSCoder) { nil } @@ -67,9 +61,9 @@ final class MultiplyImpactStep: UIView, Themeable { subtitleLabel.rightAnchor.constraint(lessThanOrEqualTo: rightAnchor, constant: -12).isActive = true } - func applyTheme() { - indicator?.tintColor = .legacyTheme.ecosia.primaryBrand - titleLabel?.textColor = .legacyTheme.ecosia.primaryText - subtitleLabel?.textColor = .legacyTheme.ecosia.secondaryText + func applyTheme(theme: Theme) { + indicator?.tintColor = theme.colors.ecosia.brandPrimary + titleLabel?.textColor = theme.colors.ecosia.textPrimary + subtitleLabel?.textColor = theme.colors.ecosia.textSecondary } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCell.swift index f0bfb32996ec..cccbc22e13ea 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCell.swift @@ -92,29 +92,16 @@ final class NTPAboutEcosiaCell: UICollectionViewCell, ReusableCell { disclosureView.frame.maxY + (isLastSection ? 16 : 0) } - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { super.init(frame: frame) setup() - applyTheme() } required init?(coder: NSCoder) { super.init(coder: coder) setup() - applyTheme() - } - - override func prepareForReuse() { - super.prepareForReuse() - applyTheme() } override func layoutSubviews() { @@ -186,7 +173,6 @@ final class NTPAboutEcosiaCell: UICollectionViewCell, ReusableCell { dividerView.bottomAnchor.constraint(equalTo: outlineView.bottomAnchor), dividerView.heightAnchor.constraint(equalToConstant: 1) ]) - listenForThemeChange(contentView) } func rotateIndicator(isExpanded: Bool) { @@ -232,16 +218,16 @@ final class NTPAboutEcosiaCell: UICollectionViewCell, ReusableCell { } } -extension NTPAboutEcosiaCell: Themeable { - - func applyTheme() { - outlineView.backgroundColor = .legacyTheme.ecosia.ntpCellBackground - titleLabel.textColor = .legacyTheme.ecosia.primaryText - indicatorImageView.tintColor = .legacyTheme.ecosia.secondaryText - dividerView.backgroundColor = .legacyTheme.ecosia.border - disclosureView.backgroundColor = .legacyTheme.ecosia.quarternaryBackground - subtitleLabel.textColor = .legacyTheme.ecosia.primaryTextInverted - learnMoreButton.layer.borderColor = UIColor.legacyTheme.ecosia.primaryTextInverted.cgColor - learnMoreLabel.textColor = .legacyTheme.ecosia.primaryTextInverted +extension NTPAboutEcosiaCell: ThemeApplicable { + + func applyTheme(theme: Theme) { + outlineView.backgroundColor = theme.colors.ecosia.ntpCellBackground + titleLabel.textColor = theme.colors.ecosia.textPrimary + indicatorImageView.tintColor = theme.colors.ecosia.textSecondary + dividerView.backgroundColor = theme.colors.ecosia.borderDecorative + disclosureView.backgroundColor = theme.colors.ecosia.backgroundQuaternary + subtitleLabel.textColor = theme.colors.ecosia.textInversePrimary + learnMoreButton.layer.borderColor = theme.colors.ecosia.textInversePrimary.cgColor + learnMoreLabel.textColor = theme.colors.ecosia.textInversePrimary } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCellViewModel.swift b/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCellViewModel.swift index b2a93ce4ba46..16d76e85002f 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCellViewModel.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/AboutEcosia/NTPAboutEcosiaCellViewModel.swift @@ -78,6 +78,7 @@ extension NTPAboutEcosiaCellViewModel: HomepageSectionHandler { return UICollectionViewCell() } cell.configure(section: sections[indexPath.row], viewModel: self) + cell.applyTheme(theme: theme) return cell } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/CircleButton.swift b/firefox-ios/Client/Ecosia/UI/NTP/CircleButton.swift index d702172bd1b6..38a6abd4d674 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/CircleButton.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/CircleButton.swift @@ -75,9 +75,9 @@ class CircleButton: ToolbarButton { } override func applyTheme(theme: Theme) { - circle.backgroundColor = .legacyTheme.ecosia.tertiaryBackground - tintColor = config.shouldHideCircle ? .legacyTheme.ecosia.primaryText : .legacyTheme.ecosia.primaryButton - selectedTintColor = .legacyTheme.ecosia.primaryButtonActive + circle.backgroundColor = theme.colors.ecosia.backgroundTertiary + tintColor = config.shouldHideCircle ? theme.colors.ecosia.textPrimary : theme.colors.ecosia.buttonBackgroundPrimary + selectedTintColor = theme.colors.ecosia.buttonBackgroundPrimaryActive unselectedTintColor = tintColor } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterCell.swift index 07214dfdd0b4..04018e9fffbe 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterCell.swift @@ -11,7 +11,7 @@ protocol NTPSeedCounterDelegate: NSObjectProtocol { func didTapSeedCounter() } -final class NTPSeedCounterCell: UICollectionViewCell, Themeable, ReusableCell { +final class NTPSeedCounterCell: UICollectionViewCell, ThemeApplicable, ReusableCell { // MARK: - UX Constants private enum UX { @@ -37,11 +37,6 @@ final class NTPSeedCounterCell: UICollectionViewCell, Themeable, ReusableCell { private var button = UIButton() private var twinkleHostingController: UIHostingController? - // MARK: - Themeable Properties - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { @@ -67,8 +62,6 @@ final class NTPSeedCounterCell: UICollectionViewCell, Themeable, ReusableCell { setupSeedCounterViewHostingController() setupTwinkleViewHostingController() setupTransparentButton() - applyTheme() - listenForThemeChange(contentView) } private func setupTransparentButton() { @@ -132,7 +125,7 @@ final class NTPSeedCounterCell: UICollectionViewCell, Themeable, ReusableCell { private func addNewSeedCollectedCircleView() { let duration = UX.newSeedCircleAnimationDuration - let newSeedView = NewSeedCollectedCircleView(seedsCollected: 1) + let newSeedView = NewSeedCollectedCircleView(windowUUID: currentWindowUUID, seedsCollected: 1) .frame(width: UX.newSeedCircleSize, height: UX.newSeedCircleSize) .modifier(AppearFromBottomEffectModifier(reduceMotionEnabled: UIAccessibility.isReduceMotionEnabled, duration: duration, @@ -203,7 +196,7 @@ final class NTPSeedCounterCell: UICollectionViewCell, Themeable, ReusableCell { } // MARK: - Theming - @objc func applyTheme() { - containerStackView.backgroundColor = .legacyTheme.ecosia.secondaryBackground + func applyTheme(theme: Theme) { + containerStackView.backgroundColor = theme.colors.ecosia.backgroundSecondary } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterViewModel.swift b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterViewModel.swift index 90b0b0beba85..23bda6aaa68e 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterViewModel.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/NTPSeedCounterViewModel.swift @@ -75,6 +75,7 @@ extension NTPSeedCounterViewModel: HomepageSectionHandler { func configure(_ cell: UICollectionViewCell, at indexPath: IndexPath) -> UICollectionViewCell { guard let seedCounterCell = cell as? NTPSeedCounterCell else { return UICollectionViewCell() } seedCounterCell.delegate = delegate + seedCounterCell.applyTheme(theme: theme) return seedCounterCell } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterHiddenSettings.swift b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterHiddenSettings.swift index f3a27d356c6f..bfcb14c55cca 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterHiddenSettings.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterHiddenSettings.swift @@ -21,7 +21,7 @@ final class AddOneSeedSetting: HiddenSetting { override var title: NSAttributedString? { return NSAttributedString( string: "Debug: Add One Seed", - attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] ) } @@ -31,7 +31,7 @@ final class AddOneSeedSetting: HiddenSetting { let level = progressManagerType.loadCurrentLevel() return NSAttributedString( string: "Seeds: \(seedsCollected) | Level: \(level)", - attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] ) } @@ -59,7 +59,7 @@ final class AddFiveSeedsSetting: HiddenSetting { override var title: NSAttributedString? { return NSAttributedString( string: "Debug: Add Five Seeds", - attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] ) } @@ -69,7 +69,7 @@ final class AddFiveSeedsSetting: HiddenSetting { let level = progressManagerType.loadCurrentLevel() return NSAttributedString( string: "Seeds: \(seedsCollected) | Level: \(level)", - attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] ) } @@ -97,7 +97,7 @@ final class ResetSeedCounterSetting: HiddenSetting { override var title: NSAttributedString? { return NSAttributedString( string: "Debug: Reset Seed Counter", - attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] ) } @@ -107,7 +107,7 @@ final class ResetSeedCounterSetting: HiddenSetting { let level = progressManagerType.loadCurrentLevel() return NSAttributedString( string: "Seeds: \(seedsCollected) | Level: \(level)", - attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText] + attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText] ) } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterView.swift b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterView.swift index 4ff0bb3e2b0b..c533ff45e944 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterView.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/ClimateImpactCounter/SeedCounterView.swift @@ -60,8 +60,8 @@ struct SeedCounterView: View { // MARK: - Helpers func applyTheme(theme: Theme) { - self.theme.backgroundColor = Color(.legacyTheme.ecosia.primaryBackground) - self.theme.progressColor = Color(.legacyTheme.ecosia.primaryButtonActive) + self.theme.backgroundColor = Color(theme.colors.ecosia.backgroundPrimary) + self.theme.progressColor = Color(theme.colors.ecosia.buttonBackgroundPrimaryActive) } private func triggerUpdateValues() { @@ -77,15 +77,31 @@ struct SeedCounterView: View { } } struct NewSeedCollectedCircleView: View { + let windowUUID: WindowUUID? + @Environment(\.themeManager) var themeManager + + @State private var newSeedCollectedCircleColor: Color = .clear + var seedsCollected: Int var body: some View { ZStack { Circle() - .fill(Color(.legacyTheme.ecosia.peach)) + .fill(newSeedCollectedCircleColor) Text("+\(seedsCollected)") .font(.caption) } + .onAppear { + applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID)) + } + .onReceive(NotificationCenter.default.publisher(for: .ThemeDidChange)) { notification in + guard let uuid = notification.windowUUID, uuid == windowUUID else { return } + applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID)) + } + } + + func applyTheme(theme: Theme) { + newSeedCollectedCircleColor = Color(theme.colors.ecosia.newSeedCollectedCircle) } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCell.swift index 9909f6683af2..8899e2825cd6 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCell.swift @@ -5,7 +5,7 @@ import Foundation import Common -final class NTPCustomizationCell: UICollectionViewCell, Themeable, ReusableCell { +final class NTPCustomizationCell: UICollectionViewCell, ThemeApplicable, ReusableCell { struct UX { static let buttonHeight: CGFloat = 40 static let horizontalInset: CGFloat = 16 @@ -31,29 +31,16 @@ final class NTPCustomizationCell: UICollectionViewCell, Themeable, ReusableCell return button }() - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { super.init(frame: frame) setup() - applyTheme() } required init?(coder: NSCoder) { super.init(coder: coder) setup() - applyTheme() - } - - override func prepareForReuse() { - super.prepareForReuse() - applyTheme() } override func layoutSubviews() { @@ -72,14 +59,13 @@ final class NTPCustomizationCell: UICollectionViewCell, Themeable, ReusableCell button.centerXAnchor.constraint(equalTo: contentView.centerXAnchor), button.centerYAnchor.constraint(equalTo: contentView.centerYAnchor) ]) - listenForThemeChange(contentView) } - func applyTheme() { - button.imageView?.tintColor = .legacyTheme.ecosia.secondaryButtonContent - button.setTitleColor(.legacyTheme.ecosia.secondaryButtonContent, for: .normal) - button.setBackgroundColor(.legacyTheme.ecosia.secondaryButtonBackground, forState: .normal) - button.setBackgroundColor(.legacyTheme.ecosia.activeTransparentBackground, forState: .highlighted) + func applyTheme(theme: Theme) { + button.imageView?.tintColor = theme.colors.ecosia.buttonContentSecondary + button.setTitleColor(theme.colors.ecosia.buttonContentSecondary, for: .normal) + button.setBackgroundColor(theme.colors.ecosia.buttonBackgroundNTPCustomization, forState: .normal) + button.setBackgroundColor(theme.colors.ecosia.buttonBackgroundTransparentActive, forState: .highlighted) } @objc func touchButtonAction() { diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCellViewModel.swift b/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCellViewModel.swift index 0682cd821401..f4c21918ee87 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCellViewModel.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Customization/NTPCustomizationCellViewModel.swift @@ -57,6 +57,7 @@ extension NTPCustomizationCellViewModel: HomepageSectionHandler { return UICollectionViewCell() } cell.delegate = delegate + cell.applyTheme(theme: theme) return cell } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/DefaultBrowser.swift b/firefox-ios/Client/Ecosia/UI/NTP/DefaultBrowser.swift index 9d91bbc91baf..020a3df3df02 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/DefaultBrowser.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/DefaultBrowser.swift @@ -202,7 +202,7 @@ final class DefaultBrowser: UIViewController, Themeable { line2.addArrangedSubview(text2) self.text2 = text2 - let cta = EcosiaPrimaryButton() + let cta = EcosiaPrimaryButton(windowUUID: windowUUID) cta.contentEdgeInsets = .init(top: 0, left: 16, bottom: 0, right: 16) cta.translatesAutoresizingMaskIntoConstraints = false cta.setTitle(.localized(.openSettings), for: .normal) @@ -237,17 +237,18 @@ final class DefaultBrowser: UIViewController, Themeable { } @objc func applyTheme() { + let theme = themeManager.getCurrentTheme(for: windowUUID) view.backgroundColor = .clear - headline.textColor = .legacyTheme.ecosia.primaryText - text1.textColor = .legacyTheme.ecosia.secondaryText - text2.textColor = .legacyTheme.ecosia.secondaryText - arrow1.tintColor = .legacyTheme.ecosia.primaryButton - arrow2.tintColor = .legacyTheme.ecosia.primaryButton - content.backgroundColor = .legacyTheme.ecosia.ntpIntroBackground - waves.tintColor = .legacyTheme.ecosia.ntpIntroBackground - cta.setTitleColor(.legacyTheme.ecosia.primaryTextInverted, for: .normal) - skip.setTitleColor(.legacyTheme.ecosia.primaryButton, for: .normal) - cta.backgroundColor = .legacyTheme.ecosia.primaryButton + headline.textColor = theme.colors.ecosia.textPrimary + text1.textColor = theme.colors.ecosia.textSecondary + text2.textColor = theme.colors.ecosia.textSecondary + arrow1.tintColor = theme.colors.ecosia.buttonBackgroundPrimary + arrow2.tintColor = theme.colors.ecosia.buttonBackgroundPrimary + content.backgroundColor = theme.colors.ecosia.ntpIntroBackground + waves.tintColor = theme.colors.ecosia.ntpIntroBackground + cta.setTitleColor(theme.colors.ecosia.textInversePrimary, for: .normal) + skip.setTitleColor(theme.colors.ecosia.buttonBackgroundPrimary, for: .normal) + cta.backgroundColor = theme.colors.ecosia.buttonBackgroundPrimary } @objc private func skipTapped() { diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCell.swift index 98f1ecd8bd3f..8eb9ba181be3 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCell.swift @@ -6,7 +6,7 @@ import UIKit import Core import Common -final class NTPImpactCell: UICollectionViewCell, Themeable, ReusableCell { +final class NTPImpactCell: UICollectionViewCell, ThemeApplicable, ReusableCell { struct UX { static let cellsSpacing: CGFloat = 12 } @@ -28,24 +28,16 @@ final class NTPImpactCell: UICollectionViewCell, Themeable, ReusableCell { containerStack.arrangedSubviews.compactMap { $0 as? NTPImpactRowView } } - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { super.init(frame: frame) setup() - applyTheme() } required init?(coder: NSCoder) { super.init(coder: coder) setup() - applyTheme() } override func layoutSubviews() { @@ -56,7 +48,6 @@ final class NTPImpactCell: UICollectionViewCell, Themeable, ReusableCell { private func setup() { contentView.addSubview(containerStack) setupConstraints() - listenForThemeChange(contentView) } private func setupConstraints() { @@ -68,9 +59,10 @@ final class NTPImpactCell: UICollectionViewCell, Themeable, ReusableCell { ]) } - func applyTheme() { + func applyTheme(theme: Theme) { containerStack.arrangedSubviews.forEach { view in (view as? Themeable)?.applyTheme() + (view as? ThemeApplicable)?.applyTheme(theme: theme) } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCellViewModel.swift b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCellViewModel.swift index 0e2a8ac15954..ec99abfe8791 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCellViewModel.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactCellViewModel.swift @@ -151,6 +151,7 @@ extension NTPImpactCellViewModel: HomepageSectionHandler { let items = infoItemSections[indexPath.row] cell.configure(items: items) cell.delegate = delegate + cell.applyTheme(theme: theme) cells[indexPath.row] = cell return cell } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactDividerFooter.swift b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactDividerFooter.swift index 77a32fa50367..02bc53dc1e08 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactDividerFooter.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactDividerFooter.swift @@ -5,7 +5,7 @@ import Foundation import Common -final class NTPImpactDividerFooter: UICollectionReusableView, ReusableCell, Themeable { +final class NTPImpactDividerFooter: UICollectionReusableView, ReusableCell, ThemeApplicable { struct UX { static let dividerHeight: CGFloat = 1 static let dividerTop: CGFloat = 20 @@ -20,12 +20,6 @@ final class NTPImpactDividerFooter: UICollectionReusableView, ReusableCell, Them return view }() - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init required init?(coder: NSCoder) { nil } @@ -41,13 +35,9 @@ final class NTPImpactDividerFooter: UICollectionReusableView, ReusableCell, Them dividerView.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -UX.dividerInset), dividerView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -UX.dividerBottom) ]) - - applyTheme() - - listenForThemeChange(self) } - @objc func applyTheme() { - dividerView.backgroundColor = .legacyTheme.ecosia.border + func applyTheme(theme: Theme) { + dividerView.backgroundColor = theme.colors.ecosia.borderDecorative } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactRowView.swift b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactRowView.swift index ab3a34687a5e..596c7de7d22e 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactRowView.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Impact/NTPImpactRowView.swift @@ -7,7 +7,7 @@ import Common import ComponentLibrary /// A view representing an individual impact row, used in the New Tab Page to display environmental impact information. -final class NTPImpactRowView: UIView, Themeable { +final class NTPImpactRowView: UIView, ThemeApplicable { // MARK: - UX Constants @@ -134,12 +134,6 @@ final class NTPImpactRowView: UIView, Themeable { /// Optional background color for the row. var customBackgroundColor: UIColor? - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Initialization /// Initializes a new `NTPImpactRowView` with the provided `ClimateImpactInfo`. @@ -154,7 +148,6 @@ final class NTPImpactRowView: UIView, Themeable { } setupView() setupConstraints() - applyTheme() } /// Not supported, as `NTPImpactRowView` requires `ClimateImpactInfo` during initialization. @@ -234,17 +227,16 @@ final class NTPImpactRowView: UIView, Themeable { ]) } - // MARK: - Themeable - - /// Applies the current theme to the view, updating colors and styles as needed. - func applyTheme() { - backgroundColor = customBackgroundColor ?? .legacyTheme.ecosia.secondaryBackground - titleLabel.textColor = .legacyTheme.ecosia.primaryText - subtitleLabel.textColor = .legacyTheme.ecosia.secondaryText - actionButton.setTitleColor(.legacyTheme.ecosia.primaryButton, for: .normal) - dividerView.backgroundColor = .legacyTheme.ecosia.border - totalProgressView.color = .legacyTheme.ecosia.ntpBackground - currentProgressView.color = .legacyTheme.ecosia.treeCounterProgressCurrent + // MARK: - ThemeApplicable + + func applyTheme(theme: Theme) { + backgroundColor = customBackgroundColor ?? theme.colors.ecosia.backgroundSecondary + titleLabel.textColor = theme.colors.ecosia.textPrimary + subtitleLabel.textColor = theme.colors.ecosia.textSecondary + actionButton.setTitleColor(theme.colors.ecosia.buttonBackgroundPrimary, for: .normal) + dividerView.backgroundColor = theme.colors.ecosia.borderDecorative + totalProgressView.color = theme.colors.ecosia.ntpBackground + currentProgressView.color = theme.colors.ecosia.brandPrimary } // MARK: - Actions diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibaryCellViewModel.swift b/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibaryCellViewModel.swift index 1371db0bd3bc..05ab2e7e1d0a 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibaryCellViewModel.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibaryCellViewModel.swift @@ -67,7 +67,11 @@ extension NTPLibraryCellViewModel: HomepageViewModelProtocol { extension NTPLibraryCellViewModel: HomepageSectionHandler { func configure(_ cell: UICollectionViewCell, at indexPath: IndexPath) -> UICollectionViewCell { - (cell as! NTPLibraryCell).delegate = delegate + guard let cell = cell as? NTPLibraryCell else { + return UICollectionViewCell() + } + cell.delegate = delegate + cell.applyTheme(theme: theme) return cell } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibraryCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibraryCell.swift index 2b2d990ab4ca..464a4c0b055c 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibraryCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Library/NTPLibraryCell.swift @@ -6,7 +6,7 @@ import Shared import UIKit import Common -class NTPLibraryCell: UICollectionViewCell, Themeable, ReusableCell { +class NTPLibraryCell: UICollectionViewCell, ThemeApplicable, ReusableCell { var mainView = UIStackView() weak var widthConstraint: NSLayoutConstraint! @@ -49,12 +49,6 @@ class NTPLibraryCell: UICollectionViewCell, Themeable, ReusableCell { var shortcuts: [NTPLibraryShortcutView] = [] - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { @@ -95,27 +89,20 @@ class NTPLibraryCell: UICollectionViewCell, Themeable, ReusableCell { mainView.addArrangedSubview(view) shortcuts.append(view) } - applyTheme() - listenForThemeChange(contentView) } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - func applyTheme() { + func applyTheme(theme: Theme) { shortcuts.forEach { item in - item.title.textColor = .legacyTheme.ecosia.primaryText - item.button.tintColor = .legacyTheme.ecosia.primaryButton - item.button.backgroundColor = .legacyTheme.ecosia.secondaryButton + item.title.textColor = theme.colors.ecosia.textPrimary + item.button.tintColor = theme.colors.ecosia.buttonBackgroundPrimary + item.button.backgroundColor = theme.colors.ecosia.buttonBackgroundSecondary } } - override func prepareForReuse() { - super.prepareForReuse() - applyTheme() - } - @objc func tapped(_ sender: UIButton) { guard let item = Item(rawValue: sender.tag) else { return } Analytics.shared.ntpLibraryItem(.click, property: item.analyticsProperty) diff --git a/firefox-ios/Client/Ecosia/UI/NTP/Logo/NTPLogoCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/Logo/NTPLogoCell.swift index e3116eb2d0c0..7344778b6b81 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/Logo/NTPLogoCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/Logo/NTPLogoCell.swift @@ -6,18 +6,12 @@ import UIKit import Core import Common -final class NTPLogoCell: UICollectionViewCell, ReusableCell, Themeable { +final class NTPLogoCell: UICollectionViewCell, ReusableCell, ThemeApplicable { static let bottomMargin: CGFloat = 6 static let width: CGFloat = 144 private weak var logo: UIImageView! - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { @@ -50,16 +44,9 @@ final class NTPLogoCell: UICollectionViewCell, ReusableCell, Themeable { logo.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true logo.centerXAnchor.constraint(equalTo: contentView.centerXAnchor).isActive = true logo.widthAnchor.constraint(equalToConstant: Self.width).isActive = true - applyTheme() - listenForThemeChange(contentView) - } - - func applyTheme() { - logo.tintColor = .legacyTheme.ecosia.primaryBrand } - override func prepareForReuse() { - super.prepareForReuse() - applyTheme() + func applyTheme(theme: Theme) { + logo.tintColor = theme.colors.ecosia.brandPrimary } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/NTPTooltip.swift b/firefox-ios/Client/Ecosia/UI/NTP/NTPTooltip.swift index cbba15a316b1..b3afed163a67 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/NTPTooltip.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/NTPTooltip.swift @@ -5,7 +5,7 @@ import UIKit import Common -final class NTPTooltip: UICollectionReusableView, Themeable { +final class NTPTooltip: UICollectionReusableView, ThemeApplicable { enum TailPosition { case leading, center } @@ -130,10 +130,7 @@ final class NTPTooltip: UICollectionReusableView, Themeable { let tap = UITapGestureRecognizer(target: self, action: #selector(tapped)) addGestureRecognizer(tap) - applyTheme() addShadows() - - listenForThemeChange(self) } func setText(_ text: String) { @@ -148,11 +145,11 @@ final class NTPTooltip: UICollectionReusableView, Themeable { linkButton.isHidden = true } - func setLinkTitle(_ text: String) { + func setLinkTitle(_ text: String, theme: Theme) { let titleString = NSMutableAttributedString(string: text) titleString.addAttributes([ .font: UIFont.preferredFont(forTextStyle: .callout).bold(), - .foregroundColor: UIColor.legacyTheme.ecosia.primaryTextInverted + .foregroundColor: theme.colors.ecosia.textInversePrimary ], range: NSRange(location: 0, length: text.count)) linkButton.setAttributedTitle(titleString, for: .normal) linkButton.isHidden = false @@ -168,11 +165,11 @@ final class NTPTooltip: UICollectionReusableView, Themeable { } } - @objc func applyTheme() { - tail.tintColor = UIColor.legacyTheme.ecosia.quarternaryBackground - background.backgroundColor = UIColor.legacyTheme.ecosia.quarternaryBackground - textLabel.textColor = .legacyTheme.ecosia.primaryTextInverted - closeButton.tintColor = .legacyTheme.ecosia.primaryTextInverted + func applyTheme(theme: Theme) { + tail.tintColor = theme.colors.ecosia.backgroundQuaternary + background.backgroundColor = theme.colors.ecosia.backgroundQuaternary + textLabel.textColor = theme.colors.ecosia.textInversePrimary + closeButton.tintColor = theme.colors.ecosia.textInversePrimary } @objc func tapped() { @@ -187,11 +184,6 @@ final class NTPTooltip: UICollectionReusableView, Themeable { delegate?.ntpTooltipLinkTapped(self) } - override func prepareForReuse() { - super.prepareForReuse() - applyTheme() - } - private func updateTailPosition() { switch tailPosition { case .center: diff --git a/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCell.swift index 165fa90b8cf8..b2a5520bd8b4 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCell.swift @@ -6,7 +6,7 @@ import Core import UIKit import Common -final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell { +final class NTPNewsCell: UICollectionViewCell, ThemeApplicable, ReusableCell { private var imageUrl: URL? private lazy var background: UIView = { let background = UIView() @@ -90,13 +90,8 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell { bottomLabel.setContentHuggingPriority(.defaultLow, for: .horizontal) return bottomLabel }() - var defaultBackgroundColor: (() -> UIColor) = { .legacyTheme.ecosia.ntpCellBackground } - - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default + var defaultBackgroundColor: UIColor = .clear + var selectedBackgroundColor: UIColor = .clear // MARK: - Init @@ -162,9 +157,6 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell { border.rightAnchor.constraint(equalTo: background.rightAnchor, constant: -16).isActive = true border.bottomAnchor.constraint(equalTo: background.bottomAnchor).isActive = true border.heightAnchor.constraint(equalToConstant: 1).isActive = true - - applyTheme() - listenForThemeChange(contentView) } override var isSelected: Bool { @@ -200,7 +192,6 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell { border.isHidden = row == totalCount - 1 background.setMaskedCornersUsingPosition(row: row, totalCount: totalCount) - applyTheme() isAccessibilityElement = true accessibilityIdentifier = "news_item" @@ -217,16 +208,18 @@ final class NTPNewsCell: UICollectionViewCell, Themeable, ReusableCell { } private func hover() { - background.backgroundColor = isSelected || isHighlighted ? .legacyTheme.ecosia.secondarySelectedBackground : defaultBackgroundColor() + background.backgroundColor = isSelected || isHighlighted ? selectedBackgroundColor : defaultBackgroundColor } - func applyTheme() { - background.backgroundColor = defaultBackgroundColor() - placeholder.tintColor = .legacyTheme.ecosia.decorativeIcon - placeholder.backgroundColor = .legacyTheme.ecosia.newsPlaceholder - border.backgroundColor = .legacyTheme.ecosia.border - title.textColor = .legacyTheme.ecosia.primaryText - bottomLabel.textColor = .legacyTheme.ecosia.secondaryText - highlightLabel.textColor = .legacyTheme.ecosia.secondaryText + func applyTheme(theme: Theme) { + defaultBackgroundColor = theme.colors.ecosia.ntpCellBackground + selectedBackgroundColor = theme.colors.ecosia.secondarySelectedBackground + background.backgroundColor = defaultBackgroundColor + placeholder.tintColor = theme.colors.ecosia.iconDecorative + placeholder.backgroundColor = theme.colors.ecosia.newsPlaceholder + border.backgroundColor = theme.colors.ecosia.borderDecorative + title.textColor = theme.colors.ecosia.textPrimary + bottomLabel.textColor = theme.colors.ecosia.textSecondary + highlightLabel.textColor = theme.colors.ecosia.textSecondary } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCellViewModel.swift b/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCellViewModel.swift index 2bb2cc30ca7b..9552c6c2b47b 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCellViewModel.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/News/NTPNewsCellViewModel.swift @@ -95,8 +95,8 @@ extension NTPNewsCellViewModel: HomepageSectionHandler { func configure(_ cell: UICollectionViewCell, at indexPath: IndexPath) -> UICollectionViewCell { guard let cell = cell as? NTPNewsCell else { return UICollectionViewCell() } let itemCount = numberOfItemsInSection() - cell.defaultBackgroundColor = { .legacyTheme.ecosia.ntpImpactBackground } cell.configure(items[indexPath.row], images: images, row: indexPath.row, totalCount: itemCount) + cell.applyTheme(theme: theme) return cell } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/News/NewsController.swift b/firefox-ios/Client/Ecosia/UI/NTP/News/NewsController.swift index 386bc2abf972..d15dd93b42c7 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/News/NewsController.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/News/NewsController.swift @@ -20,7 +20,7 @@ final class NewsController: UIViewController, UICollectionViewDelegate, UICollec let windowUUID: WindowUUID var currentWindowUUID: Common.WindowUUID? { return windowUUID } - var themeManager: ThemeManager { AppContainer.shared.resolve() } + var themeManager: ThemeManager var themeObserver: NSObjectProtocol? var notificationCenter: NotificationProtocol = NotificationCenter.default @@ -28,8 +28,11 @@ final class NewsController: UIViewController, UICollectionViewDelegate, UICollec required init?(coder: NSCoder) { nil } - init(windowUUID: WindowUUID, items: [NewsModel]) { + init(items: [NewsModel], + windowUUID: WindowUUID, + themeManager: ThemeManager = AppContainer.shared.resolve()) { self.windowUUID = windowUUID + self.themeManager = themeManager super.init(nibName: nil, bundle: nil) self.items = items title = .localized(.ecosiaNews) @@ -130,6 +133,7 @@ final class NewsController: UIViewController, UICollectionViewDelegate, UICollec func collectionView(_: UICollectionView, cellForItemAt: IndexPath) -> UICollectionViewCell { let cell = collection.dequeueReusableCell(withReuseIdentifier: identifier, for: cellForItemAt) as! NTPNewsCell cell.configure(items[cellForItemAt.row], images: images, row: cellForItemAt.item, totalCount: items.count) + cell.applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID)) return cell } @@ -141,13 +145,16 @@ final class NewsController: UIViewController, UICollectionViewDelegate, UICollec } func applyTheme() { + let theme = themeManager.getCurrentTheme(for: windowUUID) collection.visibleSupplementaryViews(ofKind: UICollectionView.elementKindSectionHeader).forEach({ ($0 as? Themeable)?.applyTheme() + ($0 as? ThemeApplicable)?.applyTheme(theme: theme) }) collection.visibleCells.forEach({ ($0 as? Themeable)?.applyTheme() + ($0 as? ThemeApplicable)?.applyTheme(theme: theme) }) - collection.backgroundColor = UIColor.legacyTheme.ecosia.modalBackground + collection.backgroundColor = theme.colors.ecosia.modalBackground updateBarAppearance() if traitCollection.userInterfaceIdiom == .pad { @@ -158,12 +165,13 @@ final class NewsController: UIViewController, UICollectionViewDelegate, UICollec private func updateBarAppearance() { guard let appearance = navigationController?.navigationBar.standardAppearance else { return } - appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.legacyTheme.ecosia.primaryText] - appearance.titleTextAttributes = [.foregroundColor: UIColor.legacyTheme.ecosia.primaryText] - appearance.backgroundColor = .legacyTheme.ecosia.modalBackground + let theme = themeManager.getCurrentTheme(for: windowUUID) + appearance.largeTitleTextAttributes = [.foregroundColor: theme.colors.ecosia.textPrimary] + appearance.titleTextAttributes = [.foregroundColor: theme.colors.ecosia.textPrimary] + appearance.backgroundColor = theme.colors.ecosia.modalBackground navigationItem.standardAppearance = appearance - navigationController?.navigationBar.backgroundColor = .legacyTheme.ecosia.modalBackground - navigationController?.navigationBar.tintColor = .legacyTheme.ecosia.primaryBrand + navigationController?.navigationBar.backgroundColor = theme.colors.ecosia.modalBackground + navigationController?.navigationBar.tintColor = theme.colors.ecosia.brandPrimary } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { @@ -172,13 +180,7 @@ final class NewsController: UIViewController, UICollectionViewDelegate, UICollec } } -private final class NewsSubHeader: UICollectionReusableView, Themeable { - - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default +private final class NewsSubHeader: UICollectionReusableView, ThemeApplicable { // MARK: - Properties @@ -203,17 +205,11 @@ private final class NewsSubHeader: UICollectionReusableView, Themeable { subtitle.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -16).isActive = true subtitle.leftAnchor.constraint(equalTo: leftAnchor).isActive = true subtitle.rightAnchor.constraint(equalTo: rightAnchor).isActive = true - applyTheme() } - override func prepareForReuse() { - super.prepareForReuse() - applyTheme() - } - - func applyTheme() { - backgroundColor = UIColor.legacyTheme.ecosia.modalBackground - subtitle.textColor = UIColor.legacyTheme.ecosia.secondaryText + func applyTheme(theme: Theme) { + backgroundColor = theme.colors.ecosia.modalBackground + subtitle.textColor = theme.colors.ecosia.textSecondary } } diff --git a/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCell.swift b/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCell.swift index 55c3bf0242d2..bbbc540afd1e 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCell.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCell.swift @@ -7,7 +7,7 @@ import Core import Common /// Reusable Nudge Card Cell that can be configured with any view model. -class NTPConfigurableNudgeCardCell: UICollectionViewCell, Themeable, ReusableCell { +class NTPConfigurableNudgeCardCell: UICollectionViewCell, ThemeApplicable, ReusableCell { // MARK: - UX Constants private enum UX { @@ -104,12 +104,6 @@ class NTPConfigurableNudgeCardCell: UICollectionViewCell, Themeable, ReusableCel weak var delegate: NTPConfigurableNudgeCardCellDelegate? - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Initializer override init(frame: CGRect) { @@ -144,9 +138,6 @@ class NTPConfigurableNudgeCardCell: UICollectionViewCell, Themeable, ReusableCel imageView.heightAnchor.constraint(equalToConstant: UX.imageWidthHeight), imageView.widthAnchor.constraint(equalTo: imageView.heightAnchor), ]) - - applyTheme() - listenForThemeChange(contentView) } // MARK: - Configuration Method @@ -182,13 +173,12 @@ class NTPConfigurableNudgeCardCell: UICollectionViewCell, Themeable, ReusableCel } // MARK: - Theming - @objc func applyTheme() { - // Apply theming based on the provided theme from the ViewModel - mainContainerStackView.backgroundColor = .legacyTheme.ecosia.secondaryBackground - closeButton.tintColor = .legacyTheme.ecosia.decorativeIcon - titleLabel.textColor = .legacyTheme.ecosia.primaryText - descriptionLabel.textColor = .legacyTheme.ecosia.secondaryText - actionButton.setTitleColor(.legacyTheme.ecosia.primaryButton, for: .normal) + func applyTheme(theme: Theme) { + mainContainerStackView.backgroundColor = theme.colors.ecosia.backgroundSecondary + closeButton.tintColor = theme.colors.ecosia.iconDecorative + titleLabel.textColor = theme.colors.ecosia.textPrimary + descriptionLabel.textColor = theme.colors.ecosia.textSecondary + actionButton.setTitleColor(theme.colors.ecosia.buttonBackgroundPrimary, for: .normal) } @objc private func closeAction() { diff --git a/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCellViewModel.swift b/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCellViewModel.swift index 715be5d34f5c..9e1c95c7bafe 100644 --- a/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCellViewModel.swift +++ b/firefox-ios/Client/Ecosia/UI/NTP/NudgeCards/NTPConfigurableNudgeCardCellViewModel.swift @@ -86,7 +86,11 @@ class NTPConfigurableNudgeCardCellViewModel: HomepageViewModelProtocol { extension NTPConfigurableNudgeCardCellViewModel: HomepageSectionHandler { func configure(_ cell: UICollectionViewCell, at indexPath: IndexPath) -> UICollectionViewCell { - (cell as? NTPConfigurableNudgeCardCell)?.configure(with: self) + guard let cell = cell as? NTPConfigurableNudgeCardCell else { + return UICollectionViewCell() + } + cell.configure(with: self) + cell.applyTheme(theme: theme) return cell } } diff --git a/firefox-ios/Client/Ecosia/UI/Onboarding/Welcome.swift b/firefox-ios/Client/Ecosia/UI/Onboarding/Welcome.swift index 1c98f6ae3f77..699c5237990d 100644 --- a/firefox-ios/Client/Ecosia/UI/Onboarding/Welcome.swift +++ b/firefox-ios/Client/Ecosia/UI/Onboarding/Welcome.swift @@ -26,10 +26,12 @@ final class Welcome: UIViewController { private var zoomedOut = false private weak var delegate: WelcomeDelegate? + let windowUUID: WindowUUID required init?(coder: NSCoder) { nil } - init(delegate: WelcomeDelegate) { + init(delegate: WelcomeDelegate, windowUUID: WindowUUID) { self.delegate = delegate + self.windowUUID = windowUUID super.init(nibName: nil, bundle: nil) modalPresentationCapturesStatusBarAppearance = true definesPresentationContext = true @@ -47,11 +49,6 @@ final class Welcome: UIViewController { addBackground() addStack() - /* TODO Ecosia Upgrade: Is this still needed? [MOB-3152] - let themeManager: ThemeManager = AppContainer.shared.resolve() - (themeManager as? EcosiaThemeManager)?.updateLegacyThemeIfSystemThemeON() - */ - Task.detached { // Fetching FinancialReports async as some onboarding steps might use it try? await FinancialReports.shared.fetchAndUpdate() @@ -151,7 +148,7 @@ final class Welcome: UIViewController { stack.addArrangedSubview(label) let cta = UIButton(type: .system) - cta.backgroundColor = .Light.Button.secondary + cta.backgroundColor = .Light.Button.backgroundSecondary cta.setTitle(.localized(.getStarted), for: .normal) cta.titleLabel?.font = .preferredFont(forTextStyle: .callout) cta.titleLabel?.adjustsFontForContentSizeCategory = true @@ -282,7 +279,7 @@ final class Welcome: UIViewController { // MARK: Actions @objc func getStarted() { - let tour = WelcomeTour(delegate: self) + let tour = WelcomeTour(delegate: self, windowUUID: windowUUID) tour.modalTransitionStyle = .crossDissolve tour.modalPresentationStyle = .overCurrentContext present(tour, animated: true, completion: nil) @@ -293,11 +290,6 @@ final class Welcome: UIViewController { Analytics.shared.introClick(.skip, page: .start, index: 0) delegate?.welcomeDidFinish(self) } - - override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { - super.traitCollectionDidChange(previousTraitCollection) - LegacyThemeManager.instance.themeChanged(from: previousTraitCollection, to: traitCollection) - } } extension Welcome: WelcomeTourDelegate { diff --git a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTour.swift b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTour.swift index af83748360cc..1c2d68dc6e02 100644 --- a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTour.swift +++ b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTour.swift @@ -38,14 +38,16 @@ final class WelcomeTour: UIViewController, Themeable { // MARK: - Themeable Properties - var currentWindowUUID: WindowUUID? { return view.currentWindowUUID } + let windowUUID: WindowUUID + var currentWindowUUID: WindowUUID? { windowUUID } var themeManager: ThemeManager { AppContainer.shared.resolve() } var themeObserver: NSObjectProtocol? var notificationCenter: NotificationProtocol = NotificationCenter.default // MARK: - Init - init(delegate: WelcomeTourDelegate, startingStep: Step? = nil) { + init(delegate: WelcomeTourDelegate, windowUUID: WindowUUID, startingStep: Step? = nil) { + self.windowUUID = windowUUID super.init(nibName: nil, bundle: nil) modalPresentationCapturesStatusBarAppearance = true self.delegate = delegate @@ -291,7 +293,7 @@ final class WelcomeTour: UIViewController, Themeable { container.subviews.forEach({ $0.removeFromSuperview() }) guard let content = content else { return } - (content as? Themeable)?.applyTheme() + (content as? ThemeApplicable)?.applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID)) container.addSubview(content) content.translatesAutoresizingMaskIntoConstraints = false content.leadingAnchor.constraint(equalTo: container.leadingAnchor).isActive = true @@ -357,17 +359,18 @@ final class WelcomeTour: UIViewController, Themeable { // MARK: Theming func applyTheme() { - view.backgroundColor = .legacyTheme.ecosia.welcomeBackground - waves.tintColor = .legacyTheme.ecosia.welcomeBackground - titleLabel.textColor = .legacyTheme.ecosia.primaryText - subtitleLabel.textColor = .legacyTheme.ecosia.secondaryText - skipButton?.tintColor = .legacyTheme.ecosia.primaryButton - backButton.tintColor = .legacyTheme.ecosia.primaryButton - pageControl.pageIndicatorTintColor = .legacyTheme.ecosia.disabled - pageControl.currentPageIndicatorTintColor = .legacyTheme.ecosia.primaryButton - ctaButton.backgroundColor = .Light.Button.secondary + let theme = themeManager.getCurrentTheme(for: currentWindowUUID) + view.backgroundColor = theme.colors.ecosia.modalBackground + waves.tintColor = theme.colors.ecosia.modalBackground + titleLabel.textColor = theme.colors.ecosia.textPrimary + subtitleLabel.textColor = theme.colors.ecosia.textSecondary + skipButton?.tintColor = theme.colors.ecosia.buttonBackgroundPrimary + backButton.tintColor = theme.colors.ecosia.buttonBackgroundPrimary + pageControl.pageIndicatorTintColor = theme.colors.ecosia.stateDisabled + pageControl.currentPageIndicatorTintColor = theme.colors.ecosia.buttonBackgroundPrimary + ctaButton.backgroundColor = .Light.Button.backgroundSecondary ctaButton.setTitleColor(.Light.Text.primary, for: .normal) - container.subviews.forEach({ ($0 as? Themeable)?.applyTheme() }) + container.subviews.forEach({ ($0 as? ThemeApplicable)?.applyTheme(theme: theme) }) imageView.backgroundColor = current?.background.color ?? .clear guard let current = current else { return } diff --git a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourAction.swift b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourAction.swift index 218a7fb5bb0d..493b1fc3452a 100644 --- a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourAction.swift +++ b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourAction.swift @@ -6,18 +6,12 @@ import UIKit import Core import Common -final class WelcomeTourAction: UIView, Themeable { +final class WelcomeTourAction: UIView, ThemeApplicable { // MARK: - Properties private weak var stack: UIStackView! - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { @@ -70,9 +64,9 @@ final class WelcomeTourAction: UIView, Themeable { stack.addArrangedSubview(bottom) } - func applyTheme() { + func applyTheme(theme: Theme) { stack.arrangedSubviews.forEach { view in - (view as? Themeable)?.applyTheme() + (view as? ThemeApplicable)?.applyTheme(theme: theme) } } diff --git a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourGreen.swift b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourGreen.swift index ddbf44e7ff9e..c498d20002dc 100644 --- a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourGreen.swift +++ b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourGreen.swift @@ -5,7 +5,7 @@ import UIKit import Common -final class WelcomeTourGreen: UIView, Themeable { +final class WelcomeTourGreen: UIView, ThemeApplicable { private lazy var searchLabel: UILabel = { let label = UILabel() label.translatesAutoresizingMaskIntoConstraints = false @@ -34,19 +34,12 @@ final class WelcomeTourGreen: UIView, Themeable { return label }() - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init init(isCounterEnabled: Bool = false) { super.init(frame: .zero) setup(isCounterEnabled: isCounterEnabled) updateAccessibilitySettings() - applyTheme() } required init?(coder: NSCoder) { nil } @@ -104,10 +97,10 @@ final class WelcomeTourGreen: UIView, Themeable { } } - func applyTheme() { - searchLabel.textColor = .legacyTheme.ecosia.primaryText - counterLabel.textColor = .legacyTheme.ecosia.primaryText - counterSubtitleLabel.textColor = .legacyTheme.ecosia.secondaryText + func applyTheme(theme: Theme) { + searchLabel.textColor = theme.colors.ecosia.textPrimary + counterLabel.textColor = theme.colors.ecosia.textPrimary + counterSubtitleLabel.textColor = theme.colors.ecosia.textSecondary } func updateAccessibilitySettings() { diff --git a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourProfit.swift b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourProfit.swift index 85a6a66d07a7..7c42b6b9d2dd 100644 --- a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourProfit.swift +++ b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourProfit.swift @@ -5,26 +5,19 @@ import UIKit import Common -final class WelcomeTourProfit: UIView, Themeable { +final class WelcomeTourProfit: UIView, ThemeApplicable { weak var beforeContainer: UIView! weak var beforeLabel: UILabel! weak var afterContainer: UIView! weak var afterLabel: UILabel! weak var treeImage: UIImageView! - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init init() { super.init(frame: .zero) setup() updateAccessibilitySettings() - applyTheme() } required init?(coder: NSCoder) { nil } @@ -108,12 +101,12 @@ final class WelcomeTourProfit: UIView, Themeable { afterDot.centerXAnchor.constraint(equalTo: afterEllipse.leadingAnchor).isActive = true } - func applyTheme() { - beforeContainer.backgroundColor = .legacyTheme.ecosia.welcomeBackground - afterContainer.backgroundColor = .legacyTheme.ecosia.welcomeBackground - beforeLabel.textColor = .legacyTheme.ecosia.primaryText - afterLabel.textColor = .legacyTheme.ecosia.primaryText - treeImage.tintColor = .legacyTheme.ecosia.primaryBrand + func applyTheme(theme: Theme) { + beforeContainer.backgroundColor = theme.colors.ecosia.modalBackground + afterContainer.backgroundColor = theme.colors.ecosia.modalBackground + beforeLabel.textColor = theme.colors.ecosia.textPrimary + afterLabel.textColor = theme.colors.ecosia.textPrimary + treeImage.tintColor = theme.colors.ecosia.brandPrimary } func updateAccessibilitySettings() { diff --git a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourRow.swift b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourRow.swift index e44055e6d33e..2ad1157f2a47 100644 --- a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourRow.swift +++ b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourRow.swift @@ -5,7 +5,7 @@ import Foundation import Common -final class WelcomeTourRow: UIView, Themeable { +final class WelcomeTourRow: UIView, ThemeApplicable { let image: String let title: String let text: String @@ -13,12 +13,6 @@ final class WelcomeTourRow: UIView, Themeable { weak var titleLabel: UILabel! weak var textLabel: UILabel! - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init init(image: String, title: String, text: String) { @@ -28,7 +22,6 @@ final class WelcomeTourRow: UIView, Themeable { super.init(frame: .zero) setup() - applyTheme() } required init?(coder: NSCoder) { nil } @@ -76,9 +69,9 @@ final class WelcomeTourRow: UIView, Themeable { self.textLabel = textLabel } - func applyTheme() { - backgroundColor = .legacyTheme.ecosia.welcomeElementBackground - titleLabel.textColor = .legacyTheme.ecosia.primaryText - textLabel.textColor = .legacyTheme.ecosia.secondaryText + func applyTheme(theme: Theme) { + backgroundColor = theme.colors.ecosia.barBackground + titleLabel.textColor = theme.colors.ecosia.textPrimary + textLabel.textColor = theme.colors.ecosia.textSecondary } } diff --git a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourTransparent.swift b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourTransparent.swift index 7f4c6126be8f..6bcb7bcefbc9 100644 --- a/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourTransparent.swift +++ b/firefox-ios/Client/Ecosia/UI/Onboarding/WelcomeTourTransparent.swift @@ -6,24 +6,17 @@ import UIKit import Core import Common -final class WelcomeTourTransparent: UIView, Themeable { +final class WelcomeTourTransparent: UIView, ThemeApplicable { private weak var stack: UIStackView! private weak var monthView: UIView! private weak var monthViewLabel: UILabel! - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Init override init(frame: CGRect) { super.init(frame: frame) setup() updateAccessibilitySettings() - applyTheme() } required init?(coder: NSCoder) { nil } @@ -59,11 +52,11 @@ final class WelcomeTourTransparent: UIView, Themeable { } } - func applyTheme() { + func applyTheme(theme: Theme) { stack.arrangedSubviews.forEach { view in - (view as? Themeable)?.applyTheme() + (view as? ThemeApplicable)?.applyTheme(theme: theme) } - applyThemeToMonthView() + applyThemeToMonthView(theme: theme) } func updateAccessibilitySettings() { @@ -107,8 +100,8 @@ final class WelcomeTourTransparent: UIView, Themeable { parentStack.addArrangedSubview(UIView(frame: .init(width: 0, height: 8))) } - func applyThemeToMonthView() { - monthView.backgroundColor = .legacyTheme.ecosia.primaryButton - monthViewLabel.textColor = .legacyTheme.ecosia.tertiaryText + func applyThemeToMonthView(theme: Theme) { + monthView.backgroundColor = theme.colors.ecosia.buttonBackgroundPrimary + monthViewLabel.textColor = theme.colors.ecosia.textTertiary } } diff --git a/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenu.swift b/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenu.swift index 65d68c1b0db6..9f037ee08d74 100644 --- a/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenu.swift +++ b/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenu.swift @@ -5,7 +5,7 @@ import UIKit import Common -final class PageActionMenu: UIViewController, UIGestureRecognizerDelegate, Themeable { +final class PageActionMenu: UIViewController, UIGestureRecognizerDelegate { // MARK: - UX @@ -19,9 +19,10 @@ final class PageActionMenu: UIViewController, UIGestureRecognizerDelegate, Theme let windowUUID: WindowUUID var currentWindowUUID: WindowUUID? { return windowUUID } - var themeManager: ThemeManager { AppContainer.shared.resolve() } + var themeManager: ThemeManager var themeObserver: NSObjectProtocol? var notificationCenter: NotificationProtocol = NotificationCenter.default + var currentTheme: Theme { themeManager.getCurrentTheme(for: windowUUID) } // MARK: - Properties @@ -42,10 +43,14 @@ final class PageActionMenu: UIViewController, UIGestureRecognizerDelegate, Theme // MARK: - Init - init(viewModel: PhotonActionSheetViewModel, delegate: PageActionsShortcutsDelegate, windowUUID: WindowUUID) { + init(viewModel: PhotonActionSheetViewModel, + delegate: PageActionsShortcutsDelegate, + windowUUID: WindowUUID, + themeManager: ThemeManager = AppContainer.shared.resolve()) { self.viewModel = viewModel self.delegate = delegate self.windowUUID = windowUUID + self.themeManager = themeManager super.init(nibName: nil, bundle: nil) title = viewModel.title @@ -184,7 +189,7 @@ extension PageActionMenu: UITableViewDataSource, UITableViewDelegate { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: PageActionMenuCell.UX.cellIdentifier, for: indexPath) as! PageActionMenuCell cell.determineTableViewCellPositionAt(indexPath, forActions: viewModel.actions) - cell.configure(with: viewModel, at: indexPath) + cell.configure(with: viewModel, at: indexPath, theme: currentTheme) return cell } @@ -200,6 +205,7 @@ extension PageActionMenu: UITableViewDataSource, UITableViewDelegate { let header = tableView.dequeueReusableHeaderFooterView(withIdentifier: UX.shortcuts) as! PageActionsShortcutsHeader header.delegate = delegate + header.applyTheme(theme: currentTheme) return header } @@ -216,13 +222,16 @@ extension PageActionMenu: UITableViewDataSource, UITableViewDelegate { // MARK: - Themeable -extension PageActionMenu { +extension PageActionMenu: Themeable { func applyTheme() { tableView.reloadData() - view.backgroundColor = .legacyTheme.ecosia.modalBackground - tableView.backgroundColor = .legacyTheme.ecosia.modalBackground - tableView.separatorColor = .legacyTheme.ecosia.border - knob.backgroundColor = .legacyTheme.ecosia.secondaryText + view.backgroundColor = currentTheme.colors.ecosia.modalBackground + tableView.backgroundColor = currentTheme.colors.ecosia.modalBackground + tableView.separatorColor = currentTheme.colors.ecosia.borderDecorative + knob.backgroundColor = currentTheme.colors.ecosia.textSecondary + tableView.visibleCells.forEach { + ($0 as? ThemeApplicable)?.applyTheme(theme: currentTheme) + } } } diff --git a/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenuCell.swift b/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenuCell.swift index 1bb5d9cbc8eb..1a96abb996b9 100644 --- a/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenuCell.swift +++ b/firefox-ios/Client/Ecosia/UI/PageAction/PageActionMenuCell.swift @@ -3,8 +3,9 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/ import UIKit +import Common -final class PageActionMenuCell: UITableViewCell { +final class PageActionMenuCell: UITableViewCell, ThemeApplicable { struct UX { @@ -66,6 +67,10 @@ final class PageActionMenuCell: UITableViewCell { textLabel?.text = nil imageView?.image = nil } + + func applyTheme(theme: Theme) { + badge?.backgroundColor = theme.colors.ecosia.brandPrimary + } } extension PageActionMenuCell { @@ -133,7 +138,7 @@ extension PageActionMenuCell { } /// Adds the custom separator view - private func addCustomGroupedStyleLikeSeparator() { + private func addCustomGroupedStyleLikeSeparator(theme: Theme) { if separatorView == nil { separatorView = UIView() @@ -142,7 +147,7 @@ extension PageActionMenuCell { guard let separatorView else { return } separatorView.translatesAutoresizingMaskIntoConstraints = false - separatorView.backgroundColor = .legacyTheme.ecosia.border + separatorView.backgroundColor = theme.colors.ecosia.borderDecorative contentView.addSubview(separatorView) contentView.bringSubviewToFront(separatorView) @@ -169,32 +174,36 @@ extension PageActionMenuCell { /// - Parameters: /// - viewModel: The`PhotonActionSheetViewModel`'s View Model /// - indexPath: The TableView's index path - func configure(with viewModel: PhotonActionSheetViewModel, at indexPath: IndexPath) { + func configure(with viewModel: PhotonActionSheetViewModel, + at indexPath: IndexPath, + theme: Theme) { - backgroundColor = .legacyTheme.ecosia.impactMultiplyCardBackground + backgroundColor = theme.colors.ecosia.impactMultiplyCardBackground let actions = viewModel.actions[indexPath.section][indexPath.row] guard let item = actions.items.first else { return } textLabel?.text = item.currentTitle - textLabel?.textColor = .legacyTheme.ecosia.primaryText + textLabel?.textColor = theme.colors.ecosia.textPrimary detailTextLabel?.text = item.text - detailTextLabel?.textColor = .legacyTheme.ecosia.secondaryText + detailTextLabel?.textColor = theme.colors.ecosia.textSecondary accessibilityIdentifier = item.iconString ?? item.accessibilityId accessibilityLabel = item.currentTitle if let iconName = item.iconString { imageView?.image = UIImage(named: iconName)?.withRenderingMode(.alwaysTemplate) - imageView?.tintColor = .legacyTheme.ecosia.secondaryText + imageView?.tintColor = theme.colors.ecosia.textSecondary } else { imageView?.image = nil } - isNew(actions.items.first?.isNew == true) + isNew(actions.items.first?.isNew == true, theme: theme) if separatorCellsPositions.contains(position) { - addCustomGroupedStyleLikeSeparator() + addCustomGroupedStyleLikeSeparator(theme: theme) } + + applyTheme(theme: theme) } } @@ -204,7 +213,7 @@ extension PageActionMenuCell { /// /// - Parameters: /// - isNew: A boolean value based on which we create the `badge` view - private func isNew(_ isNew: Bool) { + private func isNew(_ isNew: Bool, theme: Theme) { if isNew { if badge == nil { let badge = UIView() @@ -229,8 +238,7 @@ extension PageActionMenuCell { let height = size.height + 5 badge?.layer.cornerRadius = height / 2 badge?.frame.size = .init(width: size.width + 16, height: height) - badge?.backgroundColor = .legacyTheme.ecosia.primaryBrand - badgeLabel?.textColor = .legacyTheme.ecosia.primaryTextInverted + badgeLabel?.textColor = theme.colors.ecosia.textInversePrimary } else { accessoryView = nil } diff --git a/firefox-ios/Client/Ecosia/UI/PageAction/PageActionsShortcutsHeader.swift b/firefox-ios/Client/Ecosia/UI/PageAction/PageActionsShortcutsHeader.swift index 65052894c4f5..e293131c1c85 100644 --- a/firefox-ios/Client/Ecosia/UI/PageAction/PageActionsShortcutsHeader.swift +++ b/firefox-ios/Client/Ecosia/UI/PageAction/PageActionsShortcutsHeader.swift @@ -12,7 +12,7 @@ protocol PageActionsShortcutsDelegate: AnyObject { func pageOptionsSettings() } -class PageActionsShortcutsHeader: UITableViewHeaderFooterView { +class PageActionsShortcutsHeader: UITableViewHeaderFooterView, ThemeApplicable { var mainView = UIStackView() weak var delegate: PageActionsShortcutsDelegate? @@ -71,28 +71,22 @@ class PageActionsShortcutsHeader: UITableViewHeaderFooterView { mainView.addArrangedSubview(view) shortcuts.append(view) } - applyTheme() } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } - private func applyTheme() { + func applyTheme(theme: Theme) { backgroundView?.backgroundColor = .clear shortcuts.forEach { item in - item.title.textColor = .legacyTheme.ecosia.primaryText - item.button.tintColor = .legacyTheme.ecosia.secondaryText - item.button.backgroundColor = .legacyTheme.ecosia.impactMultiplyCardBackground + item.title.textColor = theme.colors.ecosia.textPrimary + item.button.tintColor = theme.colors.ecosia.textSecondary + item.button.backgroundColor = theme.colors.ecosia.impactMultiplyCardBackground } } - override func prepareForReuse() { - super.prepareForReuse() - applyTheme() - } - @objc func tapped(_ sender: UIButton) { switch sender.tag { case 0: diff --git a/firefox-ios/Client/Ecosia/UI/SemanticColor.swift b/firefox-ios/Client/Ecosia/UI/SemanticColor.swift deleted file mode 100644 index db960fe6ae41..000000000000 --- a/firefox-ios/Client/Ecosia/UI/SemanticColor.swift +++ /dev/null @@ -1,98 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import UIKit - -extension UIColor { - struct Light { - struct Background { - static let primary = UIColor.white - static let secondary = UIColor(red: 0.973, green: 0.973, blue: 0.965, alpha: 1) - static let tertiary = UIColor(red: 0.941, green: 0.941, blue: 0.922, alpha: 1) - static let quarternary = UIColor(red: 0.153, green: 0.322, blue: 0.263, alpha: 1) - static let highlighted = UIColor(rgb: 0xCFF2D0) - } - - struct Button { - static let primary = UIColor(red: 0, green: 0.5, blue: 0.033, alpha: 1) - static let primaryActive = UIColor(rgb: 0x006600) - static let secondary = UIColor.white - static let secondaryActive = UIColor(rgb: 0xF8F8F6) - static let secondaryContent = UIColor(rgb: 0x333333) - static let secondaryBackground = UIColor(rgb: 0xF8F8F6) - static let activeTransparentBackground = UIColor(rgb: 0x333333).withAlphaComponent(0.24) - } - - struct Text { - static let primary = UIColor(red: 0.059, green: 0.059, blue: 0.059, alpha: 1) - static let secondary = UIColor(red: 0.424, green: 0.424, blue: 0.424, alpha: 1) - static let tertiary = UIColor.white - } - - struct State { - static let warning = UIColor(rgb: 0xFD4256) - static let information = UIColor(red: 0, green: 0.494, blue: 0.659, alpha: 1) - static let disabled = UIColor(rgb: 0xDEDED9) - } - - struct Icon { - static let primary = UIColor(red: 0.059, green: 0.059, blue: 0.059, alpha: 1) - static let secondary = UIColor(rgb: 0x007508) - static let decorative = UIColor(red: 0.424, green: 0.424, blue: 0.424, alpha: 1) - } - - struct Brand { - static let primary = UIColor(red: 0, green: 0.5, blue: 0.033, alpha: 1) - } - - static let border = UIColor(rgb: 0xDEDED9) - } - - struct Dark { - struct Background { - static let primary = UIColor(red: 0.1, green: 0.1, blue: 0.1, alpha: 1) - static let secondary = UIColor(rgb: 0x252525) - static let tertiary = UIColor(rgb: 0x333333) - static let quarternary = UIColor(rgb: 0xAFE9B0) - static let highlighted = UIColor(rgb: 0x577568) - } - - struct Button { - static let primary = UIColor(red: 0.365, green: 0.824, blue: 0.369, alpha: 1) - static let primaryActive = UIColor(rgb: 0x008009) - static let secondary = UIColor(rgb: 0x333333) - static let secondaryContent = UIColor.white - static let secondaryBackground = UIColor(rgb: 0x252525) - static let activeTransparentBackground = UIColor(rgb: 0xDEDED9).withAlphaComponent(0.32) - } - - struct Text { - static let primary = UIColor.white - static let secondary = UIColor(red: 0.871, green: 0.871, blue: 0.851, alpha: 1) - static let tertiary = UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 1) - } - - struct State { - static let warning = UIColor(rgb: 0xFF8A8C) - static let information = UIColor(red: 0.589, green: 0.839, blue: 0.973, alpha: 1) - static let disabled = UIColor(rgb: 0x6C6C6C) - } - - struct Brand { - static let primary = UIColor(red: 0.365, green: 0.824, blue: 0.369, alpha: 1) - } - - struct Icon { - static let primary = UIColor.white - static let secondary = UIColor(rgb: 0x5DD25E) - static let decorative = UIColor(red: 0.871, green: 0.871, blue: 0.871, alpha: 1) - } - - static let border = UIColor(rgb: 0x4C4C4C) - } - - struct Grey { - static let fifty = UIColor(red: 0.35, green: 0.35, blue: 0.35, alpha: 1) - } -} diff --git a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaColor.swift b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaColor.swift new file mode 100644 index 000000000000..990913d6e676 --- /dev/null +++ b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaColor.swift @@ -0,0 +1,71 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import UIKit + +// This class contains all of Ecosia official primitive color tokens referenced in the link below. +// https://www.figma.com/design/8T2rTBVwynJKSdY6MQo5PQ/%E2%9A%9B%EF%B8%8F--Foundations?node-id=1239-9385&t=UKHtrxcc9UtOihsm-4 +// You should never call those colors directly, they should only be called from a theme within the theme manager. +// This is the equivalent to Firefox's `FXColors`. +struct EcosiaColor { + // MARK: - Black & White + static let Black = UIColor(rgb: 0x000000) + static let White = UIColor(rgb: 0xFFFFFF) + + // MARK: - Neutral + static let Gray10 = UIColor(rgb: 0xF8F8F6) + static let Gray20 = UIColor(rgb: 0xF0F0EB) + static let Gray30 = UIColor(rgb: 0xDEDED9) + static let Gray40 = UIColor(rgb: 0xBEBEB9) + static let Gray50 = UIColor(rgb: 0x6C6C6C) + static let Gray60 = UIColor(rgb: 0x4C4C4C) + static let Gray70 = UIColor(rgb: 0x333333) + static let Gray80 = UIColor(rgb: 0x252525) + static let Gray90 = UIColor(rgb: 0x1A1A1A) + + // MARK: - Green + static let Green10 = UIColor(rgb: 0xCFF2D0) + static let Green20 = UIColor(rgb: 0xAFE9B0) + static let Green30 = UIColor(rgb: 0x5DD25E) + static let Green40 = UIColor(rgb: 0xA4D24F) + static let Green50 = UIColor(rgb: 0x008009) + static let Green60 = UIColor(rgb: 0x007508) + static let Green70 = UIColor(rgb: 0x006600) + + // MARK: - Dark Green + static let DarkGreen30 = UIColor(rgb: 0x668A7A) + static let DarkGreen50 = UIColor(rgb: 0x275243) + static let DarkGreen70 = UIColor(rgb: 0x09281D) + static let DarkGreen800 = UIColor(rgb: 0x18362B) + + // MARK: - Light Green + static let LightGreen20 = UIColor(rgb: 0xBACC80) + static let LightGreen30 = UIColor(rgb: 0xD8FF80) + static let LightGreen40 = UIColor(rgb: 0xA4D24F) + static let LightGreen50 = UIColor(rgb: 0x72A11A) + static let LightGreen60 = UIColor(rgb: 0x40521F) + + // MARK: - Red + static let Red20 = UIColor(rgb: 0xFFE8DA) + static let Red30 = UIColor(rgb: 0xFF8A8C) + static let Red40 = UIColor(rgb: 0xFD4256) + static let Red50 = UIColor(rgb: 0xAF1731) + + // MARK: - Yellow + static let Yellow40 = UIColor(rgb: 0xF7BC00) + static let Yellow50 = UIColor(rgb: 0xD6A300) + + // MARK: - Blue + static let Blue30 = UIColor(rgb: 0x96D6F8) + static let Blue40 = UIColor(rgb: 0x0094C7) + static let Blue50 = UIColor(rgb: 0x007EA8) + static let Blue60 = UIColor(rgb: 0x005D87) + static let Blue70 = UIColor(rgb: 0x004687) + static let Blue80 = UIColor(rgb: 0x002A3D) + + // MARK: - Peach + static let Peach30 = UIColor(rgb: 0xFFE6BF) + static let Peach40 = UIColor(rgb: 0xFFAF87) + static let Peach50 = UIColor(rgb: 0xCA8461) +} diff --git a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaDarkTheme.swift b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaDarkTheme.swift new file mode 100644 index 000000000000..7031a65a86f4 --- /dev/null +++ b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaDarkTheme.swift @@ -0,0 +1,65 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import Common +import UIKit + +public struct EcosiaDarkTheme: Theme { + public var type: ThemeType = .dark + public var colors: EcosiaThemeColourPalette = EcosiaDarkColourPalette() +} + +private class EcosiaDarkColourPalette: EcosiaLightColourPalette { + override var ecosia: EcosiaSemanticColors { + EcosiaDarkSemanticColors() + } + + override var fallbackTheme: Theme { + DarkTheme() + } +} + +private struct EcosiaDarkSemanticColors: EcosiaSemanticColors { + var backgroundPrimary: UIColor = EcosiaColor.Gray90 + var backgroundSecondary: UIColor = EcosiaColor.Gray80 + var backgroundTertiary: UIColor = EcosiaColor.Gray70 + var backgroundQuaternary: UIColor = EcosiaColor.Green20 + var borderDecorative: UIColor = EcosiaColor.Gray60 + var brandPrimary: UIColor = EcosiaColor.Green30 + var buttonBackgroundPrimary: UIColor = EcosiaColor.Green30 + var buttonBackgroundPrimaryActive: UIColor = EcosiaColor.Green50 // ⚠️ Mismatch + var buttonBackgroundSecondary: UIColor = EcosiaColor.Gray70 // ⚠️ Mismatch + var buttonBackgroundSecondaryHover: UIColor = EcosiaColor.Gray70 + var buttonContentSecondary: UIColor = EcosiaColor.White + var buttonBackgroundTransparentActive: UIColor = EcosiaColor.Gray30.withAlphaComponent(0.32) + var backgroundHighlighted: UIColor = EcosiaColor.DarkGreen30 + var iconPrimary: UIColor = EcosiaColor.White + var iconSecondary: UIColor = EcosiaColor.Green30 + var iconDecorative: UIColor = EcosiaColor.Gray40 // ⚠️ Mismatch + var stateError: UIColor = EcosiaColor.Red30 + var stateInformation: UIColor = EcosiaColor.Blue30 // ⚠️ No match + var stateDisabled: UIColor = EcosiaColor.Gray50 + var textPrimary: UIColor = EcosiaColor.White + var textInversePrimary: UIColor = EcosiaColor.Black // ⚠️ Mismatch + var textSecondary: UIColor = EcosiaColor.Gray30 + var textTertiary: UIColor = EcosiaColor.Gray70 // ⚠️ Mismatch + + // MARK: Unmapped Snowflakes + var barBackground: UIColor = EcosiaColor.Gray80 + var barSeparator: UIColor = .Photon.Grey60 + var ntpCellBackground: UIColor = EcosiaColor.Gray70 + var ntpBackground: UIColor = EcosiaColor.Gray90 + var ntpIntroBackground: UIColor = EcosiaColor.Gray80 + var impactMultiplyCardBackground: UIColor = EcosiaColor.Gray70 + var newsPlaceholder: UIColor = EcosiaColor.Gray50 + var modalBackground: UIColor = EcosiaColor.Gray80 + var secondarySelectedBackground: UIColor = .init(rgb: 0x3A3A3A) + var buttonBackgroundNTPCustomization: UIColor = EcosiaColor.Gray80 + var privateButtonBackground: UIColor = EcosiaColor.White + var tabSelectedPrivateBackground: UIColor = EcosiaColor.White + var toastImageTint: UIColor = EcosiaColor.DarkGreen50 + var newSeedCollectedCircle: UIColor = .init(rgb: 0xCC7722) + var tabTrayScreenshotBackground: UIColor = .Photon.DarkGrey30 + var tableViewRowText: UIColor = .Photon.Grey10 +} diff --git a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaThemeColourPalette.swift b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaLightTheme.swift similarity index 50% rename from firefox-ios/Client/Ecosia/UI/Theme/EcosiaThemeColourPalette.swift rename to firefox-ios/Client/Ecosia/UI/Theme/EcosiaLightTheme.swift index fbe3dc8648aa..1f3337827902 100644 --- a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaThemeColourPalette.swift +++ b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaLightTheme.swift @@ -2,82 +2,48 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/ -/* - -The purpose of this file is to build an adapter layer and begin to utilize the `ThemeColourPalette` that Firefox provide. -WHY? -In the previous releases of Firefox the theming architecture relied on a protocol approach without any sort of dependency injection as part of the `applyTheme()` function. - However, since the codebase bigger restructure, the Theming has gone thru a major refactor as well. - By having this adapter in, we can benefit of the `Theme` object being passed as part of the `func applyTheme(theme: Theme)` function so that all the places having it implemented will receive the new colors. - The setup of these Dark and Light Ecosia's Colour Palette is definted by the `EcosiaThemeManager`. - However, the need of a `fallbackDefaultThemeManager` of type `DefaultThemeManager` is crucial as we don't have all the colors defined ourselves and we rely on the Firefox ones we can't get access to as part of the `BrowserKit` package. - Once and if we'll have all the colors defined, we can remove the `fallbackDefaultThemeManager` variable. -*/ - import Common import UIKit -public struct EcosiaLightTheme: Theme { +struct EcosiaLightTheme: Theme { public var type: ThemeType = .light - public var colors: ThemeColourPalette = EcosiaLightColourPalette() -} - -public struct EcosiaDarkTheme: Theme { - public var type: ThemeType = .dark - public var colors: ThemeColourPalette = EcosiaDarkColourPalette() + public var colors: EcosiaThemeColourPalette = EcosiaLightColourPalette() } -private class EcosiaDarkColourPalette: EcosiaLightColourPalette { - - override var fallbackTheme: Theme { - DarkTheme() +class EcosiaLightColourPalette: EcosiaThemeColourPalette { + var ecosia: EcosiaSemanticColors { + EcosiaLightSemanticColors() } - override var layer1: UIColor { .legacyTheme.ecosia.primaryBackground } -} - -private class EcosiaLightColourPalette: ThemeColourPalette { - - // TODO Ecosia Upgrade: Review new colors and older ones that are no longer on the protocol [MOB-3152] - var layerInformation: UIColor { fallbackTheme.colors.layerInformation } - var layerSuccess: UIColor { fallbackTheme.colors.layerSuccess } - var layerCritical: UIColor { fallbackTheme.colors.layerCritical } - var layerSelectedText: UIColor { fallbackTheme.colors.layerSelectedText } - var layerAutofillText: UIColor { fallbackTheme.colors.layerAutofillText } - var actionPrimaryDisabled: UIColor { fallbackTheme.colors.actionPrimaryDisabled } - var actionSuccess: UIColor { fallbackTheme.colors.actionSuccess } - var actionCritical: UIColor { fallbackTheme.colors.actionCritical } - var actionInformation: UIColor { fallbackTheme.colors.actionInformation } - var textCritical: UIColor { fallbackTheme.colors.textCritical } - var textInvertedDisabled: UIColor { fallbackTheme.colors.textInvertedDisabled } - var iconAccent: UIColor { fallbackTheme.colors.iconAccent } - var iconCritical: UIColor { fallbackTheme.colors.iconCritical } - var iconRatingNeutral: UIColor { fallbackTheme.colors.iconRatingNeutral } - - /* TODO Ecosia Upgrade: Review if ok to switch to directly linking fallback theme. [MOB-3152] - // The alternative is receiving window here since `getCurrentTheme` now requires it. - let fallbackDefaultThemeManager: ThemeManager = DefaultThemeManager(sharedContainerIdentifier: AppInfo.sharedContainerIdentifier) - */ var fallbackTheme: Theme { LightTheme() } // MARK: - Layers - var layer1: UIColor { .legacyTheme.ecosia.tertiaryBackground } + var layer1: UIColor { ecosia.ntpBackground } var layer2: UIColor { fallbackTheme.colors.layer2 } - var layer3: UIColor { .legacyTheme.ecosia.ntpBackground } + var layer3: UIColor { ecosia.ntpBackground } var layer4: UIColor { fallbackTheme.colors.layer4 } - var layer5: UIColor { .legacyTheme.ecosia.secondaryBackground } - var layer6: UIColor { .legacyTheme.ecosia.homePanelBackground } - var layer5Hover: UIColor { .legacyTheme.ecosia.secondarySelectedBackground } + var layer5: UIColor { ecosia.backgroundSecondary } + var layer5Hover: UIColor { ecosia.secondarySelectedBackground } var layerScrim: UIColor { fallbackTheme.colors.layerScrim } - var layerGradient: Common.Gradient { fallbackTheme.colors.layerGradient } - var layerGradientOverlay: Common.Gradient { fallbackTheme.colors.layerGradientOverlay } - var layerAccentNonOpaque: UIColor { .legacyTheme.ecosia.primaryButton } + var layerGradient: Gradient { fallbackTheme.colors.layerGradient } + var layerGradientOverlay: Gradient { fallbackTheme.colors.layerGradientOverlay } + var layerAccentNonOpaque: UIColor { ecosia.buttonBackgroundPrimary } var layerAccentPrivate: UIColor { fallbackTheme.colors.layerAccentPrivate } - var layerAccentPrivateNonOpaque: UIColor { .legacyTheme.ecosia.primaryText } + var layerAccentPrivateNonOpaque: UIColor { ecosia.textPrimary } var layerSepia: UIColor { fallbackTheme.colors.layerSepia } - var layerWarning: UIColor { .legacyTheme.ecosia.warning } + var layerHomepage: Gradient { fallbackTheme.colors.layerHomepage } + var layerInformation: UIColor { fallbackTheme.colors.layerInformation } + var layerSuccess: UIColor { fallbackTheme.colors.layerSuccess } + var layerWarning: UIColor { ecosia.stateError } + var layerCritical: UIColor { fallbackTheme.colors.layerCritical } + var layerSelectedText: UIColor { fallbackTheme.colors.layerSelectedText } + var layerAutofillText: UIColor { fallbackTheme.colors.layerAutofillText } + var layerSearch: UIColor { fallbackTheme.colors.layerSearch } + var layerGradientURL: Gradient { fallbackTheme.colors.layerGradientURL } + + // MARK: - Ratings var layerRatingA: UIColor { fallbackTheme.colors.layerRatingA } var layerRatingASubdued: UIColor { fallbackTheme.colors.layerRatingASubdued } var layerRatingB: UIColor { fallbackTheme.colors.layerRatingB } @@ -88,53 +54,102 @@ private class EcosiaLightColourPalette: ThemeColourPalette { var layerRatingDSubdued: UIColor { fallbackTheme.colors.layerRatingDSubdued } var layerRatingF: UIColor { fallbackTheme.colors.layerRatingF } var layerRatingFSubdued: UIColor { fallbackTheme.colors.layerRatingFSubdued } - var layerHomepage: Common.Gradient { fallbackTheme.colors.layerHomepage } - var layerSearch: UIColor { fallbackTheme.colors.layerSearch } - var layerGradientURL: Common.Gradient { fallbackTheme.colors.layerGradientURL } - var actionTabActive: UIColor { fallbackTheme.colors.actionTabActive } - var actionTabInactive: UIColor { fallbackTheme.colors.actionTabInactive } - var borderToolbarDivider: UIColor { fallbackTheme.colors.borderToolbarDivider } // MARK: - Actions - var actionPrimary: UIColor { .legacyTheme.ecosia.primaryButton } - var actionPrimaryHover: UIColor { .legacyTheme.ecosia.primaryButtonActive } - var actionSecondary: UIColor { .legacyTheme.ecosia.secondaryButton } + var actionPrimary: UIColor { ecosia.buttonBackgroundPrimary } + var actionPrimaryHover: UIColor { ecosia.buttonBackgroundPrimaryActive } + var actionPrimaryDisabled: UIColor { fallbackTheme.colors.actionPrimaryDisabled } + var actionSecondary: UIColor { ecosia.buttonBackgroundSecondary } var actionSecondaryHover: UIColor { fallbackTheme.colors.actionSecondaryHover } var formSurfaceOff: UIColor { fallbackTheme.colors.formSurfaceOff } var formKnob: UIColor { fallbackTheme.colors.formKnob } var indicatorActive: UIColor { fallbackTheme.colors.indicatorActive } var indicatorInactive: UIColor { fallbackTheme.colors.indicatorInactive } - var actionWarning: UIColor { .legacyTheme.ecosia.warning } + var actionSuccess: UIColor { fallbackTheme.colors.actionSuccess } + var actionWarning: UIColor { ecosia.stateError } + var actionCritical: UIColor { fallbackTheme.colors.actionCritical } + var actionInformation: UIColor { fallbackTheme.colors.actionInformation } + var actionTabActive: UIColor { fallbackTheme.colors.actionTabActive } + var actionTabInactive: UIColor { fallbackTheme.colors.actionTabInactive } // MARK: - Text - var textPrimary: UIColor { .legacyTheme.ecosia.primaryText } - var textSecondary: UIColor { .legacyTheme.ecosia.secondaryText } + var textPrimary: UIColor { ecosia.textPrimary } + var textSecondary: UIColor { ecosia.textSecondary } var textDisabled: UIColor { fallbackTheme.colors.textDisabled } - var textAccent: UIColor { .legacyTheme.ecosia.primaryButton } + var textCritical: UIColor { fallbackTheme.colors.textCritical } + var textAccent: UIColor { ecosia.buttonBackgroundPrimary } var textOnDark: UIColor { fallbackTheme.colors.textOnDark } var textOnLight: UIColor { fallbackTheme.colors.textOnLight } - var textInverted: UIColor { .legacyTheme.ecosia.primaryTextInverted } + var textInverted: UIColor { ecosia.textInversePrimary } + var textInvertedDisabled: UIColor { fallbackTheme.colors.textInvertedDisabled } // MARK: - Icons - var iconPrimary: UIColor { .legacyTheme.ecosia.primaryIcon } - var iconSecondary: UIColor { .legacyTheme.ecosia.secondaryIcon } + var iconPrimary: UIColor { ecosia.iconPrimary } + var iconSecondary: UIColor { ecosia.iconSecondary } var iconDisabled: UIColor { fallbackTheme.colors.iconDisabled } + var iconAccent: UIColor { fallbackTheme.colors.iconAccent } var iconOnColor: UIColor { fallbackTheme.colors.iconOnColor } - var iconWarning: UIColor { .legacyTheme.ecosia.warning } + var iconCritical: UIColor { ecosia.stateError } var iconSpinner: UIColor { fallbackTheme.colors.iconSpinner } var iconAccentViolet: UIColor { fallbackTheme.colors.iconAccentViolet } var iconAccentBlue: UIColor { fallbackTheme.colors.iconAccentBlue } var iconAccentPink: UIColor { fallbackTheme.colors.iconAccentPink } var iconAccentGreen: UIColor { fallbackTheme.colors.iconAccentGreen } var iconAccentYellow: UIColor { fallbackTheme.colors.iconAccentYellow } + var iconRatingNeutral: UIColor { fallbackTheme.colors.iconRatingNeutral } // MARK: - Border - var borderPrimary: UIColor { .legacyTheme.ecosia.barSeparator } + var borderPrimary: UIColor { ecosia.barSeparator } var borderAccent: UIColor { actionPrimary } var borderAccentNonOpaque: UIColor { actionPrimary } var borderAccentPrivate: UIColor { actionPrimary } var borderInverted: UIColor { fallbackTheme.colors.borderInverted } + var borderToolbarDivider: UIColor { fallbackTheme.colors.borderToolbarDivider } // MARK: - Shadow var shadowDefault: UIColor { fallbackTheme.colors.shadowDefault } } + +private struct EcosiaLightSemanticColors: EcosiaSemanticColors { + var backgroundPrimary: UIColor = EcosiaColor.White + var backgroundSecondary: UIColor = EcosiaColor.Gray10 + var backgroundTertiary: UIColor = EcosiaColor.Gray20 + var backgroundQuaternary: UIColor = EcosiaColor.DarkGreen50 + var borderDecorative: UIColor = EcosiaColor.Gray30 + var brandPrimary: UIColor = EcosiaColor.Green50 + var buttonBackgroundPrimary: UIColor = EcosiaColor.Green50 + var buttonBackgroundPrimaryActive: UIColor = EcosiaColor.Green70 // ⚠️ Mismatch + var buttonBackgroundSecondary: UIColor = EcosiaColor.White + var buttonBackgroundSecondaryHover: UIColor = EcosiaColor.Gray10 // ⚠️ Mismatch + var buttonContentSecondary: UIColor = EcosiaColor.Gray70 + var buttonBackgroundTransparentActive: UIColor = EcosiaColor.Green70.withAlphaComponent(0.24) + var backgroundHighlighted: UIColor = EcosiaColor.Green10 + var iconPrimary: UIColor = EcosiaColor.Black // ⚠️ Mismatch + var iconSecondary: UIColor = EcosiaColor.Green60 // ⚠️ Mismatch + var iconDecorative: UIColor = EcosiaColor.Gray50 + var stateError: UIColor = EcosiaColor.Red40 + var stateInformation: UIColor = EcosiaColor.Blue50 // ⚠️ No match + var stateDisabled: UIColor = EcosiaColor.Gray30 + var textPrimary: UIColor = EcosiaColor.Black // ⚠️ Mismatch + var textInversePrimary: UIColor = EcosiaColor.White + var textSecondary: UIColor = EcosiaColor.Gray50 + var textTertiary: UIColor = EcosiaColor.White + + // MARK: Unmapped Snowflakes + var barBackground: UIColor = EcosiaColor.White + var barSeparator: UIColor = .Photon.Grey20 + var ntpCellBackground: UIColor = EcosiaColor.White + var ntpBackground: UIColor = EcosiaColor.Gray20 + var ntpIntroBackground: UIColor = EcosiaColor.White + var impactMultiplyCardBackground: UIColor = EcosiaColor.White + var newsPlaceholder: UIColor = EcosiaColor.Gray10 + var modalBackground: UIColor = EcosiaColor.Gray20 + var secondarySelectedBackground: UIColor = EcosiaColor.Gray10 + var buttonBackgroundNTPCustomization: UIColor = EcosiaColor.Gray10 + var privateButtonBackground: UIColor = .Photon.Grey70 + var tabSelectedPrivateBackground: UIColor = EcosiaColor.Gray80 + var toastImageTint: UIColor = EcosiaColor.LightGreen30 + var newSeedCollectedCircle: UIColor = EcosiaColor.Peach30 + var tabTrayScreenshotBackground: UIColor = EcosiaColor.White + var tableViewRowText: UIColor = .Photon.Grey90 +} diff --git a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaTheme.swift b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaTheme.swift deleted file mode 100644 index bfec7cb8629e..000000000000 --- a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaTheme.swift +++ /dev/null @@ -1,211 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import UIKit -import Common - -extension LegacyTheme { - var isDark: Bool { - return type(of: self) == DarkTheme.self - } -} - -class EcosiaTheme { - var primaryBrand: UIColor { .Light.Brand.primary} - var secondaryBrand: UIColor { UIColor.Photon.Grey60 } - var border: UIColor { .Light.border } - - var primaryBackground: UIColor { .Light.Background.primary } - var secondaryBackground: UIColor { .Light.Background.secondary } - var tertiaryBackground: UIColor { .Light.Background.tertiary } - var quarternaryBackground: UIColor { .Light.Background.quarternary } - var barBackground: UIColor { .white } - var barSeparator: UIColor { UIColor.Photon.Grey20 } - var impactBackground: UIColor { .Light.Background.primary } - var impactSeparator: UIColor { UIColor.Photon.Grey40 } - var treeCounterProgressTotal: UIColor { .Light.Background.tertiary } - var treeCounterProgressCurrent: UIColor { .Light.Brand.primary } - var treeCounterProgressBorder: UIColor { .Light.Background.tertiary } - - var ntpCellBackground: UIColor { .Light.Background.primary } - var ntpBackground: UIColor { .Light.Background.tertiary } - var ntpIntroBackground: UIColor { .Light.Background.primary } - var ntpImpactBackground: UIColor { .Light.Background.primary } - - var impactMultiplyCardBackground: UIColor { .Light.Background.primary } - var trackingSheetBackground: UIColor { .Light.Background.tertiary } - var moreNewsButton: UIColor { .Light.Button.secondary } - var newsPlaceholder: UIColor { .Light.Background.secondary } - - var actionSheetBackground: UIColor { .Light.Background.primary } - var actionSheetCancelButton: UIColor { .Light.Button.primaryActive } - var modalBackground: UIColor { .Light.Background.tertiary } - var modalHeader: UIColor { .init(red: 0.153, green: 0.322, blue: 0.263, alpha: 1) } - - var whatsNewCloseButton: UIColor { .Light.Text.primary } - - var primaryText: UIColor { .Light.Text.primary } - var primaryTextInverted: UIColor { .Dark.Text.primary } - var secondaryText: UIColor { .Light.Text.secondary } - var navigationBarText: UIColor { .Light.Text.primary } - var tertiaryText: UIColor { .Light.Text.tertiary } - - var primaryIcon: UIColor { .Light.Icon.primary } - var secondaryIcon: UIColor { .Light.Icon.secondary } - var decorativeIcon: UIColor { .Light.Icon.decorative } - - var highlightedBackground: UIColor { .Light.Background.highlighted } - var primarySelectedBackground: UIColor { .Light.Background.secondary } - var secondarySelectedBackground: UIColor { .Light.Background.secondary } - - var primaryButton: UIColor { .Light.Button.primary } - var primaryButtonActive: UIColor { .Light.Button.primaryActive } - var secondaryButton: UIColor { .Light.Button.secondary } - var secondaryButtonContent: UIColor { .Light.Button.secondaryContent } - var secondaryButtonBackground: UIColor { .Light.Button.secondaryBackground } - var activeTransparentBackground: UIColor { .Light.Button.activeTransparentBackground } - - var textfieldPlaceholder: UIColor { .Light.Text.secondary } - var textfieldIconTint: UIColor { .Light.Button.primary } - var personalCounterSelection: UIColor { UIColor.Photon.Grey20 } - var privateButtonBackground: UIColor { UIColor.Photon.Grey70 } - - var modalOverlayBackground: UIColor { UIColor(rgb: 0x333333).withAlphaComponent(0.4) } - - var segmentSelectedText: UIColor { .Light.Text.primary } - var segmentBackground: UIColor { .Light.Background.secondary } - - var warning: UIColor { .Light.State.warning } - var information: UIColor { .Light.State.information } - var disabled: UIColor { .Light.State.disabled } - - var tabBackground: UIColor { .Light.Background.primary } - var tabSelectedBackground: UIColor { .Light.Button.primary } - var tabSelectedPrivateBackground: UIColor { .Dark.Background.secondary } - - var toastImageTint: UIColor { .init(red: 0.847, green: 1, blue: 0.502, alpha: 1) } - var autocompleteBackground: UIColor { .Light.Background.primary } - var welcomeBackground: UIColor { .Light.Background.tertiary } - var welcomeElementBackground: UIColor { .Light.Background.primary } - - var homePanelBackground: UIColor { return .Light.Background.tertiary } - var peach: UIColor { .init(rgb: 0xFFE6BF) } -} - -final class DarkEcosiaTheme: EcosiaTheme { - override var primaryBrand: UIColor { .Dark.Brand.primary} - override var secondaryBrand: UIColor { .white } - override var border: UIColor { .Dark.border } - - override var primaryBackground: UIColor { .Dark.Background.primary } - override var secondaryBackground: UIColor { .Dark.Background.secondary } - override var tertiaryBackground: UIColor { .Dark.Background.tertiary } - override var quarternaryBackground: UIColor { .Dark.Background.quarternary } - override var barBackground: UIColor { .Dark.Background.secondary } - override var barSeparator: UIColor { UIColor.Photon.Grey60 } - override var impactBackground: UIColor { .Dark.Background.tertiary } - override var impactSeparator: UIColor { UIColor.Photon.Grey60 } - override var treeCounterProgressTotal: UIColor { .Dark.Background.secondary } - override var treeCounterProgressCurrent: UIColor { .Dark.Brand.primary } - override var treeCounterProgressBorder: UIColor { .Dark.Background.tertiary } - - override var ntpCellBackground: UIColor { .Dark.Background.tertiary } - override var ntpBackground: UIColor { .Dark.Background.primary } - override var ntpImpactBackground: UIColor { .Dark.Background.secondary} - override var ntpIntroBackground: UIColor { .Dark.Background.tertiary } - - override var impactMultiplyCardBackground: UIColor { .Dark.Background.tertiary } - override var trackingSheetBackground: UIColor { .Dark.Background.secondary } - override var moreNewsButton: UIColor { .Dark.Background.primary } - override var newsPlaceholder: UIColor { .Grey.fifty } - - override var actionSheetBackground: UIColor { .Dark.Background.secondary } - override var actionSheetCancelButton: UIColor { .Dark.Button.primaryActive } - override var modalBackground: UIColor { .Dark.Background.secondary } - override var modalHeader: UIColor { .Dark.Background.secondary } - - override var whatsNewCloseButton: UIColor { .white } - - override var primaryText: UIColor { .Dark.Text.primary} - override var primaryTextInverted: UIColor { .Light.Text.primary } - override var secondaryText: UIColor { .Dark.Text.secondary } - override var navigationBarText: UIColor { .Dark.Text.primary } - override var tertiaryText: UIColor { .Dark.Text.tertiary } - - override var primaryIcon: UIColor { .Dark.Icon.primary } - override var secondaryIcon: UIColor { .Dark.Icon.secondary } - override var decorativeIcon: UIColor { .Dark.Icon.decorative } - - override var highlightedBackground: UIColor { .Dark.Background.highlighted } - - override var primarySelectedBackground: UIColor { .Dark.Background.tertiary } - override var secondarySelectedBackground: UIColor { .init(red: 0.227, green: 0.227, blue: 0.227, alpha: 1) } - - override var primaryButton: UIColor { .Dark.Button.primary } - override var primaryButtonActive: UIColor { .Dark.Button.primaryActive } - override var secondaryButton: UIColor { .Dark.Button.secondary } - override var secondaryButtonContent: UIColor { .Dark.Button.secondaryContent } - override var secondaryButtonBackground: UIColor { .Dark.Button.secondaryBackground } - override var activeTransparentBackground: UIColor { .Dark.Button.activeTransparentBackground } - - override var textfieldPlaceholder: UIColor { .Dark.Text.secondary } - override var textfieldIconTint: UIColor { .Dark.Button.primary } - - override var personalCounterSelection: UIColor { UIColor.Photon.Grey60 } - override var privateButtonBackground: UIColor { .white } - - override var modalOverlayBackground: UIColor { UIColor(rgb: 0x333333).withAlphaComponent(0.6) } - - override var segmentSelectedText: UIColor { UIColor.Photon.Grey90 } - override var segmentBackground: UIColor { .Dark.Background.tertiary } - - override var warning: UIColor { .Dark.State.warning } - override var information: UIColor { .Dark.State.information } - override var disabled: UIColor { .Dark.State.disabled } - - override var tabBackground: UIColor { .Dark.Background.tertiary } - override var tabSelectedBackground: UIColor { .Dark.Button.primary } - override var tabSelectedPrivateBackground: UIColor { .white} - - override var toastImageTint: UIColor { .init(red: 0.153, green: 0.322, blue: 0.263, alpha: 1) } - override var autocompleteBackground: UIColor { .Dark.Background.secondary } - override var welcomeBackground: UIColor { .Dark.Background.secondary } - override var welcomeElementBackground: UIColor { .Dark.Background.secondary } - - override var homePanelBackground: UIColor { return .Dark.Background.secondary } - override var peach: UIColor { .init(rgb: 0xCC7722) } -} - -extension UIImage { - convenience init?(themed name: String) { - let suffix = LegacyThemeManager.instance.current.isDark ? "Dark" : "" - self.init(named: name + suffix) - } -} - -class EcosiaPrimaryButton: UIButton { - override var isSelected: Bool { - get { - return super.isSelected - } - set { - super.isSelected = newValue - update() - } - } - - override var isHighlighted: Bool { - get { - return super.isHighlighted - } - set { - super.isHighlighted = newValue - update() - } - } - - private func update() { - backgroundColor = (isSelected || isHighlighted) ? .legacyTheme.ecosia.primaryButtonActive : .legacyTheme.ecosia.primaryButton - } -} diff --git a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaThemeManager.swift b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaThemeManager.swift index 2a29f26301e9..709e0ec05b14 100644 --- a/firefox-ios/Client/Ecosia/UI/Theme/EcosiaThemeManager.swift +++ b/firefox-ios/Client/Ecosia/UI/Theme/EcosiaThemeManager.swift @@ -194,30 +194,12 @@ public final class EcosiaThemeManager: ThemeManager, Notifiable { case .dark: return EcosiaDarkTheme() case .nightMode: - return EcosiaDarkTheme() // TODO Ecosia Upgrade: Is this what we want? [MOB-3152] + return EcosiaDarkTheme() case .privateMode: return EcosiaLightTheme() } } - // TODO Ecosia Upgrade: Is migration still needed? [MOB-3152] - private func migrateDefaultsToUseStandard() { - guard let oldDefaultsStore = UserDefaults(suiteName: sharedContainerIdentifier) else { return } - - if let systemThemeIsOn = oldDefaultsStore.value(forKey: ThemeKeys.systemThemeIsOn) { - userDefaults.set(systemThemeIsOn, forKey: ThemeKeys.systemThemeIsOn) - } - if let nightModeIsOn = oldDefaultsStore.value(forKey: ThemeKeys.NightMode.isOn) { - userDefaults.set(nightModeIsOn, forKey: ThemeKeys.NightMode.isOn) - } - if let automaticBrightnessIsOn = oldDefaultsStore.value(forKey: ThemeKeys.AutomaticBrightness.isOn) { - userDefaults.set(automaticBrightnessIsOn, forKey: ThemeKeys.AutomaticBrightness.isOn) - } - if let automaticBrighnessValue = oldDefaultsStore.value(forKey: ThemeKeys.AutomaticBrightness.thresholdValue) { - userDefaults.set(automaticBrighnessValue, forKey: ThemeKeys.AutomaticBrightness.thresholdValue) - } - } - // MARK: - Notifiable public func handleNotifications(_ notification: Notification) { @@ -230,14 +212,3 @@ public final class EcosiaThemeManager: ThemeManager, Notifiable { } } } - -/* TODO Ecosia Upgrade: Is this still needed? [MOB-3152] -extension EcosiaThemeManager { - - func updateLegacyThemeIfSystemThemeON() { - if LegacyThemeManager.instance.systemThemeIsOn { - LegacyThemeManager.updateBasedOnCurrentSystemThemeType() - } - } -} -*/ diff --git a/firefox-ios/Client/Ecosia/UI/Theme/SemanticColor.swift b/firefox-ios/Client/Ecosia/UI/Theme/SemanticColor.swift new file mode 100644 index 000000000000..7bcb757ec373 --- /dev/null +++ b/firefox-ios/Client/Ecosia/UI/Theme/SemanticColor.swift @@ -0,0 +1,108 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/ + +import UIKit + +// TODO: Remove this file once migrated to `EcosiaSemanticColors` inside `EcosiaThemeColourPalette` + +// This file contains all of Ecosia official semantic color tokens referenced in the link below. +// https://www.figma.com/design/8T2rTBVwynJKSdY6MQo5PQ/%E2%9A%9B%EF%B8%8F--Foundations?node-id=2237-3418&t=UKHtrxcc9UtOihsm-0 +// They should use `EcosiaColorPrimitives` and should be called from a theme within the theme manager. +extension UIColor { + struct Light { + struct Background { + static let primary = EcosiaColor.White + static let secondary = EcosiaColor.Gray10 + static let tertiary = EcosiaColor.Gray20 + static let quarternary = EcosiaColor.DarkGreen50 + static let highlighted = EcosiaColor.Green10 // ⚠️ No match + } + + struct Brand { + static let primary = EcosiaColor.Green50 + } + + struct Border { + static let decorative = EcosiaColor.Gray30 + } + + struct Button { + static let backgroundPrimary = EcosiaColor.Green50 + static let backgroundPrimaryActive = EcosiaColor.Green70 // ⚠️ Mismatch + static let backgroundSecondary = EcosiaColor.White + static let backgroundSecondaryHover = EcosiaColor.Gray10 // ⚠️ Mismatch + static let contentSecondary = EcosiaColor.Gray70 + static let secondaryBackground = EcosiaColor.Gray10 // ⚠️ Mismatch & duplicate + static let backgroundTransparentActive = EcosiaColor.Green70.withAlphaComponent(0.24) + } + + struct Icon { + static let primary = EcosiaColor.Black // ⚠️ Mobile snowflake & mismatch + static let secondary = EcosiaColor.Green60 // ⚠️ Mobile snowflake & mismatch + static let decorative = EcosiaColor.Gray50 // ⚠️ Mobile snowflake + } + + struct State { + static let error = EcosiaColor.Red40 // ⚠️ Mobile snowflake + static let information = EcosiaColor.Blue50 // ⚠️ No match + static let disabled = EcosiaColor.Gray30 + } + + struct Text { + static let primary = EcosiaColor.Black // ⚠️ Mismatch + static let secondary = EcosiaColor.Gray50 + static let tertiary = EcosiaColor.White + } + } + + struct Dark { + struct Background { + static let primary = EcosiaColor.Gray90 + static let secondary = EcosiaColor.Gray80 + static let tertiary = EcosiaColor.Gray70 + static let quarternary = EcosiaColor.Green20 + static let highlighted = EcosiaColor.DarkGreen30 // ⚠️ No match + } + + struct Brand { + static let primary = EcosiaColor.Green30 + } + + struct Border { + static let decorative = EcosiaColor.Gray60 + } + + struct Button { + static let backgroundPrimary = EcosiaColor.Green30 + static let backgroundPrimaryActive = EcosiaColor.Green50 // ⚠️ Mismatch + static let backgroundSecondary = EcosiaColor.Gray70 // ⚠️ Mismatch + static let backgroundSecondaryHover = EcosiaColor.Gray70 + static let contentSecondary = EcosiaColor.White + static let secondaryBackground = EcosiaColor.Gray80 // ⚠️ Mismatch & duplicate + static let backgroundTransparentActive = EcosiaColor.Gray30.withAlphaComponent(0.32) + } + + struct Icon { + static let primary = EcosiaColor.White // ⚠️ Mobile snowflake + static let secondary = EcosiaColor.Green30 // ⚠️ Mobile snowflake + static let decorative = EcosiaColor.Gray40 // ⚠️ Mobile snowflake & mismatch + } + + struct State { + static let error = EcosiaColor.Red30 // ⚠️ Mobile snowflake + static let information = EcosiaColor.Blue30 // ⚠️ No match + static let disabled = EcosiaColor.Gray50 + } + + struct Text { + static let primary = EcosiaColor.White + static let secondary = EcosiaColor.Gray30 + static let tertiary = EcosiaColor.Gray70 // ⚠️ Mismatch + } + } + + struct Grey { + static let fifty = EcosiaColor.Gray50 + } +} diff --git a/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewCell.swift b/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewCell.swift index 7db7adf5ca49..4ed5dd48fc35 100644 --- a/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewCell.swift +++ b/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewCell.swift @@ -6,19 +6,13 @@ import UIKit import Core import Common -final class WhatsNewCell: UITableViewCell, Themeable { +final class WhatsNewCell: UITableViewCell { // MARK: - Properties private var item: WhatsNewItem! private var contentConfigurationToUpdate: Any? - // MARK: - Themeable Properties - - var themeManager: ThemeManager { AppContainer.shared.resolve() } - var themeObserver: NSObjectProtocol? - var notificationCenter: NotificationProtocol = NotificationCenter.default - // MARK: - Configuration func configure(with item: WhatsNewItem) { @@ -26,8 +20,6 @@ final class WhatsNewCell: UITableViewCell, Themeable { backgroundColor = .clear self.item = item configureBasedOnOSVersion() - applyTheme() - listenForThemeChange(contentView) } private func configureBasedOnOSVersion() { @@ -81,15 +73,15 @@ final class WhatsNewCell: UITableViewCell, Themeable { } } -extension WhatsNewCell { +extension WhatsNewCell: ThemeApplicable { - func applyTheme() { + func applyTheme(theme: Theme) { if #available(iOS 14, *) { guard var updatedConfiguration = contentConfigurationToUpdate as? UIListContentConfiguration else { return } - updatedConfiguration.image = item.image?.tinted(withColor: .legacyTheme.ecosia.secondaryIcon) + updatedConfiguration.image = item.image?.tinted(withColor: theme.colors.ecosia.iconSecondary) contentConfiguration = updatedConfiguration } else { - imageView?.image = item.image?.tinted(withColor: .legacyTheme.ecosia.secondaryIcon) + imageView?.image = item.image?.tinted(withColor: theme.colors.ecosia.iconSecondary) } } } diff --git a/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewViewController.swift b/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewViewController.swift index 20d9c81f6c91..5c618a6a39f6 100644 --- a/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewViewController.swift +++ b/firefox-ios/Client/Ecosia/UI/WhatsNew/WhatsNewViewController.swift @@ -68,14 +68,18 @@ final class WhatsNewViewController: UIViewController, Themeable { let windowUUID: WindowUUID var currentWindowUUID: WindowUUID? { return windowUUID } - var themeManager: ThemeManager { AppContainer.shared.resolve() } + var themeManager: ThemeManager var themeObserver: NSObjectProtocol? var notificationCenter: NotificationProtocol = NotificationCenter.default // MARK: - Init - init(viewModel: WhatsNewViewModel, delegate: WhatsNewViewDelegate?, windowUUID: WindowUUID) { + init(viewModel: WhatsNewViewModel, + delegate: WhatsNewViewDelegate?, + windowUUID: WindowUUID, + themeManager: ThemeManager = AppContainer.shared.resolve()) { self.windowUUID = windowUUID + self.themeManager = themeManager super.init(nibName: nil, bundle: nil) self.viewModel = viewModel self.delegate = delegate @@ -241,6 +245,7 @@ extension WhatsNewViewController: UITableViewDataSource { let cell = tableView.dequeueReusableCell(withIdentifier: WhatsNewCell.cellIdentifier, for: indexPath) as! WhatsNewCell let item = viewModel.items[indexPath.row] cell.configure(with: item) + cell.applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID)) return cell } } @@ -250,17 +255,18 @@ extension WhatsNewViewController: UITableViewDataSource { extension WhatsNewViewController { func applyTheme() { - view.backgroundColor = .legacyTheme.ecosia.primaryBackground - topContainerView.backgroundColor = .legacyTheme.ecosia.tertiaryBackground - tableView.backgroundColor = .legacyTheme.ecosia.primaryBackground + let theme = themeManager.getCurrentTheme(for: windowUUID) + view.backgroundColor = theme.colors.ecosia.backgroundPrimary + topContainerView.backgroundColor = theme.colors.ecosia.backgroundTertiary + tableView.backgroundColor = theme.colors.ecosia.backgroundPrimary tableView.separatorColor = .clear - knob.backgroundColor = .legacyTheme.ecosia.secondaryText - closeButton.backgroundColor = .legacyTheme.ecosia.primaryBackground - closeButton.tintColor = .legacyTheme.ecosia.whatsNewCloseButton - footerButton.backgroundColor = .legacyTheme.ecosia.primaryBrand - footerButton.setTitleColor(.legacyTheme.ecosia.primaryTextInverted, for: .normal) - headerLabelContainerView.backgroundColor = .legacyTheme.ecosia.primaryBackground - secondImageView.tintColor = .legacyTheme.ecosia.primaryBackground + knob.backgroundColor = theme.colors.ecosia.textSecondary + closeButton.backgroundColor = theme.colors.ecosia.backgroundPrimary + closeButton.tintColor = theme.colors.ecosia.textPrimary + footerButton.backgroundColor = theme.colors.ecosia.brandPrimary + footerButton.setTitleColor(theme.colors.ecosia.textInversePrimary, for: .normal) + headerLabelContainerView.backgroundColor = theme.colors.ecosia.backgroundPrimary + secondImageView.tintColor = theme.colors.ecosia.backgroundPrimary } } diff --git a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+FindInPage.swift b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+FindInPage.swift index e67a4b701926..f259c94f7ce2 100644 --- a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+FindInPage.swift +++ b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+FindInPage.swift @@ -56,10 +56,7 @@ extension BrowserViewController { greaterThanOrEqualToConstant: UIConstants.ToolbarHeight ).isActive = true - /* Ecosia: EcosiaFindInPageBar.applyTheme needs no arguments findInPageBar.applyTheme(theme: currentTheme()) - */ - findInPageBar.applyTheme() updateViewConstraints() diff --git a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift index 6e3d9c0bae75..bf4f09d907ee 100644 --- a/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift +++ b/firefox-ios/Client/Frontend/Browser/BrowserViewController/Extensions/BrowserViewController+WebViewDelegates.swift @@ -980,7 +980,7 @@ private extension BrowserViewController { let alert = UIAlertController(title: .localized(.openExternalLinkTitle), message: String(format: .localized(.openExternalLinkDescription), url.absoluteString), preferredStyle: .alert) - alert.view.tintColor = .legacyTheme.ecosia.primaryButton + alert.view.tintColor = currentTheme().colors.ecosia.buttonBackgroundPrimary let cancelAction = UIAlertAction(title: .localized(.cancel), style: .default) { _ in completion(false) } diff --git a/firefox-ios/Client/Frontend/Browser/ButtonToast.swift b/firefox-ios/Client/Frontend/Browser/ButtonToast.swift index 8755b1aae32b..d248119ada77 100644 --- a/firefox-ios/Client/Frontend/Browser/ButtonToast.swift +++ b/firefox-ios/Client/Frontend/Browser/ButtonToast.swift @@ -47,7 +47,6 @@ class ButtonToast: Toast { private var imageView: UIImageView = .build { imageView in // Ecosia: Add imageview properties imageView.contentMode = .scaleAspectFit - imageView.tintColor = UIColor.legacyTheme.ecosia.toastImageTint imageView.setContentHuggingPriority(.required, for: .horizontal) } @@ -221,14 +220,15 @@ class ButtonToast: Toast { titleLabel.textColor = theme.colors.textInverted descriptionLabel.textColor = theme.colors.textInverted - // Ecosia: Add image tintColor to look like v104 - // imageView.tintColor = theme.colors.textInverted - imageView.tintColor = UIColor.legacyTheme.ecosia.toastImageTint + /* Ecosia: Add image tintColor to look like v104 + imageView.tintColor = theme.colors.textInverted + */ + imageView.tintColor = theme.colors.ecosia.toastImageTint roundedButton.setTitleColor(theme.colors.textInverted, for: []) /* Ecosia: Add `horizontalStackView` background as the Toast view is made clear so to have the padding effect from bottom, left and right */ - horizontalStackView.backgroundColor = UIColor.legacyTheme.ecosia.quarternaryBackground + horizontalStackView.backgroundColor = theme.colors.ecosia.backgroundQuaternary // Ecosia: Review ToastView to look like v104 // roundedButton.layer.borderColor = theme.colors.borderInverted.cgColor } diff --git a/firefox-ios/Client/Frontend/Browser/Search/SearchViewController.swift b/firefox-ios/Client/Frontend/Browser/Search/SearchViewController.swift index d49f094614cb..5fb7cfe88429 100644 --- a/firefox-ios/Client/Frontend/Browser/Search/SearchViewController.swift +++ b/firefox-ios/Client/Frontend/Browser/Search/SearchViewController.swift @@ -618,7 +618,7 @@ class SearchViewController: SiteTableViewController, } // Ecosia: Update cell background - cell.backgroundColor = .legacyTheme.ecosia.ntpImpactBackground + cell.backgroundColor = currentTheme().colors.ecosia.ntpCellBackground } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { @@ -680,7 +680,7 @@ class SearchViewController: SiteTableViewController, /* Ecosia: Update background searchEngineContainerView.layer.backgroundColor = currentTheme().colors.layer1.cgColor */ - searchEngineContainerView.layer.backgroundColor = UIColor.legacyTheme.ecosia.barBackground.withAlphaComponent(0.8).cgColor + searchEngineContainerView.layer.backgroundColor = currentTheme().colors.ecosia.barBackground.withAlphaComponent(0.8).cgColor searchEngineContainerView.layer.shadowColor = currentTheme().colors.shadowDefault.cgColor reloadData() @@ -731,7 +731,7 @@ class SearchViewController: SiteTableViewController, /* Ecosia: Update tintColor oneLineCell.leftImageView.tintColor = currentTheme().colors.iconPrimary */ - oneLineCell.leftImageView.tintColor = .legacyTheme.ecosia.primaryButton + oneLineCell.leftImageView.tintColor = currentTheme().colors.ecosia.buttonBackgroundPrimary oneLineCell.leftImageView.backgroundColor = nil let appendButton = UIButton(type: .roundedRect) @@ -752,7 +752,7 @@ class SearchViewController: SiteTableViewController, oneLineCell.accessoryView = indexPath.row > 0 ? appendButton : nil // Ecosia: Enrich background - oneLineCell.backgroundColor = .legacyTheme.ecosia.autocompleteBackground + oneLineCell.backgroundColor = currentTheme().colors.ecosia.barBackground cell = oneLineCell } case .openedTabs: @@ -768,7 +768,7 @@ class SearchViewController: SiteTableViewController, twoLineCell.leftImageView.setFavicon(FaviconImageViewModel(siteURLString: urlString)) } // Ecosia: Enrich background - twoLineCell.backgroundColor = .legacyTheme.ecosia.autocompleteBackground + twoLineCell.backgroundColor = currentTheme().colors.ecosia.barBackground twoLineCell.accessoryView = nil cell = twoLineCell } @@ -786,7 +786,7 @@ class SearchViewController: SiteTableViewController, let urlString = remoteTab.URL.absoluteString twoLineCell.leftImageView.setFavicon(FaviconImageViewModel(siteURLString: urlString)) // Ecosia: Enrich background - twoLineCell.backgroundColor = .legacyTheme.ecosia.autocompleteBackground + twoLineCell.backgroundColor = currentTheme().colors.ecosia.barBackground twoLineCell.accessoryView = nil cell = twoLineCell } diff --git a/firefox-ios/Client/Frontend/Browser/TabTrayButtonExtensions.swift b/firefox-ios/Client/Frontend/Browser/TabTrayButtonExtensions.swift index cb82ef07444a..8cd6ce581b84 100644 --- a/firefox-ios/Client/Frontend/Browser/TabTrayButtonExtensions.swift +++ b/firefox-ios/Client/Frontend/Browser/TabTrayButtonExtensions.swift @@ -26,14 +26,15 @@ class PrivateModeButton: ToggleButton, PrivateModeUI { func applyUIMode(isPrivate: Bool, theme: Theme) { isSelected = isPrivate - // Ecosia: Update tint - // tintColor = isPrivate ? theme.colors.iconOnColor : theme.colors.iconPrimary - tintColor = isPrivate ? .legacyTheme.ecosia.primaryBackground : .legacyTheme.ecosia.primaryText + /* Ecosia: Update tint + tintColor = isPrivate ? theme.colors.iconOnColor : theme.colors.iconPrimary + */ + tintColor = isPrivate ? theme.colors.ecosia.backgroundPrimary : theme.colors.ecosia.textPrimary imageView?.tintColor = tintColor // Ecosia: Modify background layer backgroundLayer.backgroundColor = isPrivate - ? UIColor.legacyTheme.ecosia.privateButtonBackground.cgColor + ? theme.colors.ecosia.privateButtonBackground.cgColor : UIColor.clear.cgColor accessibilityValue = isSelected ? .TabTrayToggleAccessibilityValueOn : .TabTrayToggleAccessibilityValueOff diff --git a/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/EcosiaLegacyTabTrayViewController.swift b/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/EcosiaLegacyTabTrayViewController.swift deleted file mode 100644 index d4e720bad7d1..000000000000 --- a/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/EcosiaLegacyTabTrayViewController.swift +++ /dev/null @@ -1,557 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/ - -import SnapKit -import Shared -import Storage -import Foundation -import Common - -enum TabTrayViewAction { - case addTab - case deleteTab -} - -// swiftlint:disable class_delegate_protocol -protocol TabTrayViewDelegate: UIViewController { - func didTogglePrivateMode(_ togglePrivateModeOn: Bool) - func performToolbarAction(_ action: TabTrayViewAction, sender: UIBarButtonItem) -} -// swiftlint:enable class_delegate_protocol - -class LegacyTabTrayViewController: UIViewController, Themeable { - - struct UX { - struct NavigationMenu { - static let height: CGFloat = 32 - static let width: CGFloat = 343 - } - } - - // MARK: - Variables - var viewModel: LegacyTabTrayViewModel - var openInNewTab: ((_ url: URL, _ isPrivate: Bool) -> Void)? - var didSelectUrl: ((_ url: URL, _ visitType: VisitType) -> Void)? - var notificationCenter: NotificationProtocol - var nimbus: FxNimbus - var themeManager: ThemeManager - var themeObserver: NSObjectProtocol? - - // MARK: - UI Elements - // Buttons & Menus - lazy var deleteButton: UIBarButtonItem = { - let button = UIButton(type: .system) - button.titleLabel?.font = .preferredFont(forTextStyle: .body) - button.titleLabel?.adjustsFontForContentSizeCategory = true - button.accessibilityIdentifier = "closeAllTabsButtonTabTray" - button.setTitle(.localized(.closeAll), for: .normal) - button.addTarget(self, action: #selector(didTapDeleteTabs), for: .primaryActionTriggered) - button.accessibilityLabel = .AppMenu.Toolbar.TabTrayDeleteMenuButtonAccessibilityLabel - return UIBarButtonItem(customView: button) - }() - - lazy var addNewTabButton = CircleButton(config: .newTab, margin: 2) - lazy var newTabButton: UIBarButtonItem = { - addNewTabButton.translatesAutoresizingMaskIntoConstraints = false - let height = addNewTabButton.heightAnchor.constraint(equalToConstant: 50) - height.priority = .init(rawValue: 999) - height.isActive = true - - let width = addNewTabButton.widthAnchor.constraint(equalToConstant: 50) - width.priority = .init(rawValue: 999) - width.isActive = true - - addNewTabButton.addTarget(self, action: #selector(didTapAddTab(_:)), for: .primaryActionTriggered) - let buttonItem = UIBarButtonItem(customView: addNewTabButton) - buttonItem.accessibilityIdentifier = "newTabButtonTabTray" - return buttonItem - }() - - lazy var maskButton = PrivateModeButton() - lazy var maskButtonItem: UIBarButtonItem = { - maskButton.addTarget(self, action: #selector(togglePrivateMode), for: .primaryActionTriggered) - let item = UIBarButtonItem(customView: maskButton) - return item - }() - - lazy var doneButton: UIBarButtonItem = { - let button = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(didTapDone)) - button.accessibilityIdentifier = "doneButtonTabTray" - return button - }() - - lazy var syncTabButton: UIBarButtonItem = { - let button = UIBarButtonItem(title: .FxASyncNow, - style: .plain, - target: self, - action: #selector(didTapSyncTabs)) - - button.accessibilityIdentifier = "syncTabsButtonTabTray" - return button - }() - - lazy var syncLoadingView: UIStackView = { - let syncingLabel = UILabel() - syncingLabel.text = .SyncingMessageWithEllipsis - - let activityIndicator = UIActivityIndicatorView(style: .medium) - activityIndicator.color = .systemGray - activityIndicator.startAnimating() - - let stackView = UIStackView(arrangedSubviews: [syncingLabel, activityIndicator]) - stackView.spacing = 12 - return stackView - }() - - lazy var flexibleSpace: UIBarButtonItem = { - return UIBarButtonItem(barButtonSystemItem: .flexibleSpace, - target: nil, - action: nil) - }() - - lazy var fixedSpace: UIBarButtonItem = { - let fixedSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, - target: nil, - action: nil) - fixedSpace.width = CGFloat(UX.NavigationMenu.height) - return fixedSpace - }() - - lazy var countLabel: UILabel = { - let label = UILabel(frame: CGRect(width: 24, height: 24)) - label.font = TabsButton.UX.titleFont - label.layer.cornerRadius = TabsButton.UX.cornerRadius - label.textAlignment = .center - label.text = viewModel.normalTabsCount - return label - }() - - lazy var bottomToolbarItems: [UIBarButtonItem] = { - return [maskButtonItem, flexibleSpace, newTabButton, flexibleSpace, deleteButton] - }() - - lazy var bottomToolbarItemsForSync: [UIBarButtonItem] = { - return [flexibleSpace, syncTabButton] - }() - - lazy var navigationMenu: UISegmentedControl = { - var navigationMenu: UISegmentedControl - if shouldUseiPadSetup() { - navigationMenu = iPadNavigationMenuIdentifiers - } else { - navigationMenu = iPhoneNavigationMenuIdentifiers - } - - navigationMenu.accessibilityIdentifier = "navBarTabTray" - - var segmentToFocus = viewModel.segmentToFocus - if segmentToFocus == nil { - segmentToFocus = viewModel.tabManager.selectedTab?.isPrivate ?? false ? .privateTabs : .tabs - } - navigationMenu.selectedSegmentIndex = segmentToFocus?.rawValue ?? LegacyTabTrayViewModel.Segment.tabs.rawValue - navigationMenu.addTarget(self, action: #selector(panelChanged), for: .valueChanged) - return navigationMenu - }() - - lazy var iPadNavigationMenuIdentifiers: UISegmentedControl = { - return UISegmentedControl(items: LegacyTabTrayViewModel.Segment.allCases.map { $0.label }) - }() - - lazy var iPhoneNavigationMenuIdentifiers: UISegmentedControl = { - return UISegmentedControl(items: [ - LegacyTabTrayViewModel.Segment.tabs.image!.overlayWith(image: countLabel), - LegacyTabTrayViewModel.Segment.privateTabs.image!]) - // Ecosia: remove sync: LegacyTabTrayViewModel.Segment.syncedTabs.image!]) - }() - - /* Ecosia: hide navigation Toolbar - // Toolbars - lazy var navigationToolbar: UIToolbar = { - let toolbar = UIToolbar() - toolbar.delegate = self - toolbar.setItems([UIBarButtonItem(customView: navigationMenu)], animated: false) - toolbar.isTranslucent = false - return toolbar - }() - */ - - override var preferredStatusBarStyle: UIStatusBarStyle { - return .lightContent - } - - // MARK: - Initializers - init(tabTrayDelegate: TabTrayDelegate? = nil, - profile: Profile, - tabToFocus: Tab? = nil, - tabManager: TabManager, - overlayManager: OverlayModeManager, - focusedSegment: LegacyTabTrayViewModel.Segment? = nil, - themeManager: ThemeManager = AppContainer.shared.resolve(), - and notificationCenter: NotificationProtocol = NotificationCenter.default, - with nimbus: FxNimbus = FxNimbus.shared - ) { - self.nimbus = nimbus - self.notificationCenter = notificationCenter - self.themeManager = themeManager - self.viewModel = LegacyTabTrayViewModel(tabTrayDelegate: tabTrayDelegate, - profile: profile, - tabToFocus: tabToFocus, - tabManager: tabManager, - overlayManager: overlayManager, - segmentToFocus: focusedSegment) - - super.init(nibName: nil, bundle: nil) - modalPresentationCapturesStatusBarAppearance = true - - setupNotifications(forObserver: self, - observing: [.ProfileDidStartSyncing, - .ProfileDidFinishSyncing, - .UpdateLabelOnTabClosed]) - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - deinit { - notificationCenter.removeObserver(self) - } - - // MARK: - View Lifecycle - override func viewDidLoad() { - super.viewDidLoad() - - viewSetup() - listenForThemeChange(view) - applyTheme() - updatePrivateUIState() - panelChanged() - } - - override func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - - // We expose the tab tray feature whenever it's going to be seen by the user - // Ecosia // nimbus.features.tabTrayFeature.recordExposure() - - if shouldUseiPadSetup() { - navigationController?.isToolbarHidden = true - } else { - navigationController?.isToolbarHidden = false - updateToolbarItems(forSyncTabs: viewModel.profile.hasSyncableAccount()) - } - } - - private func viewSetup() { - // viewModel.syncedTabsController.remotePanelDelegate = self - - /* Ecosia - if let appWindow = (UIApplication.shared.delegate?.window), - let window = appWindow as UIWindow? { - window.backgroundColor = .black - } - */ - - if shouldUseiPadSetup() { - iPadViewSetup() - } else { - iPhoneViewSetup() - } - - showPanel(viewModel.tabTrayView) - } - - func updatePrivateUIState() { - UserDefaults.standard.set(viewModel.tabManager.selectedTab?.isPrivate ?? false, forKey: "wasLastSessionPrivate") - } - - fileprivate func iPadViewSetup() { - navigationItem.leftBarButtonItem = deleteButton - navigationItem.titleView = navigationMenu - navigationItem.rightBarButtonItems = [doneButton, fixedSpace, newTabButton] - - navigationItem.titleView?.snp.makeConstraints { make in - make.width.equalTo(343) - } - } - - fileprivate func iPhoneViewSetup() { - navigationItem.rightBarButtonItem = doneButton - - /* Ecosia: hide navigationToolbar - view.addSubview(navigationToolbar) - - navigationToolbar.snp.makeConstraints { make in - make.left.right.equalTo(view) - make.top.equalTo(view.safeArea.top) - } - */ - navigationItem.rightBarButtonItem = doneButton - - navigationMenu.snp.makeConstraints { make in - make.width.lessThanOrEqualTo(UX.NavigationMenu.width) - make.height.equalTo(UX.NavigationMenu.height) - } - } - - fileprivate func updateTitle() { - guard !shouldUseiPadSetup(), let grid = viewModel.tabTrayView as? LegacyGridTabViewController else { return } - navigationItem.title = grid.tabDisplayManager.isPrivate ? - LegacyTabTrayViewModel.Segment.privateTabs.navTitle : - LegacyTabTrayViewModel.Segment.tabs.navTitle - } - - @objc func panelChanged() { - let segment = LegacyTabTrayViewModel.Segment(rawValue: navigationMenu.selectedSegmentIndex) - switch segment { - case .tabs: - switchBetweenLocalPanels(withPrivateMode: false, animated: false) - case .privateTabs: - switchBetweenLocalPanels(withPrivateMode: true, animated: false) - /* - case .syncedTabs: - TelemetryWrapper.recordEvent(category: .action, method: .tap, object: .libraryPanel, value: .syncPanel, extras: nil) - if children.first == viewModel.tabTrayView { - hideCurrentPanel() - updateToolbarItems(forSyncTabs: viewModel.profile.hasSyncableAccount()) - showPanel(viewModel.syncedTabsController) - } - */ - default: - return - } - } - - // Ecosia: custom private mode UI - @objc func togglePrivateMode() { - guard let grid = viewModel.tabTrayView as? LegacyGridTabViewController else { return } - switchBetweenLocalPanels(withPrivateMode: !grid.tabDisplayManager.isPrivate, animated: true) - } - - fileprivate func updateMaskButton() { - guard let grid = viewModel.tabTrayView as? LegacyGridTabViewController else { return } - maskButton.isSelected = grid.tabDisplayManager.isPrivate - maskButton.applyUIMode(isPrivate: grid.tabDisplayManager.isPrivate, theme: themeManager.currentTheme) - } - - private func switchBetweenLocalPanels(withPrivateMode privateMode: Bool, animated: Bool) { - if children.first != viewModel.tabTrayView { - hideCurrentPanel() - showPanel(viewModel.tabTrayView) - } - updateToolbarItems(forSyncTabs: viewModel.profile.hasSyncableAccount()) - viewModel.tabTrayView.didTogglePrivateMode(privateMode) - updatePrivateUIState() - updateTitle() - - // Ecosia: update private button - maskButton.setSelected(privateMode, animated: animated) - maskButton.applyUIMode(isPrivate: privateMode, theme: themeManager.currentTheme) - } - - private func showPanel(_ panel: UIViewController) { - addChild(panel) - panel.beginAppearanceTransition(true, animated: true) - view.addSubview(panel.view) - // Ecosia: view.bringSubviewToFront(navigationToolbar) - // Ecosia: hide Toolbar - // let topEdgeInset = shouldUseiPadSetup() ? 0 : GridTabTrayControllerUX.NavigationToolbarHeight - let topEdgeInset: CGFloat = 0 - panel.additionalSafeAreaInsets = UIEdgeInsets(top: topEdgeInset, left: 0, bottom: 0, right: 0) - panel.endAppearanceTransition() - panel.view.snp.makeConstraints { make in - make.edges.equalToSuperview() - } - panel.didMove(toParent: self) - updateTitle() - updateMaskButton() - } - - private func hideCurrentPanel() { - if let panel = children.first { - panel.willMove(toParent: nil) - panel.beginAppearanceTransition(false, animated: true) - panel.view.removeFromSuperview() - panel.endAppearanceTransition() - panel.removeFromParent() - } - } - - private func updateToolbarItems(forSyncTabs showSyncItems: Bool = false) { - if shouldUseiPadSetup() { - navigationItem.rightBarButtonItems = [doneButton, fixedSpace, newTabButton] - navigationItem.leftBarButtonItem = deleteButton - } else { - let newToolbarItems: [UIBarButtonItem]? = bottomToolbarItems - setToolbarItems(newToolbarItems, animated: true) - } - } - - private func updateButtonTitle(_ notification: Notification) { - switch notification.name { - case .ProfileDidStartSyncing: - // Update Sync Tab button - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - self.syncTabButton.isEnabled = false - self.syncTabButton.customView = self.syncLoadingView - } - case .ProfileDidFinishSyncing: - // Update Sync Tab button - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - - self.syncTabButton.customView = nil - self.syncTabButton.title = .FxASyncNow - self.syncTabButton.isEnabled = true - } - default: - break - } - } -} - -extension LegacyTabTrayViewController: TabTrayController { - - func remotePanelDidRequestToSignIn() { } - - func remotePanelDidRequestToOpenInNewTab(_ url: URL, isPrivate: Bool) { - self.openInNewTab?(url, isPrivate) - self.dismissVC() - } - - func remotePanel(didSelectURL url: URL, visitType: VisitType) { - self.didSelectUrl?(url, visitType) - self.dismissVC() - } -} - -// MARK: - Notifiable protocol -extension LegacyTabTrayViewController: Notifiable { - func handleNotifications(_ notification: Notification) { - ensureMainThread { [weak self] in - switch notification.name { - case .ProfileDidStartSyncing, .ProfileDidFinishSyncing: - self?.updateButtonTitle(notification) - case .UpdateLabelOnTabClosed: - guard let label = self?.countLabel else { return } - self?.countLabel.text = self?.viewModel.normalTabsCount - self?.iPhoneNavigationMenuIdentifiers.setImage(UIImage(named: ImageIdentifiers.navTabCounter)!.overlayWith(image: label), forSegmentAt: 0) - default: break - } - } - } -} - -// MARK: - Theme protocol -extension LegacyTabTrayViewController { - - @objc func applyTheme() { - view.backgroundColor = UIColor.legacyTheme.tabTray.background - // Ecosia: navigationToolbar.barTintColor = UIColor.theme.tabTray.toolbar - // Ecosia: navigationToolbar.tintColor = UIColor.theme.tabTray.toolbarButtonTint - navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.ecosia.primaryText] - // viewModel.syncedTabsController.applyTheme() - - // Ecosia - if traitCollection.userInterfaceIdiom == .phone { - navigationController?.navigationBar.tintColor = UIColor.legacyTheme.ecosia.primaryButton - } - maskButton.applyUIMode(isPrivate: maskButton.isSelected, theme: themeManager.currentTheme) - // Ecosia: Update `addNewTabButton.applyTheme` - // addNewTabButton.applyTheme() - addNewTabButton.applyTheme(theme: themeManager.currentTheme) - // Ecosia: Change close all button title color - (deleteButton.customView as? UIButton)?.setTitleColor(.legacyTheme.ecosia.warning, for: .normal) - - if shouldUseiPadSetup() { - navigationItem.leftBarButtonItem?.tintColor = UIColor.legacyTheme.ecosia.primaryButton - navigationItem.rightBarButtonItem?.tintColor = UIColor.legacyTheme.ecosia.primaryButton - navigationMenu.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.ecosia.primaryText], for: .normal) - navigationMenu.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.ecosia.segmentSelectedText], for: .selected) - } - } - } - -// MARK: - UIToolbarDelegate -extension LegacyTabTrayViewController: UIToolbarDelegate { - func position(for bar: UIBarPositioning) -> UIBarPosition { - return .topAttached - } -} - -// MARK: - Adaptive & Popover Presentation Delegates -extension LegacyTabTrayViewController: UIAdaptivePresentationControllerDelegate, UIPopoverPresentationControllerDelegate { - // Returning None here, for the iPhone makes sure that the Popover is actually presented as a - // Popover and not as a full-screen modal, which is the default on compact device classes. - func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle { - - if shouldUseiPadSetup() { - return .overFullScreen - } - - return .none - } - - func presentationControllerDidDismiss(_ presentationController: UIPresentationController) { - notificationCenter.post(name: .TabsTrayDidClose) - TelemetryWrapper.recordEvent(category: .action, method: .close, object: .tabTray) - } -} - -// MARK: - Button actions -extension LegacyTabTrayViewController { - @objc func didTapAddTab(_ sender: UIBarButtonItem) { - viewModel.didTapAddTab(sender) - } - - @objc func didTapDeleteTabs(_ sender: UIBarButtonItem) { - viewModel.didTapDeleteTab(sender) - } - - @objc func didTapSyncTabs(_ sender: UIBarButtonItem) { - viewModel.didTapSyncTabs(sender) - } - - @objc func didTapDone() { - notificationCenter.post(name: .TabsTrayDidClose) - self.dismiss(animated: true, completion: nil) - } -} - -/* -// MARK: - RemoteTabsPanel : LibraryPanelDelegate -extension LegacyTabTrayViewController: RemotePanelDelegate { - func remotePanelDidRequestToSignIn() { - fxaSignInOrCreateAccountHelper() - } - - func remotePanelDidRequestToCreateAccount() { - fxaSignInOrCreateAccountHelper() - } - - func remotePanelDidRequestToOpenInNewTab(_ url: URL, isPrivate: Bool) { - TelemetryWrapper.recordEvent(category: .action, method: .open, object: .syncTab) - self.openInNewTab?(url, isPrivate) - self.dismissVC() - } - - func remotePanel(didSelectURL url: URL, visitType: VisitType) { - TelemetryWrapper.recordEvent(category: .action, method: .open, object: .syncTab) - self.didSelectUrl?(url, visitType) - self.dismissVC() - } - - // Sign In and Create Account Helper - func fxaSignInOrCreateAccountHelper() { - let fxaParams = FxALaunchParams(query: ["entrypoint": "homepanel"]) - let controller = FirefoxAccountSignInViewController.getSignInOrFxASettingsVC(fxaParams, flowType: .emailLoginFlow, referringPage: .tabTray, profile: viewModel.profile) - (controller as? FirefoxAccountSignInViewController)?.shouldReload = { [weak self] in - self?.viewModel.reloadRemoteTabs() - } - presentThemedViewController(navItemLocation: .Left, navItemText: .Close, vcBeingPresented: controller, topTabsVisible: UIDevice.current.userInterfaceIdiom == .pad) - } -} - */ diff --git a/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyGridTabViewController.swift b/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyGridTabViewController.swift index 774680070361..58d93658781f 100644 --- a/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyGridTabViewController.swift +++ b/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyGridTabViewController.swift @@ -718,7 +718,7 @@ extension LegacyGridTabViewController { let closeAllAction = UIAlertAction(title: .TabTrayCloseAllTabsPromptCancel, style: .cancel, handler: nil) - closeAllAction.setValue(UIColor.legacyTheme.ecosia.actionSheetCancelButton, forKey: "titleTextColor") + closeAllAction.setValue(currentTheme().colors.ecosia.buttonBackgroundPrimaryActive, forKey: "titleTextColor") controller.addAction(closeAllAction, accessibilityIdentifier: AccessibilityIdentifiers.TabTray.deleteCancelButton) controller.popoverPresentationController?.barButtonItem = sender diff --git a/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyTabCell.swift b/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyTabCell.swift index 653292a1b73d..d3a3da7d2f1b 100644 --- a/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyTabCell.swift +++ b/firefox-ios/Client/Frontend/Browser/Tabs/Legacy/LegacyTabCell.swift @@ -275,7 +275,7 @@ class LegacyTabCell: UICollectionViewCell, right: LegacyTabCell.borderWidth) // Ecosia: Update border color // layer.borderColor = (isPrivate ? theme.colors.borderAccentPrivate : theme.colors.borderAccent).cgColor - layer.borderColor = UIColor.legacyTheme.ecosia.primaryButton.cgColor + layer.borderColor = theme.colors.ecosia.buttonBackgroundPrimary.cgColor layer.borderWidth = LegacyTabCell.borderWidth layer.cornerRadius = LegacyGridTabViewController.UX.cornerRadius + LegacyTabCell.borderWidth } diff --git a/firefox-ios/Client/Frontend/Browser/Tabs/Views/TabCell.swift b/firefox-ios/Client/Frontend/Browser/Tabs/Views/TabCell.swift index b0671a8ec400..2ffc15a680df 100644 --- a/firefox-ios/Client/Frontend/Browser/Tabs/Views/TabCell.swift +++ b/firefox-ios/Client/Frontend/Browser/Tabs/Views/TabCell.swift @@ -160,7 +160,7 @@ class TabCell: UICollectionViewCell, ThemeApplicable, ReusableCell { favicon.tintColor = theme.colors.textPrimary smallFaviconView.tintColor = theme.colors.textPrimary */ - self.ecosiaApplyTheme() + self.ecosiaApplyTheme(theme: theme) } // MARK: - Configuration @@ -322,20 +322,20 @@ class TabCell: UICollectionViewCell, ThemeApplicable, ReusableCell { // Ecosia: Add legacy theme references extension TabCell { - func ecosiaApplyTheme() { + func ecosiaApplyTheme(theme: Theme) { - backgroundHolder.backgroundColor = UIColor.legacyTheme.tabTray.cellBackground - screenshotView.backgroundColor = UIColor.legacyTheme.tabTray.screenshotBackground + backgroundHolder.backgroundColor = theme.colors.ecosia.backgroundPrimary + screenshotView.backgroundColor = theme.colors.ecosia.tabTrayScreenshotBackground let isPrivate = tabModel?.isPrivate == true let activeBGColor = isPrivate ? - UIColor.legacyTheme.ecosia.tabSelectedPrivateBackground : - UIColor.legacyTheme.ecosia.tabSelectedBackground - headerView.backgroundColor = isSelectedTab ? activeBGColor : UIColor.legacyTheme.ecosia.tabBackground + theme.colors.ecosia.tabSelectedPrivateBackground : + theme.colors.ecosia.buttonBackgroundPrimary + headerView.backgroundColor = isSelectedTab ? activeBGColor : theme.colors.ecosia.ntpCellBackground - titleText.textColor = isSelectedTab ? UIColor.legacyTheme.ecosia.primaryTextInverted : UIColor.legacyTheme.ecosia.primaryText - favicon.tintColor = isSelectedTab ? UIColor.legacyTheme.ecosia.primaryTextInverted : UIColor.legacyTheme.ecosia.primaryText - closeButton.tintColor = isSelectedTab ? UIColor.legacyTheme.ecosia.primaryTextInverted : UIColor.legacyTheme.ecosia.primaryText + titleText.textColor = isSelectedTab ? theme.colors.ecosia.textInversePrimary : theme.colors.ecosia.textPrimary + favicon.tintColor = isSelectedTab ? theme.colors.ecosia.textInversePrimary : theme.colors.ecosia.textPrimary + closeButton.tintColor = isSelectedTab ? theme.colors.ecosia.textInversePrimary : theme.colors.ecosia.textPrimary let borderWidth: CGFloat = 3 @@ -347,7 +347,7 @@ extension TabCell { // create a frame that is "BorderWidth" size bigger than the cell layer.shadowOffset = CGSize(width: -borderWidth, height: -borderWidth) layer.shadowColor = activeBGColor.cgColor - } else if LegacyThemeManager.instance.current.isDark { + } else if theme.type == .dark { layer.masksToBounds = true layer.shadowOpacity = 0 layer.shadowOffset = .zero diff --git a/firefox-ios/Client/Frontend/Components/StatusBarOverlay.swift b/firefox-ios/Client/Frontend/Components/StatusBarOverlay.swift index 00e09c4243d8..a9284494619a 100644 --- a/firefox-ios/Client/Frontend/Components/StatusBarOverlay.swift +++ b/firefox-ios/Client/Frontend/Components/StatusBarOverlay.swift @@ -71,9 +71,10 @@ class StatusBarOverlay: UIView, // MARK: - ThemeApplicable func applyTheme(theme: Theme) { - // Ecosia: update background - // savedBackgroundColor = hasTopTabs ? theme.colors.layer3 : theme.colors.layer1 - savedBackgroundColor = .legacyTheme.ecosia.primaryBackground + /* Ecosia: update background + savedBackgroundColor = hasTopTabs ? theme.colors.layer3 : theme.colors.layer1 + */ + savedBackgroundColor = theme.colors.ecosia.backgroundPrimary backgroundColor = savedBackgroundColor?.withAlphaComponent(scrollOffset) } diff --git a/firefox-ios/Client/Frontend/Home/LegacyHomepageViewController.swift b/firefox-ios/Client/Frontend/Home/LegacyHomepageViewController.swift index 6efe90db5621..ca248fefb107 100644 --- a/firefox-ios/Client/Frontend/Home/LegacyHomepageViewController.swift +++ b/firefox-ios/Client/Frontend/Home/LegacyHomepageViewController.swift @@ -430,9 +430,10 @@ class LegacyHomepageViewController: func applyTheme() { let theme = themeManager.getCurrentTheme(for: windowUUID) viewModel.theme = theme - // Ecosia: Update NTP background - // view.backgroundColor = theme.colors.layer1 - view.backgroundColor = .legacyTheme.ecosia.ntpBackground + /* Ecosia: Update NTP background + view.backgroundColor = theme.colors.layer1 + */ + view.backgroundColor = theme.colors.ecosia.ntpBackground } // called when the homepage is displayed to make sure it's scrolled to top @@ -660,6 +661,7 @@ extension LegacyHomepageViewController: UICollectionViewDelegate, UICollectionVi let text = NTPTooltip.highlight()?.text, kind == UICollectionView.elementKindSectionHeader { let tooltip = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: NTPTooltip.key, for: indexPath) as! NTPTooltip + tooltip.applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID)) tooltip.setText(text) tooltip.delegate = self return tooltip @@ -667,7 +669,12 @@ extension LegacyHomepageViewController: UICollectionViewDelegate, UICollectionVi // Ecosia: footer for impact if sectionViewModel.sectionType == .impact, kind == UICollectionView.elementKindSectionFooter { - return collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: NTPImpactDividerFooter.cellIdentifier, for: indexPath) + let dividerFooter = collectionView + .dequeueReusableSupplementaryView(ofKind: kind, + withReuseIdentifier: NTPImpactDividerFooter.cellIdentifier, + for: indexPath) as? NTPImpactDividerFooter + dividerFooter?.applyTheme(theme: themeManager.getCurrentTheme(for: windowUUID)) + return dividerFooter ?? UICollectionReusableView() } guard let headerView = collectionView.dequeueReusableSupplementaryView( diff --git a/firefox-ios/Client/Frontend/Home/LogoHeader/HomeLogoHeaderViewModel.swift b/firefox-ios/Client/Frontend/Home/LogoHeader/HomeLogoHeaderViewModel.swift index 6d532c3ad750..3933f3d95fd8 100644 --- a/firefox-ios/Client/Frontend/Home/LogoHeader/HomeLogoHeaderViewModel.swift +++ b/firefox-ios/Client/Frontend/Home/LogoHeader/HomeLogoHeaderViewModel.swift @@ -107,6 +107,7 @@ extension HomepageHeaderViewModel: HomepageSectionHandler { return headerCell */ guard let logoHeaderCell = cell as? NTPLogoCell else { return UICollectionViewCell() } + logoHeaderCell.applyTheme(theme: theme) return logoHeaderCell } } diff --git a/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/BookmarksPanelViewModel.swift b/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/BookmarksPanelViewModel.swift index 1f1b92cc2da1..1c01828a4958 100644 --- a/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/BookmarksPanelViewModel.swift +++ b/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/BookmarksPanelViewModel.swift @@ -197,7 +197,9 @@ extension BookmarksPanelViewModel { let documentPicker = UIDocumentPickerViewController(documentTypes: ["public.html"], in: .open) documentPicker.allowsMultipleSelection = false // Ecosia: Theming - documentPicker.view.tintColor = .legacyTheme.ecosia.primaryButton + let themeManager: ThemeManager = AppContainer.shared.resolve() + let theme = themeManager.getCurrentTheme(for: viewController.view.currentWindowUUID) + documentPicker.view.tintColor = theme.colors.ecosia.buttonBackgroundPrimary documentPicker.delegate = self viewController.present(documentPicker, animated: true) } diff --git a/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/LegacyBookmarksPanel.swift b/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/LegacyBookmarksPanel.swift index a391d1bb5851..ab507d94a4d8 100644 --- a/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/LegacyBookmarksPanel.swift +++ b/firefox-ios/Client/Frontend/Library/Bookmarks/Legacy/LegacyBookmarksPanel.swift @@ -113,11 +113,12 @@ class LegacyBookmarksPanel: SiteTableViewController, private lazy var emptyHeader = EmptyHeader(icon: "bookmarksEmpty", title: .localized(.noBookmarksYet), subtitle: .localized(.AddYourFavoritePages)) // Ecosia: Tooltip - private let bookmarksTooltip: NTPTooltip = { + private lazy var bookmarksTooltip: NTPTooltip = { let tooltip = NTPTooltip() tooltip.tailPosition = .leading + tooltip.applyTheme(theme: currentTheme()) tooltip.setText(.localized(.bookmarksToolTipText)) - tooltip.setLinkTitle(.localized(.learnMore)) + tooltip.setLinkTitle(.localized(.learnMore), theme: currentTheme()) return tooltip }() @@ -160,7 +161,7 @@ class LegacyBookmarksPanel: SiteTableViewController, tableView.allowsSelectionDuringEditing = true tableView.dragInteractionEnabled = false // Ecosia: Update TableView properties - tableView.backgroundColor = themeManager.getCurrentTheme(for: windowUUID).colors.layer6 + tableView.backgroundColor = currentTheme().colors.ecosia.modalBackground tableView.contentInset.top = 32 } @@ -210,6 +211,7 @@ class LegacyBookmarksPanel: SiteTableViewController, */ let emptyBookmarksView = EmptyBookmarksView(initialBottomMargin: topAnchorDelta) emptyBookmarksView.delegate = self + emptyBookmarksView.applyTheme(theme: currentTheme()) tableView.tableHeaderView = nil tableView.backgroundView = emptyBookmarksView case (false, true): // is folder which is empty -> show "old" empty view @@ -800,7 +802,7 @@ extension LegacyBookmarksPanel { self?.moreButton.isEnabled = true } let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) - alert.view.tintColor = UIColor.legacyTheme.ecosia.primaryButton + alert.view.tintColor = currentTheme().colors.ecosia.buttonBackgroundPrimary alert.popoverPresentationController?.barButtonItem = moreButton [importAction, exportAction, cancelAction].forEach(alert.addAction) present(alert, animated: true) diff --git a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift b/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift index 548dd0784f76..0fbf69b0abc9 100644 --- a/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift +++ b/firefox-ios/Client/Frontend/Library/HistoryPanel/HistoryPanel.swift @@ -626,7 +626,7 @@ class HistoryPanel: UIViewController, // Ecosia: Replace empty header // tableView.tableFooterView = emptyStateOverlayView tableView.tableFooterView = emptyHeader - emptyHeader.applyTheme() + emptyHeader.applyTheme(theme: currentTheme()) } else { tableView.alwaysBounceVertical = true tableView.tableFooterView = nil @@ -674,7 +674,6 @@ class HistoryPanel: UIViewController, updateEmptyPanelState() let theme = currentTheme() - // TODO Ecosia Upgrade: Check new background color layer1 [MOB-3152] tableView.backgroundColor = theme.colors.layer1 emptyStateOverlayView.backgroundColor = theme.colors.layer1 @@ -683,7 +682,7 @@ class HistoryPanel: UIViewController, */ searchbar.barTintColor = tableView.backgroundColor searchbar.backgroundColor = tableView.backgroundColor - searchbar.searchTextField.backgroundColor = .legacyTheme.ecosia.primaryBackground + searchbar.searchTextField.backgroundColor = theme.colors.ecosia.backgroundPrimary /* Ecosia: Update search bar image let tintColor = theme.colors.textPrimary @@ -691,7 +690,7 @@ class HistoryPanel: UIViewController, .withRenderingMode(.alwaysTemplate) .tinted(withColor: tintColor) */ - let searchBarImage = UIImage(named: "search")?.tinted(withColor: .legacyTheme.ecosia.secondaryText).createScaled(.init(width: 16, height: 16)) + let searchBarImage = UIImage(named: "search")?.tinted(withColor: theme.colors.ecosia.textSecondary).createScaled(.init(width: 16, height: 16)) searchbar.setImage(searchBarImage, for: .search, state: .normal) @@ -708,8 +707,8 @@ class HistoryPanel: UIViewController, bottomSearchButton.tintColor = theme.colors.iconPrimary bottomDeleteButton.tintColor = theme.colors.iconPrimary */ - bottomSearchButton.tintColor = .legacyTheme.ecosia.primaryText - bottomDeleteButton.tintColor = .legacyTheme.ecosia.warning + bottomSearchButton.tintColor = theme.colors.ecosia.textPrimary + bottomDeleteButton.tintColor = theme.colors.ecosia.stateError applyEmptyStateViewTheme(theme) diff --git a/firefox-ios/Client/Frontend/Library/LibraryViewController/LibraryViewController.swift b/firefox-ios/Client/Frontend/Library/LibraryViewController/LibraryViewController.swift index 8e5bd0607ab6..5db1a9a4a00f 100644 --- a/firefox-ios/Client/Frontend/Library/LibraryViewController/LibraryViewController.swift +++ b/firefox-ios/Client/Frontend/Library/LibraryViewController/LibraryViewController.swift @@ -329,9 +329,9 @@ class LibraryViewController: UIViewController, Themeable { /* Ecosia: Update theming standardAppearance.backgroundColor = theme.colors.layer1 */ - standardAppearance.backgroundColor = theme.colors.layer6 - standardAppearance.backgroundColor = .legacyTheme.ecosia.barBackground - standardAppearance.shadowColor = .legacyTheme.ecosia.barSeparator + standardAppearance.backgroundColor = theme.colors.ecosia.modalBackground + standardAppearance.backgroundColor = theme.colors.ecosia.barBackground + standardAppearance.shadowColor = theme.colors.ecosia.barSeparator navigationController?.toolbar.standardAppearance = standardAppearance navigationController?.toolbar.compactAppearance = standardAppearance @@ -359,12 +359,12 @@ class LibraryViewController: UIViewController, Themeable { segmentControlToolbar.barTintColor = theme.colors.layer1 */ view.backgroundColor = theme.colors.layer3 - navigationController?.navigationBar.barTintColor = theme.colors.layer6 + navigationController?.navigationBar.barTintColor = theme.colors.ecosia.modalBackground navigationController?.navigationBar.tintColor = theme.colors.actionPrimary - navigationController?.navigationBar.backgroundColor = theme.colors.layer6 - navigationController?.toolbar.barTintColor = theme.colors.layer6 + navigationController?.navigationBar.backgroundColor = theme.colors.ecosia.modalBackground + navigationController?.toolbar.barTintColor = theme.colors.ecosia.modalBackground navigationController?.toolbar.tintColor = theme.colors.actionPrimary - segmentControlToolbar.barTintColor = theme.colors.layer6 + segmentControlToolbar.barTintColor = theme.colors.ecosia.modalBackground segmentControlToolbar.tintColor = theme.colors.textPrimary segmentControlToolbar.isTranslucent = false diff --git a/firefox-ios/Client/Frontend/Settings/Main/DefaultBrowserSetting.swift b/firefox-ios/Client/Frontend/Settings/Main/DefaultBrowserSetting.swift index 57deff8dd132..45c6f47b5641 100644 --- a/firefox-ios/Client/Frontend/Settings/Main/DefaultBrowserSetting.swift +++ b/firefox-ios/Client/Frontend/Settings/Main/DefaultBrowserSetting.swift @@ -18,13 +18,13 @@ class DefaultBrowserSetting: Setting { ) ) */ - super.init(title: .init(string: .localized(.setAsDefaultBrowser), attributes: [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.tableView.rowText])) + super.init(title: .init(string: .localized(.setAsDefaultBrowser), attributes: [NSAttributedString.Key.foregroundColor: theme.colors.ecosia.tableViewRowText])) } // Ecosia: Override cell config to add image override func onConfigureCell(_ cell: UITableViewCell, theme: Theme) { super.onConfigureCell(cell, theme: theme) - cell.imageView?.image = .init(themed: "yourImpact") + cell.imageView?.image = .init(named: "yourImpact") } override func onClick(_ navigationController: UINavigationController?) { diff --git a/firefox-ios/Client/Frontend/Settings/Main/SettingDisclosureUtility.swift b/firefox-ios/Client/Frontend/Settings/Main/SettingDisclosureUtility.swift index 2f1e49c797af..8ebfaa69ef12 100644 --- a/firefox-ios/Client/Frontend/Settings/Main/SettingDisclosureUtility.swift +++ b/firefox-ios/Client/Frontend/Settings/Main/SettingDisclosureUtility.swift @@ -18,6 +18,6 @@ struct SettingDisclosureUtility { disclosureIndicator.adjustsImageSizeForAccessibilityContentSizeCategory = true return disclosureIndicator */ - ecosiaDisclosureIndicator + ecosiaDisclosureIndicator(theme: theme) } } diff --git a/firefox-ios/Client/Frontend/Settings/ThemeSettings/ThemeSettingsController.swift b/firefox-ios/Client/Frontend/Settings/ThemeSettings/ThemeSettingsController.swift index d9c1a8594722..8ea5bd653898 100644 --- a/firefox-ios/Client/Frontend/Settings/ThemeSettings/ThemeSettingsController.swift +++ b/firefox-ios/Client/Frontend/Settings/ThemeSettings/ThemeSettingsController.swift @@ -105,17 +105,6 @@ class ThemeSettingsController: ThemedTableViewController, StoreSubscriber { actionType: ThemeSettingsViewActionType.toggleUseSystemAppearance) store.dispatch(action) - // Ecosia: Update legacy theme - // TODO Ecosia Upgrade: Do we need this? [MOB-3152] - if control.isOn { - // Reset the user interface style to the default before choosing our theme - UIApplication.shared.delegate?.window??.overrideUserInterfaceStyle = .unspecified - // TODO Ecosia Upgrade: Re-add if LegacyThemeManager is kept [MOB-3152] - // LegacyThemeManager.updateBasedOnCurrentSystemThemeType() - } else if LegacyThemeManager.instance.automaticBrightnessIsOn { - LegacyThemeManager.instance.updateCurrentThemeBasedOnScreenBrightness() - } - // Switch animation must begin prior to scheduling table view update animation // (or the switch will be auto-synchronized to the slower tableview animation // and makes the switch behaviour feel slow and non-standard). diff --git a/firefox-ios/Client/Frontend/Theme/LegacyThemeManager/photon-colors.swift b/firefox-ios/Client/Frontend/Theme/LegacyThemeManager/photon-colors.swift index dad9c182563d..a32435ba6961 100644 --- a/firefox-ios/Client/Frontend/Theme/LegacyThemeManager/photon-colors.swift +++ b/firefox-ios/Client/Frontend/Theme/LegacyThemeManager/photon-colors.swift @@ -8,11 +8,10 @@ import UIKit extension UIColor { struct Photon { - // TODO Ecosia Upgrade: Are LightGrey20 and DarkGrey30 used? (they were removed in Firefox) [MOB-3152] - static let LightGrey20 = UIColor(rgb: 0xf0f0f4) - - // Ecosia: Add legacy color references from 9.1.0 App Version + // Ecosia: Add legacy color references needed on Ecosia code (to be removed) static let DarkGrey30 = UIColor(rgb: 0x42414d) + static let Grey70 = UIColor(rgb: 0x38383d) + static let DarkGrey60 = UIColor(rgb: 0x2b2a33) static let DarkGrey90 = UIColor(rgb: 0x15141a) @@ -33,9 +32,6 @@ extension UIColor { static let Grey40 = UIColor(rgb: 0xb1b1b3) static let Grey50 = UIColor(rgb: 0x737373) static let Grey60 = UIColor(rgb: 0x4a4a4f) - static let Grey70 = UIColor(rgb: 0x38383d) - // Ecosia: Add `Grey80` color - static let Grey80 = UIColor(rgb: 0x2a2a2e) static let Grey90 = UIColor(rgb: 0x0c0c0d) } } diff --git a/firefox-ios/Client/Frontend/Theme/ThemedTableViewCells/ThemedTableViewCell.swift b/firefox-ios/Client/Frontend/Theme/ThemedTableViewCells/ThemedTableViewCell.swift index 45f06b9a0e1d..283051c7dc06 100644 --- a/firefox-ios/Client/Frontend/Theme/ThemedTableViewCells/ThemedTableViewCell.swift +++ b/firefox-ios/Client/Frontend/Theme/ThemedTableViewCells/ThemedTableViewCell.swift @@ -77,7 +77,7 @@ class ThemedTableViewCell: UITableViewCell, ReusableCell, ThemeApplicable { detailTextLabel?.textColor = viewModel?.detailTextColor ?? theme.colors.textSecondary // Ecosia: Update background color // backgroundColor = viewModel?.backgroundColor ?? theme.colors.layer5 - backgroundColor = viewModel?.backgroundColor ?? .legacyTheme.tableView.rowBackground + backgroundColor = viewModel?.backgroundColor ?? theme.colors.ecosia.barBackground tintColor = viewModel?.tintColor ?? theme.colors.actionPrimary } diff --git a/firefox-ios/Client/Frontend/Toolbar+URLBar/TabLocationView.swift b/firefox-ios/Client/Frontend/Toolbar+URLBar/TabLocationView.swift index 16e5afe7224a..87813754594e 100644 --- a/firefox-ios/Client/Frontend/Toolbar+URLBar/TabLocationView.swift +++ b/firefox-ios/Client/Frontend/Toolbar+URLBar/TabLocationView.swift @@ -99,10 +99,7 @@ class TabLocationView: UIView, FeatureFlaggable { } private func setURLTextfieldPlaceholder(theme: Theme) { - /* Ecosia: Update Placeholder attributes let attributes = [NSAttributedString.Key.foregroundColor: theme.colors.textSecondary] - */ - let attributes = [NSAttributedString.Key.foregroundColor: UIColor.legacyTheme.ecosia.secondaryText] urlTextField.attributedPlaceholder = NSAttributedString( string: .TabLocationURLPlaceholder, attributes: attributes @@ -528,10 +525,10 @@ extension TabLocationView: AccessibilityActionsSource { extension TabLocationView: ThemeApplicable { func applyTheme(theme: Theme) { setURLTextfieldPlaceholder(theme: theme) + urlTextField.textColor = theme.colors.textPrimary + // Ecosia: Update `urlTextField` theme - // urlTextField.textColor = theme.colors.textPrimary - urlTextField.textColor = UIColor.legacyTheme.ecosia.primaryText - urlTextField.tintColor = .legacyTheme.ecosia.information + urlTextField.tintColor = theme.colors.ecosia.stateInformation readerModeButton.applyTheme(theme: theme) trackingProtectionButton.applyTheme(theme: theme) diff --git a/firefox-ios/Client/Frontend/Toolbar+URLBar/TabToolbar.swift b/firefox-ios/Client/Frontend/Toolbar+URLBar/TabToolbar.swift index b858b0f0db66..040257c3441d 100644 --- a/firefox-ios/Client/Frontend/Toolbar+URLBar/TabToolbar.swift +++ b/firefox-ios/Client/Frontend/Toolbar+URLBar/TabToolbar.swift @@ -153,11 +153,11 @@ extension TabToolbar: ThemeApplicable, PrivateModeUI { privateModeBadge.badge.tintBackground(color: theme.colors.layer1) warningMenuBadge.badge.tintBackground(color: theme.colors.layer1) */ - backgroundColor = .legacyTheme.ecosia.barBackground + backgroundColor = theme.colors.ecosia.barBackground actionButtons.forEach { $0.applyTheme(theme: theme) } - privateModeBadge.badge.tintBackground(color: .legacyTheme.ecosia.barBackground) - warningMenuBadge.badge.tintBackground(color: .legacyTheme.ecosia.barBackground) + privateModeBadge.badge.tintBackground(color: theme.colors.ecosia.barBackground) + warningMenuBadge.badge.tintBackground(color: theme.colors.ecosia.barBackground) } func applyUIMode(isPrivate: Bool, theme: Theme) { diff --git a/firefox-ios/Client/Frontend/Toolbar+URLBar/ToolbarButton.swift b/firefox-ios/Client/Frontend/Toolbar+URLBar/ToolbarButton.swift index 6a32b53347fc..2f5a66ffc54d 100644 --- a/firefox-ios/Client/Frontend/Toolbar+URLBar/ToolbarButton.swift +++ b/firefox-ios/Client/Frontend/Toolbar+URLBar/ToolbarButton.swift @@ -83,7 +83,7 @@ extension ToolbarButton: ThemeApplicable { selectedTintColor = theme.colors.actionPrimary disabledTintColor = theme.colors.iconDisabled */ - selectedTintColor = .legacyTheme.ecosia.primaryBrand + selectedTintColor = theme.colors.ecosia.brandPrimary disabledTintColor = UIColor.Photon.Grey30 unselectedTintColor = theme.colors.iconPrimary tintColor = isEnabled ? unselectedTintColor : disabledTintColor diff --git a/firefox-ios/Client/Frontend/Toolbar+URLBar/URLBarView.swift b/firefox-ios/Client/Frontend/Toolbar+URLBar/URLBarView.swift index 8f93386e7516..127f33f71694 100644 --- a/firefox-ios/Client/Frontend/Toolbar+URLBar/URLBarView.swift +++ b/firefox-ios/Client/Frontend/Toolbar+URLBar/URLBarView.swift @@ -86,9 +86,7 @@ class URLBarView: UIView, } } } - // Ecosia: Update `locationActiveBorderColor` - // @objc dynamic lazy var locationActiveBorderColor: UIColor = .clear { - @objc dynamic lazy var locationActiveBorderColor = UIColor.legacyTheme.ecosia.primaryButton { + @objc dynamic lazy var locationActiveBorderColor: UIColor = .clear { didSet { if inOverlayMode { locationContainer.layer.borderColor = locationActiveBorderColor.cgColor @@ -338,8 +336,6 @@ class URLBarView: UIView, // Ecosia: ProgressBar sits at the back of the LocationView locationView.addSubview(progressBar) locationView.sendSubviewToBack(progressBar) - // Ecosia: Update Search Engine Image - updateSearchEngineImage() profile.searchEnginesManager.delegate = self @@ -1059,17 +1055,19 @@ extension URLBarView: ThemeApplicable { cancelTintColor = theme.colors.textPrimary showQRButtonTintColor = theme.colors.textPrimary - // Ecosia: update background - // backgroundColor = theme.colors.layer1 - // line.backgroundColor = theme.colors.borderPrimary - backgroundColor = .legacyTheme.ecosia.primaryBackground - line.backgroundColor = .legacyTheme.ecosia.barSeparator + /* Ecosia: update background + backgroundColor = theme.colors.layer1 + line.backgroundColor = theme.colors.borderPrimary + */ + backgroundColor = theme.colors.ecosia.backgroundPrimary + line.backgroundColor = theme.colors.ecosia.barSeparator locationBorderColor = theme.colors.borderPrimary - // Ecosia: Take into account overlay mode for `locationView` background - // locationView.backgroundColor = theme.colors.layer3 - // locationContainer.backgroundColor = theme.colors.layer3 - locationView.backgroundColor = inOverlayMode ? .legacyTheme.ecosia.primaryBackground : .legacyTheme.ecosia.tertiaryBackground + /* Ecosia: Take into account overlay mode for `locationView` background + locationView.backgroundColor = theme.colors.layer3 + locationContainer.backgroundColor = theme.colors.layer3 + */ + locationView.backgroundColor = inOverlayMode ? theme.colors.ecosia.backgroundPrimary : theme.colors.ecosia.backgroundTertiary locationContainer.backgroundColor = locationView.backgroundColor /* Ecosia: Remove private mode badge @@ -1077,11 +1075,13 @@ extension URLBarView: ThemeApplicable { */ // Ecosia: Update Search Image Color - searchIconImageView.tintColor = isPrivate ? UIColor.legacyTheme.ecosia.primaryText : UIColor.legacyTheme.ecosia.textfieldIconTint + searchIconImageView.tintColor = isPrivate ? theme.colors.ecosia.textPrimary : theme.colors.ecosia.buttonBackgroundPrimary warningMenuBadge.badge.tintBackground(color: theme.colors.layer1) // Ecosia: Update UI Elements with helper updateUIElementsWithTheme(theme) + // Ecosia: Update Search Engine Image + updateSearchEngineImage() } } @@ -1116,12 +1116,13 @@ extension URLBarView: PrivateModeUI { extension URLBarView { func updateUIElementsWithTheme(_ theme: Theme) { - progressBar.backgroundColor = .legacyTheme.ecosia.tertiaryBackground - progressBar.setGradientColors(startColor: .legacyTheme.ecosia.highlightedBackground, - middleColor: .legacyTheme.ecosia.highlightedBackground, - endColor: .legacyTheme.ecosia.highlightedBackground) + progressBar.backgroundColor = theme.colors.ecosia.backgroundTertiary + progressBar.setGradientColors(startColor: theme.colors.ecosia.backgroundHighlighted, + middleColor: theme.colors.ecosia.backgroundHighlighted, + endColor: theme.colors.ecosia.backgroundHighlighted) locationTextField?.applyUIMode(isPrivate: isPrivate, theme: theme) locationTextField?.applyTheme(theme: theme) + locationActiveBorderColor = theme.colors.ecosia.buttonBackgroundPrimary } } @@ -1133,7 +1134,7 @@ extension URLBarView { if isPrivate { searchIconImageView.image = .templateImageNamed(StandardImageIdentifiers.Large.privateMode)?.tinted(withColor: locationActiveBorderColor) } else { - searchIconImageView.image = .init(themed: "searchLogo") + searchIconImageView.image = .init(named: "searchLogo") } } else { searchIconImageView.image = .templateImageNamed("searchUrl") diff --git a/firefox-ios/Client/Frontend/Widgets/OneLineTableViewCell.swift b/firefox-ios/Client/Frontend/Widgets/OneLineTableViewCell.swift index b19ffa95fd0d..45fc7c8463e9 100644 --- a/firefox-ios/Client/Frontend/Widgets/OneLineTableViewCell.swift +++ b/firefox-ios/Client/Frontend/Widgets/OneLineTableViewCell.swift @@ -184,6 +184,6 @@ class OneLineTableViewCell: UITableViewCell, leftImageView.tintColor = theme.colors.textPrimary // Ecosia: update tint color - tintColor = UIColor.legacyTheme.ecosia.primaryButton + tintColor = theme.colors.ecosia.buttonBackgroundPrimary } } diff --git a/firefox-ios/Client/Frontend/Widgets/SiteTableViewController.swift b/firefox-ios/Client/Frontend/Widgets/SiteTableViewController.swift index 9f0cd0792d83..124a05a81208 100644 --- a/firefox-ios/Client/Frontend/Widgets/SiteTableViewController.swift +++ b/firefox-ios/Client/Frontend/Widgets/SiteTableViewController.swift @@ -181,7 +181,7 @@ class SiteTableViewController: UIViewController, header.textLabel?.textColor = themeManager.getCurrentTheme(for: windowUUID).colors.textPrimary header.contentView.backgroundColor = themeManager.getCurrentTheme(for: windowUUID).colors.layer1 */ - header.textLabel?.textColor = .legacyTheme.ecosia.secondaryText + header.textLabel?.textColor = themeManager.getCurrentTheme(for: windowUUID).colors.ecosia.textSecondary header.contentView.backgroundColor = .clear } } diff --git a/firefox-ios/Client/Frontend/Widgets/SiteTableViewHeader.swift b/firefox-ios/Client/Frontend/Widgets/SiteTableViewHeader.swift index d16c1eb2d49e..f019889c5c3b 100644 --- a/firefox-ios/Client/Frontend/Widgets/SiteTableViewHeader.swift +++ b/firefox-ios/Client/Frontend/Widgets/SiteTableViewHeader.swift @@ -104,9 +104,9 @@ class SiteTableViewHeader: UITableViewHeaderFooterView, ThemeApplicable, Reusabl backgroundView?.backgroundColor = theme.colors.layer1 collapsibleImageView.image = collapsibleState?.image?.tinted(withColor: theme.colors.iconAccent) */ - titleLabel.textColor = UIColor.legacyTheme.ecosia.secondaryText + titleLabel.textColor = theme.colors.ecosia.textSecondary backgroundView?.backgroundColor = .clear - collapsibleImageView.image = collapsibleState?.image?.tinted(withColor: .legacyTheme.ecosia.secondaryText) + collapsibleImageView.image = collapsibleState?.image?.tinted(withColor: theme.colors.ecosia.textSecondary) bordersHelper.applyTheme(theme: theme) } diff --git a/firefox-ios/Client/Frontend/Widgets/ToggleButton.swift b/firefox-ios/Client/Frontend/Widgets/ToggleButton.swift index 82b94bb6842b..203871d9ae4f 100644 --- a/firefox-ios/Client/Frontend/Widgets/ToggleButton.swift +++ b/firefox-ios/Client/Frontend/Widgets/ToggleButton.swift @@ -8,7 +8,8 @@ private struct UX { /* Ecosia: Update background color static let BackgroundColor = UIColor.Photon.Purple60 */ - static let BackgroundColor = UIColor.legacyTheme.ecosia.secondaryBrand + // TODO: Do we also need to handle `white` on Dark Theme? + static let BackgroundColor = UIColor.Photon.Grey60 // The amount of pixels the toggle button will expand over the normal size. // This results in the larger -> contract animation. diff --git a/firefox-ios/EcosiaTests/PrivateModeButtonTests.swift b/firefox-ios/EcosiaTests/PrivateModeButtonTests.swift index 45e3a254cd2e..c6578852cd17 100644 --- a/firefox-ios/EcosiaTests/PrivateModeButtonTests.swift +++ b/firefox-ios/EcosiaTests/PrivateModeButtonTests.swift @@ -20,8 +20,8 @@ final class PrivateModeButtonTests: XCTestCase { LegacyThemeManager.instance.current = LegacyNormalTheme() button.applyUIMode(isPrivate: true, theme: lightTheme) - XCTAssertEqual(button.tintColor, .legacyTheme.ecosia.primaryBackground) - XCTAssertEqual(button.imageView?.tintColor, .legacyTheme.ecosia.primaryBackground) + XCTAssertEqual(button.tintColor, lightTheme.colors.ecosia.backgroundPrimary) + XCTAssertEqual(button.imageView?.tintColor, lightTheme.colors.ecosia.backgroundPrimary) XCTAssertEqual(button.backgroundLayer.backgroundColor, UIColor.Photon.Grey70.cgColor) XCTAssertEqual(button.accessibilityValue, .TabTrayToggleAccessibilityValueOn) } diff --git a/firefox-ios/firefox-ios-tests/Tests/ClientTests/StatusBarOverlayTests.swift b/firefox-ios/firefox-ios-tests/Tests/ClientTests/StatusBarOverlayTests.swift index d5ff1e734b89..5a5f370c5ae8 100644 --- a/firefox-ios/firefox-ios-tests/Tests/ClientTests/StatusBarOverlayTests.swift +++ b/firefox-ios/firefox-ios-tests/Tests/ClientTests/StatusBarOverlayTests.swift @@ -12,6 +12,7 @@ class StatusBarOverlayTests: XCTestCase { private var profile: MockProfile! private var wallpaperManager: WallpaperManagerMock! private var notificationCenter: MockNotificationCenter! + private let theme = LightTheme() override func setUp() { super.setUp() @@ -33,9 +34,10 @@ class StatusBarOverlayTests: XCTestCase { XCTAssertFalse(subject.hasTopTabs) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testOnHomepage_withoutWallpaperWithBottomURLBar_isOpaque() throws { @@ -45,9 +47,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: true) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testOnHomepage_withoutWallpaperWithTopURLBar_isOpaque() throws { @@ -57,9 +60,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: true) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testOnHomepage_withWallpaperWithBottomURLBar_notOpaque() throws { @@ -73,9 +77,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: true) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(0).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(0).cgColor) } func testOnHomepage_withWallpaperWithTopURLBar_isOpaque() throws { @@ -89,9 +94,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: true) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testOnWebpage_withoutWallpaperWithBottomURLBar_isOpaque() throws { @@ -101,9 +107,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: false) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testOnWebpage_withoutWallpaperWithTopURLBar_isOpaque() throws { @@ -113,9 +120,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: false) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testOnWebpage_withWallpaperWithBottomURLBar_isOpaque() throws { @@ -129,9 +137,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: false) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testOnWebpage_withWallpaperWithTopURLBar_isOpaque() throws { @@ -145,9 +154,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: false) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer1.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testHasTopTabs_onHomepageWithoutWallpaperWithTopURLBar_isOpaque() throws { @@ -157,9 +167,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: true) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testHasTopTabs_onHomepageWithWallpaperWithTopURLBar_isOpaque() throws { @@ -174,9 +185,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: true) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testHasTopTabs_onWebpageWithoutWallpaperWithTopURLBar_isOpaque() throws { @@ -187,9 +199,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: false) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } func testHasTopTabs_onWebpageWithWallpaperWithTopURLBar_isOpaque() throws { @@ -204,9 +217,10 @@ class StatusBarOverlayTests: XCTestCase { subject.resetState(isHomepage: false) let backgroundColor = try XCTUnwrap(subject.backgroundColor) - // Ecosia: Update expected background color - // XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) - XCTAssertEqual(backgroundColor.cgColor, UIColor.legacyTheme.ecosia.primaryBackground.withAlphaComponent(1).cgColor) + /* Ecosia: Update expected background color + XCTAssertEqual(backgroundColor.cgColor, LightTheme().colors.layer3.withAlphaComponent(1).cgColor) + */ + XCTAssertEqual(backgroundColor.cgColor, theme.colors.ecosia.backgroundPrimary.withAlphaComponent(1).cgColor) } private func createSubject(hasTopTabs: Bool = false) -> StatusBarOverlay { @@ -214,7 +228,7 @@ class StatusBarOverlayTests: XCTestCase { notificationCenter: notificationCenter, wallpaperManager: wallpaperManager) subject.hasTopTabs = hasTopTabs - subject.applyTheme(theme: LightTheme()) + subject.applyTheme(theme: theme) trackForMemoryLeaks(subject) return subject }