Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOB-3152] Refactor Ecosia theming #834

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1918287
[MOB-3152] Introduce color primitives and review semantic colors
lucaschifino Jan 24, 2025
760f72c
[MOB-3152] Introduce EcosiaSemanticColors into color palette
lucaschifino Jan 27, 2025
18f7da0
[MOB-3152] Move ecosia color palette to common and use it on global T…
lucaschifino Jan 27, 2025
d74ddc9
[MOB-3152] Replace EcosiaTheme.primaryBrand
lucaschifino Jan 27, 2025
e53c023
[MOB-3152] Replace EcosiaTheme.secondaryBrand
lucaschifino Jan 27, 2025
2f1f909
[MOB-3152] Replace EcosiaTheme.border
lucaschifino Jan 27, 2025
442264f
[MOB-3152] Replace EcosiaTheme.primaryBackground
lucaschifino Jan 27, 2025
f5f1f51
[MOB-3152] Replace EcosiaTheme.secondaryBackground
lucaschifino Jan 27, 2025
b50adbe
[MOB-3152] Replace EcosiaTheme.tertiaryBackground
lucaschifino Jan 27, 2025
99c88f2
[MOB-3152] Replace EcosiaTheme.quarternaryBackground
lucaschifino Jan 27, 2025
f20525a
[MOB-3152] Replace EcosiaTheme.barBackground
lucaschifino Jan 27, 2025
7a30f80
[MOB-3152] Replace EcosiaTheme.barSeparator
lucaschifino Jan 27, 2025
ee7795d
[MOB-3152] Remove unnecessary impact and tree counter colors
lucaschifino Jan 27, 2025
11a2d95
[MOB-3152] Replace ntp specific colors
lucaschifino Jan 27, 2025
1deea28
[MOB-3152] Replace EcosiaTheme.impactMultiplyCardBackground
lucaschifino Jan 27, 2025
f64ce2a
[MOB-3152] Replace news specific colors
lucaschifino Jan 28, 2025
0791490
[MOB-3152] Replace action sheet specific colors
lucaschifino Jan 28, 2025
53df07d
[MOB-3152] Replace modal specific colors
lucaschifino Jan 28, 2025
cdc96eb
[MOB-3152] Replace EcosiaTheme.primaryText
lucaschifino Jan 28, 2025
bbfac82
[MOB-3152] Replace EcosiaTheme.primaryTextInverted
lucaschifino Jan 28, 2025
e4f25d6
[MOB-3152] Replace remaining text colors
lucaschifino Jan 28, 2025
1227ff2
[MOB-3152] Replace icon colors
lucaschifino Jan 28, 2025
b9ac881
[MOB-3152] Replace background state colors
lucaschifino Jan 28, 2025
ea5581d
[MOB-3152] Replace EcosiaTheme.primaryButton and primaryButtonActive
lucaschifino Jan 28, 2025
9cca7d4
[MOB-3152] Replace remaining button colors
lucaschifino Jan 28, 2025
20566c9
[MOB-3152] Replace textfield specific colors
lucaschifino Jan 28, 2025
2732071
[MOB-3152] Replace EcosiaTheme.privateButtonBackground
lucaschifino Jan 28, 2025
409f6a8
[MOB-3152] Rename EcosiaColorPrimitive to EcosiaColor
lucaschifino Jan 28, 2025
1a22d1f
[MOB-3152] Remove unnecessary segment colors
lucaschifino Jan 28, 2025
53099d2
[MOB-3152] Replace state colors
lucaschifino Jan 28, 2025
ab69350
[MOB-3152] Replace tab colors
lucaschifino Jan 28, 2025
93ee1c7
[MOB-3152] Replace EcosiaTheme.toastImageTint
lucaschifino Jan 28, 2025
c7886d1
[MOB-3152] Replace EcosiaTheme.autocompleteBackground
lucaschifino Jan 28, 2025
c5e11ef
[MOB-3152] Replace onboarding specific colors
lucaschifino Jan 28, 2025
c33b2fc
[MOB-3152] Replace EcosiaTheme.homePanelBackground
lucaschifino Jan 28, 2025
3f9923c
[MOB-3152] Replace EcosiaTheme.peach
lucaschifino Jan 28, 2025
6150149
[MOB-3152] Remove unused LegacyTheme variables
lucaschifino Jan 29, 2025
7f8e825
[MOB-3152] Replace UIImage themed custom init and delete EcosiaTheme
lucaschifino Jan 29, 2025
b8ffcbe
[MOB-3152] Replace LegacyTheme.tabTray
lucaschifino Jan 29, 2025
e005c06
[MOB-3152] Replace LegacyTheme.tableView
lucaschifino Jan 29, 2025
941805a
[MOB-3152] Remove recovered LegacyTheme and LegacyThemeManager
lucaschifino Jan 30, 2025
0815a05
[MOB-3152] Remove unnecessary upgrade todos
lucaschifino Jan 30, 2025
9a0d8f4
[MOB-3152] Review and adjust new Firefox colors
lucaschifino Jan 30, 2025
8ceb257
[MOB-3152] Remove color check todos
lucaschifino Jan 30, 2025
0fc1e60
[MOB-3152] Remove unnecessary themable properties
lucaschifino Jan 30, 2025
2c5b038
[MOB-3152] Fix lint
lucaschifino Jan 30, 2025
24a4ac7
[MOB-3152] Remove EcosiaDarkTheme comment
lucaschifino Jan 30, 2025
7593e92
[MOB-3152] [MOB-3159] Use ThemeApplicable on views to avoid null windows
lucaschifino Jan 31, 2025
f00805b
[MOB-3152] Revert temporary fallback for null theme window
lucaschifino Jan 31, 2025
5abf06b
[MOB-3152] Remove hidden snowflake and old firefox color
lucaschifino Feb 3, 2025
1cd08d8
[MOB-3152] Remove unused snowflake
lucaschifino Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions BrowserKit/Sources/Common/Theming/DarkTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}
Expand All @@ -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
Expand Down
114 changes: 114 additions & 0 deletions BrowserKit/Sources/Common/Theming/EcosiaThemeColourPalette.swift
Original file line number Diff line number Diff line change
@@ -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
}
10 changes: 10 additions & 0 deletions BrowserKit/Sources/Common/Theming/LightTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions BrowserKit/Sources/Common/Theming/PrivateModeTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions BrowserKit/Sources/Common/Theming/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
4 changes: 0 additions & 4 deletions BrowserKit/Sources/Common/Theming/ThemeColourPalette.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading
Loading