Skip to content

Commit

Permalink
fix trading rewards background image (#97)
Browse files Browse the repository at this point in the history
* remove background image

* support for image theming
  • Loading branch information
mike-dydx authored Feb 27, 2024
1 parent 024ec0a commit 0393417
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions PlatformUI/PlatformUI/DesignSystem/Theme/SampleTheme.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "sample",
"themeColor": {
"layer": {
"lowest": "#000000",
Expand Down
1 change: 1 addition & 0 deletions PlatformUI/PlatformUI/DesignSystem/Theme/ThemeConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class ThemeSettings: ObservableObject, SingletonProtocol {
// MARK: - ThemeConfig

public struct ThemeConfig: Codable, Equatable {
public let id: String
public let themeColor: ThemeColor
public let themeFont: ThemeFont
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ private struct GradientColorModifier: ViewModifier {
}

public extension Image {
/// iniitalizes an image that supports app themes
/// - Parameters:
/// - themedImageBaseName: the base image name. e.g. if the app supports 3 themes and the corresponding themed image names are "circle_light" "circle_dark" and "circle_classic_dark" then your base name is "circle"
/// - bundle: the bundle
init(themedImageBaseName: String, bundle: Bundle, themeSettings: ThemeSettings = ThemeSettings.shared) {
self.init(themedImageBaseName + "_" + "\(themeSettings.themeConfig.id)", bundle: bundle)
}

func templateColor(_ foreground: ThemeColor.SemanticColor?) -> some View {
if let foreground = foreground {
return AnyView(self.renderingMode(.template).themeColor(foreground: foreground))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "texture.pdf",
"filename" : "texture 1.pdf",
"idiom" : "universal"
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "texture 1.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "texture_light.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
1 change: 1 addition & 0 deletions dydx/dydxViews/dydxViews/Themes/ThemeClassicDark.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "classic_dark",
"themeColor": {
"color": {
"text_primary": "#FAFAFD",
Expand Down
1 change: 1 addition & 0 deletions dydx/dydxViews/dydxViews/Themes/ThemeDark.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "dark",
"themeColor": {
"color": {
"text_primary": "#FAFAFA",
Expand Down
1 change: 1 addition & 0 deletions dydx/dydxViews/dydxViews/Themes/ThemeLight.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"id": "light",
"themeColor": {
"color": {
"text_primary": "#181818",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class dydxRewardsLaunchIncentivesViewModel: PlatformViewModel {
}
.padding(.all, 16)
.background {
Image("texture", bundle: .dydxView)
Image(themedImageBaseName: "texture", bundle: .dydxView)
.resizable()
.scaledToFill()
}
Expand Down

0 comments on commit 0393417

Please sign in to comment.