FUIThemeManager

public class FUIThemeManager

Manager class which supplies color palette values to Fiori components, and the UIColor.preferredFioriColor(...) API.

Changes made to the manager affect all future calls to UIColor.preferredFioriColor(...). Most components do not reload dynamically, so calls to the ThemeManager should happen at the beginning of the application lifecycle.

Note

AppDelegate.didFinishLaunching(withOptions...) is the recommended location.

Example Usage

// Pin palette version used by application to a specific version (defaults to `.latest`)
FUIThemeManager.shared.setPaletteVersion(.v3_x)

// Override some color definitions to match your application palette
FUIThemeManager.shared.setColor(.darkGray, for: .primary2, background: .light)
FUIThemeManager.shared.setHexColor("1b931d", for: .positive, background: .light)
  • Singleton instance shared by all application components.

    Declaration

    Swift

    public static let shared: FUIThemeManager
  • Method to allow selecting a specific version of the palette. Defaults to latest.

    Declaration

    Swift

    public func setPaletteVersion(_ version: FUIPaletteVersion)

    Parameters

    version

    Major version of the Fiori Design Guidelines. Note: does not match exactly to SDK release; v3 is introduced with SDK version 3.0 SP02.

  • Method to allow supplying a complete custom palette implementation.

    Note

    It is more typical to use setColor(...), or setHexColor(...) to override specific palette values than to provide a full implementation.

    Declaration

    Swift

    public func setPalette(_ palette: FUIPalette)

    Parameters

    palette

    Complete palette implementation. Should include definitions for all consumed FUIColorStyle types.

  • Accessor to current palette.

    Note

    It is unusual to need to read from the palette directly; generally, use the UIColor.preferredFioriColor(...) API.

    Declaration

    Swift

    public private(set) var palette: FUIPalette { get set }
  • Helper method, to clear any override colors set via setColor(...) or setHexColor(...). Does not affect the base definition of the current palette.

    Declaration

    Swift

    public func reset()
  • Method to supply a custom definition for a particular FUIColorStyle. Will be applied to .light background color scheme.

    Declaration

    Swift

    public func setColor(_ color: UIColor, for style: FUIColorStyle)

    Parameters

    color

    Color definition to override the base definition in the palette.

    style

    Reference of FUIColorStyle to which color is bound.

  • Method to supply a custom definition for a particular FUIColorStyle and FUIColorVariant combination.

    Note

    A nil value for background will default to .light.

    Declaration

    Swift

    public func setColor(_ color: UIColor, for style: FUIColorStyle, variant: FUIColorVariant?)

    Parameters

    color

    Color definition to override the base definition in the palette.

    style

    Reference of FUIColorStyle to which color is bound.

    variant

    Reference of FUIColorVariant to which color is bound. Defaults to .light. If no value is supplied for .dark, the value for .light will be read as a fallback.

  • Method to supply a custom definition for a particular FUIColorStyle. Will applied to .light background color scheme.

    Declaration

    Swift

    public func setHexColor(_ hex: String, for style: FUIColorStyle)

    Parameters

    hex

    Color definition as hexidecimal string to override the base definition in the palette.

    style

    Reference of FUIColorStyle to which color is bound.

  • Method to supply a custom definition for a particular FUIColorStyle and FUIColorVariant combination.

    Declaration

    Swift

    public func setHexColor(_ hex: String, for style: FUIColorStyle, variant: FUIColorVariant)

    Parameters

    hex

    Color definition as hexidecimal string to override the base definition in the palette.

    style

    Reference of FUIColorStyle to which color is bound.

    variant

    Reference of FUIColorVariant to which color is bound. Defaults to .light. If no value is supplied for .dark, the value for .light will be read as a fallback.