Skip to content

Commit

Permalink
Expose configurable theme colors through ThemeManager for client cust…
Browse files Browse the repository at this point in the history
…omization

- Added ThemeManager class with functions to customize theme colors such as primary background, label, error background, and more.
- Updated Color extension to pull dynamic color values from ThemeManager.
- Allow client apps to modify theme colors by calling functions like `setLivenessPrimaryBackground()`, `setLivenessPrimaryLabel()`, etc.
- Provides flexibility for client apps to modify color schemes based on their requirements.
  • Loading branch information
hunble committed Jan 14, 2025
1 parent 2af23ba commit d534322
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions Sources/FaceLiveness/ThemeManager.swift
Original file line number Diff line number Diff line change
@@ -60,39 +60,39 @@ public class ThemeManager {
extension ThemeManager {

// Public functions to modify the colors
public func setLivenessPrimaryBackground(light: UIColor, dark: UIColor) {
public func setLivenessPrimaryBackground(light: Color, dark: Color) {
livenessPrimaryBackground = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessPrimaryLabel(light: UIColor, dark: UIColor) {
public func setLivenessPrimaryLabel(light: Color, dark: Color) {
livenessPrimaryLabel = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessBackground(light: UIColor, dark: UIColor) {
public func setLivenessBackground(light: Color, dark: Color) {
livenessBackground = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessLabel(light: UIColor, dark: UIColor) {
public func setLivenessLabel(light: Color, dark: Color) {
livenessLabel = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessErrorBackground(light: UIColor, dark: UIColor) {
public func setLivenessErrorBackground(light: Color, dark: Color) {
livenessErrorBackground = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessErrorLabel(light: UIColor, dark: UIColor) {
public func setLivenessErrorLabel(light: Color, dark: Color) {
livenessErrorLabel = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessWarningBackground(light: UIColor, dark: UIColor) {
public func setLivenessWarningBackground(light: Color, dark: Color) {
livenessWarningBackground = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessWarningLabel(light: UIColor, dark: UIColor) {
public func setLivenessWarningLabel(light: Color, dark: Color) {
livenessWarningLabel = Color.dynamicColors(light: light, dark: dark)
}

public func setLivenessPreviewBorder(light: UIColor, dark: UIColor) {
public func setLivenessPreviewBorder(light: Color, dark: Color) {
livenessPreviewBorder = Color.dynamicColors(light: light, dark: dark)
}
// Add similar functions for other colors as needed...
6 changes: 3 additions & 3 deletions Sources/FaceLiveness/Utilities/Color+DynamicColors.swift
Original file line number Diff line number Diff line change
@@ -9,13 +9,13 @@ import UIKit
import SwiftUI

extension Color {
static func dynamicColors(light: UIColor, dark: UIColor) -> Color {
static func dynamicColors(light: Color, dark: Color) -> Color {
Color(
UIColor(
dynamicProvider: { traitCollection in
switch traitCollection.userInterfaceStyle {
case .dark: return dark
default: return light
case .dark: return UIColor(dark)
default: return UIColor(light)
}
}
)

0 comments on commit d534322

Please sign in to comment.