Skip to content

31 ‐ About the themes

Pierre-Yves Lapersonne edited this page Dec 18, 2024 · 3 revisions

The theme concept

A theme is, a fact, a big massive bucket of semantic tokens. We choose to pack all semantic tokens in protocols, so as to force any theme to manage them. Because Swift does not have notions of abstract classes compared to Kotlin, we have choosen to define an OUDSTheme which can be considered like an almost-abstract class.

Then, a white label theme may just inherit from this class and override the tokens it needs and must check in its side all tokens are defined (there are troubles with colors). The real, default theme to use, will be the OrangeTheme providing in its module brand colors and overriding some tokens with the suitable values. In fact, because the OUDSTheme and the OrangeTheme are isolated, the OUDSTheme cannot get the Orange brand colors, so some tokens cannot be defined at that level but remain overridable in the subclass (see this page for more details).

The object oriented paradigm implementation in Swift is a bit different that the one found with Java or Kotlin. For example we do not have abstract classes and Swift relies a lot in composition with protocols and extensions. Thus a theme can be composed using protocols containing as properties the semantics tokens. These tokens must also be overridable. Any default values and logic can be in a kind of fake abstract class named OUDSTheme. This theme will be then subclassed using OOP inheritance in the real default theme named OrangeTheme. Any other theme can be a subclass of OrangeTheme (e.g. country specific theme) or OUDSTheme (for white label).

Themes must be able to override semantic tokens and components tokens, and use their own raw tokens without sharing them to other themes. The existing raw tokens, shared between all themes, are not overridable because their definitions are frozen.

Here is a chart about about theme are designed:

OUDS - iOS - Chart - Themes classes diagram (v7)

Here is chart focused on OrangeTheme:

OUDS - iOS - Chart - Orange Theme (v1)

Available themes

Today two themes are avaialble but their definitions are still in progress:

They both are based on a kind of abstract theme (OUDS Theme)