CAITheme
public enum CAITheme : CustomStringConvertible
Available themes to consume by your application
CAI provides 2 themes:
- Fiori. Follows SAP Fiori Design Language. Mostly used in Enterprise context
- Casual. Mostly used in Community context
Both provide support light & dark mode.
You can also provide you own custom theme.
For Casual and Fiori, you only need to provide a Color palette. We have a default color palette for both of them but you can provide your own Color palette.
If you want to use a custom theme, you need to provide a Theme struct as well as a Color palette for it and it’s your responsibility to support light & dark mode. @see Theme.Key to know what keys you can configure.
-
Undocumented
Declaration
Swift
case casual(ColorPalette) -
Fiori theme follows SAP Fiori Design Language
Declaration
Swift
case fiori(ColorPalette) -
Undocumented
Declaration
Swift
case custom(Theme, ColorPalette) -
Get ColorPalette (read-only)
Declaration
Swift
public var palette: ColorPalette { get } -
Get underlying Theme object (read-only)
Declaration
Swift
public var theme: Theme { get } -
Binds this method in your SwiftUI Views to get the color for the current theme
Declaration
Swift
public func color(for key: Theme.Color.Key) -> ColorParameters
keyTheme.Key
Return Value
Color
-
Binds this method in your SwiftUI Views to get the value for the current theme
Declaration
Swift
public func value(for key: Theme.Key) -> Any?Parameters
keyTheme.Key
Return Value
Any. Nil if key is not found
-
Binds this method in your SwiftUI Views to get the value for the current theme
Declaration
Swift
public func value<T>(for key: Theme.Key, type: T.Type, defaultValue: T) -> TParameters
keyTheme.Key
TypeExpected Type T that this value should be
defaultValueDefault value to return if key does not exist OR is of wrong type
Return Value
Value of type T
-
Binds this method in your SwiftUI Views to get the value for the current theme
Declaration
Swift
public func value<T>(for key: Theme.Key, type: T.Type) -> T?Parameters
keyTheme.Key
TypeExpected Type T that this value should be
Return Value
Value of type T?