Skip to content

Commit

Permalink
refactor(review): more rename from wrappers to providers (#79)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
  • Loading branch information
pylapp committed Dec 17, 2024
1 parent cab6821 commit dee4293
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- [Library] New architecture with tokens wrapper ([#79](https://github.com/Orange-OpenSource/ouds-ios/issues/79))
- [Library] New architecture with tokens provider ([#79](https://github.com/Orange-OpenSource/ouds-ios/issues/79))
- [DemoApp] Prepare new architecture to add components illustration ([#328](https://github.com/Orange-OpenSource/ouds-ios/issues/328))

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ You can enrich the ``OrangeTheme`` by subclassing it or by overriding some token

You may want to define your own theme, thus you can override the ``OrangeTheme`` with your own class or just override the providers.

You will have to override the tokens wrapper you need. To do that, make a subclass of the wrapper you target:
You will have to override the tokens provider you need. To do that, make a subclass of the provider you target:
- spaces tokens are `OUDSSpaceSemanticTokensProvider`
- sizes tokens are in `OUDSSizeSemanticTokensProvider`
- colors tokens are all defined in `OrangeThemeColorSemanticTokensProvider`
Expand All @@ -78,7 +78,7 @@ You will have to override the tokens wrapper you need. To do that, make a subcla
import OUDSTokensSemantic // To use semantic tokens if needed
import OUDSTokensRaw // To use raw tokens if needed

// Token wrapper for spaces
// Token provider for spaces

class YourAppThemeSpaceTokensProvider: OUDSSpaceSemanticTokensProvider {
override var spaceFixedMedium: SpaceSemanticToken {
Expand All @@ -89,7 +89,7 @@ class YourAppThemeSpaceTokensProvider: OUDSSpaceSemanticTokensProvider {
}
}

// Token wrapper for sizes
// Token provider for sizes

class YourAppThemeSizeTokensProvider: OUDSSizeSemanticTokensProvider {
override var sizeIconDecorative2xl: SizeSemanticToken {
Expand All @@ -100,7 +100,7 @@ class YourAppThemeSizeTokensProvider: OUDSSizeSemanticTokensProvider {
}
}

// Token wrapper for colors
// Token provider for colors

class YourAppThemeColorTokensProvider: OrangeThemeColorSemanticTokensProvider {
override var colorBgSecondary: MultipleColorSemanticTokens {
Expand All @@ -111,7 +111,7 @@ class YourAppThemeColorTokensProvider: OrangeThemeColorSemanticTokensProvider {
}
}

// Token wrapper for border
// Token provider for border

class YourAppThemeBorderTokensProvider: OUDSBorderSemanticTokensProvider {
override var borderStyleDefault: BorderStyleSemanticToken {
Expand All @@ -125,23 +125,23 @@ class YourAppThemeBorderTokensProvider: OUDSBorderSemanticTokensProvider {
}
}

// Token wrapper for elevation
// Token provider for elevation

class YourAppThemeElevationTokensProvider: OUDSElevationSemanticTokensProvider {
override var elevationStickyEmphasized: ElevationCompositeSemanticToken {
ElevationCompositeSemanticToken(ElevationRawTokens.elevationBottom_4_600)
}
}

// Token wrapper for opacity
// Token provider for opacity

class YourAppThemeOpacityTokensProvider: OUDSOpacitySemanticTokensProvider {
override var opacityStrong: OpacitySemanticToken {
OpacityRawTokens.opacity920
}
}

// Token wrapper for grid
// Token provider for grid

class YourAppThemeGridTokensProvider: OUDSGridSemanticTokensProvider {
override var gridExtraCompactColumnGap: GridSemanticToken {
Expand All @@ -155,7 +155,7 @@ class YourAppThemeGridTokensProvider: OUDSGridSemanticTokensProvider {
}
}

// Token wrapper for font
// Token provider for font

class YourAppThemeFontTokensProvider: OUDSFontSemanticTokensProvider {
override var typeDisplayLarge: MultipleFontCompositeRawTokens {
Expand Down Expand Up @@ -209,7 +209,7 @@ struct YourApp: App {

### By overriding

Quite simple and similar to the previous solution, but give only the wrapper to the ``OrangeTheme``.
Quite simple and similar to the previous solution, but give only the provider to the ``OrangeTheme``.

For example for colors:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **border semantic tokens** and expose them.
/// This wrapper should be integrated as a ``AllBorderSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllBorderSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for border semantic tokens
/// // Define your own provider for border semantic tokens
/// class CustomBorderTokensProvider: OUDSBorderSemanticTokensProvider {
///
/// // Then override the border semantic tokens you want, using the border raw tokens available
Expand Down Expand Up @@ -53,7 +53,7 @@ import OUDSFoundations
/// ```
open class OUDSBorderSemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSBorderSemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **color semantic tokens**, *multiple* or not, and expose them.
/// This wrapper should be integrated as a ``AllColorSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllColorSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for color semantic tokens
/// // Define your own provider for color semantic tokens
/// class CustomColorTokensProviderr: OUDSColorSemanticTokensProvider {
///
/// // Then override the color semantic tokens you want, using the color raw tokens available
Expand Down Expand Up @@ -51,7 +51,7 @@ import OUDSFoundations
/// ```
open class OUDSColorSemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSColorSemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **elevation semantic tokens**, *multiple*, *composite* or not, and expose them.
/// This wrapper should be integrated as a ``AllElevationSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllElevationSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for elevation semantic tokens
/// // Define your own provider for elevation semantic tokens
/// class CustomElevationTokensProvider: OUDSElevationSemanticTokensProvider {
///
/// // Then override the elevation semantic tokens you want, using the elevation raw tokens available
Expand Down Expand Up @@ -47,7 +47,7 @@ import OUDSFoundations
/// ```
open class OUDSElevationSemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSElevationSemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **font semantic tokens**, *multiple*, *composite* or not, and expose them.
/// This wrapper should be integrated as a ``AllFontSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllFontSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for font semantic tokens
/// // Define your own provider for font semantic tokens
/// class CustomFontTokensProvider: OUDSFontSemanticTokensProvider {
///
/// // Then override the font semantic tokens you want, using the font raw tokens available
Expand Down Expand Up @@ -51,7 +51,7 @@ import OUDSFoundations
/// ```
open class OUDSFontSemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSFontSemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **grid semantic tokens** and expose them.
/// This wrapper should be integrated as a ``AllGridSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllGridSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for grid semantic tokens
/// // Define your own provider for grid semantic tokens
/// class CustomGridTokensProvider: OUDSGridSemanticTokensProvider {
///
/// // Then override the grid semantic tokens you want, using the grid raw tokens available
Expand Down Expand Up @@ -55,7 +55,7 @@ import OUDSFoundations
/// ```
open class OUDSGridSemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSGridSemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **opacity semantic tokens** and expose them.
/// This wrapper should be integrated as a ``AllOpacitySemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllOpacitySemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for opacity semantic tokens
/// // Define your own provider for opacity semantic tokens
/// class CustomOpacityTokensProvider: OUDSOpacitySemanticTokensProvider {
///
/// // Then override the opacity semantic tokens you want, using the opacity raw tokens available
Expand Down Expand Up @@ -47,7 +47,7 @@ import OUDSFoundations
/// ```
open class OUDSOpacitySemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSOpacitySemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **size semantic tokens**, *multiple* or not, and expose them.
/// This wrapper should be integrated as a ``AllSizeSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllSizeSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for size semantic tokens
/// // Define your own provider for size semantic tokens
/// class CustomSizeTokensProvider: OUDSSizeSemanticTokensProvider {
///
/// // Then override the size semantic tokens you want, using the dimension raw tokens available
Expand Down Expand Up @@ -51,7 +51,7 @@ import OUDSFoundations
/// ```
open class OUDSSizeSemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSSizeSemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import OUDSFoundations

/// A class which wraps all **space semantic tokens**, *multiple* or not, and expose them.
/// This wrapper should be integrated as a ``AllSpaceSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// This provider should be integrated as a ``AllSpaceSemanticTokens`` implementation inside `OUDSTheme` so as to provide
/// all tokens to the users. It helps users to override some of the tokens and assign them to an `OUDSTheme` implementation to use.
///
/// ```swift
/// // Define your own wrapper for space semantic tokens
/// // Define your own provider for space semantic tokens
/// class CustomSpaceTokensProvider: OUDSSpaceSemanticTokensProvider {
///
/// // Then override the space semantic tokens you want, using the dimension raw tokens available
Expand Down Expand Up @@ -51,7 +51,7 @@ import OUDSFoundations
/// ```
open class OUDSSpaceSemanticTokensProvider {

/// Intializes the wrapper
/// Intializes the provider
public init() {
OUDSLogger.debug("Init of OUDSSpaceSemanticTokensProvider")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@ public typealias AllOpacitySemanticTokens = OpacitySemanticTokens
public typealias AllGridSemanticTokens = GridSemanticTokens

/// A type alias which merges ``ColorSemanticTokens`` and ``ColorMultipleSemanticTokens``.
/// It helps in the end to define a wrapper for all the semantic tokens of colors, multiple or not, generated or not.
/// It helps in the end to define a provider for all the semantic tokens of colors, multiple or not, generated or not.
/// For example ``OUDSColorSemanticTokensProvider`` matches this type alias.
public typealias AllColorSemanticTokens = ColorSemanticTokens & ColorMultipleSemanticTokens

/// A type alias which merges ``ElevationSemanticTokens``, ``ElevationCompositeSemanticTokens`` and ``ElevationMultipleSemanticTokens``.
/// It helps in the end to define a wrapper for all the semantic tokens of elevations, multiple or not, generated or not.
/// It helps in the end to define a provider for all the semantic tokens of elevations, multiple or not, generated or not.
/// For example ``OUDSElevationSemanticTokensProvider`` matches this type alias.
public typealias AllElevationSemanticTokens = ElevationSemanticTokens & ElevationCompositeSemanticTokens & ElevationMultipleSemanticTokens

/// A type alias which merges ``FontSemanticTokens``, ``FontCompositeSemanticTokens`` and ``FontMultipleSemanticTokens``.
/// It helps in the end to define a wrapper for all the semantic tokens of fonts, multiple, composite, or not, generated or not.
/// It helps in the end to define a provider for all the semantic tokens of fonts, multiple, composite, or not, generated or not.
/// For example ``OUDSFontSemanticTokensProvider`` matches this type alias.
public typealias AllFontSemanticTokens = FontSemanticTokens & FontCompositeSemanticTokens & FontMultipleSemanticTokens

/// A type alias which merges ``SizeSemanticTokens`` and ``SizeMultipleSemanticTokens``.
/// It helps in the end to define a wrapper for all the semantic tokens of size, multiple or not, generated or not.
/// It helps in the end to define a provider for all the semantic tokens of size, multiple or not, generated or not.
/// For example ``OUDSSizeSemanticTokensProvider`` matches this type alias.
public typealias AllSizeSemanticTokens = SizeSemanticTokens & SizeMultipleSemanticTokens

/// A type alias which merges ``SpaceSemanticTokens`` and ``SpaceMultipleSemanticTokens``.
/// It helps in the end to define a wrapper for all the semantic tokens of space, multiple or not, generated or not.
/// It helps in the end to define a provider for all the semantic tokens of space, multiple or not, generated or not.
/// For example ``OUDSSpaceSemanticTokensProvider`` matches this type alias.
public typealias AllSpaceSemanticTokens = SpaceSemanticTokens & SpaceMultipleSemanticTokens
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ protocol ColorSemanticTokens {
// ...
}

// Ensure you have a wrapper
// Ensure you have a provider
open class OUDSColorSemanticTokensProvider { }

// Define the semantic tokens to expose through the theme thanks to the wrapper
// Define the semantic tokens to expose through the theme thanks to the provider
extension OUDSColorSemanticTokensProvider: ColorSemanticTokens {

// Color is available in the module of OUDSTheme
Expand Down Expand Up @@ -75,10 +75,10 @@ public protocol ColorMultipleSemanticTokens { ... }
// These protoocols are merged in type aliase
public typealias AllColorSemanticTokens = ColorSemanticTokens & ColorMultipleSemanticTokens

// For example, the wrapper for the colors basically is:
// For example, the provider for the colors basically is:
open class OUDSColorSemanticTokensProvider { ... }

// The wrapper is composed by protocols containing tokens
// The provider is composed by protocols containing tokens
extension OUDSColorSemanticTokensProvider: ColorSemanticTokens {
@objc open var colorOpacityInvisibleBlackLight: ColorSemanticToken { ColorRawTokens.colorOpacityBlack0 }
@objc open var colorOpacityInvisibleWhiteLight: ColorSemanticToken { ColorRawTokens.colorOpacityWhite0 }
Expand All @@ -87,12 +87,12 @@ extension OUDSColorSemanticTokensProvider: ColorMultipleSemanticTokens {
@objc open var colorOpacityInvisibleBlack: MultipleColorSemanticTokens { MultipleColorSemanticTokens(light: colorOpacityInvisibleBlackLight, dark: colorOpacityInvisibleBlackDark) }
}

// The "abstract" object of theme expose the wrapper through this subset of protocols
// The "abstract" object of theme expose the provider through this subset of protocols
open class OUDSTheme: @unchecked Sendable {
public let colors: AllColorSemanticTokens
}

// And finaly, the default theme, which can be subclassed, exposes the tokens through the wrapper
// And finaly, the default theme, which can be subclassed, exposes the tokens through the provider
open class OrangeTheme: OUDSTheme, @unchecked Sendable { ... }

theme.colors.colorOpacityInvisibleBlack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import XCTest

// swiftlint:disable required_deinit

/// To ensure the `MultipleColorRawToken` is tested as a wrapper of semantic tokens for light and dark color schemes.
/// To ensure the `MultipleColorRawToken` is tested as a provider of semantic tokens for light and dark color schemes.
final class MultipleColorRawTokenTests: XCTestCase {

/// Tests if the unique value is applied for light and dark modes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import XCTest

// swiftlint:disable required_deinit

/// To ensure the `MultipleElevationCompositeRawTokens` is tested as a wrapper of semantic tokens for light and dark color schemes.
/// To ensure the `MultipleElevationCompositeRawTokens` is tested as a provider of semantic tokens for light and dark color schemes.
final class MultipleElevationCompositeRawTokensTests: XCTestCase {

/// Tests if the unique value is applied for light and dark modes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import XCTest
// swiftlint:disable required_deinit
// swiftlint:disable type_name

/// To ensure the `MultipleFontLetterSpacingSemanticTokens` is tested as a wrapper of semantic tokens for compact and regular size classes.
/// To ensure the `MultipleFontLetterSpacingSemanticTokens` is tested as a provider of semantic tokens for compact and regular size classes.
final class MultipleFontLetterSpacingSemanticTokensTests: XCTestCase {

/// Tests if the unique value is applied for light and dark modes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import XCTest
// swiftlint:disable required_deinit
// swiftlint:disable type_name

/// To ensure the `MultipleFontLineHeightSemanticTokens` is tested as a wrapper of semantic tokens for compact and regular size classes.
/// To ensure the `MultipleFontLineHeightSemanticTokens` is tested as a provider of semantic tokens for compact and regular size classes.
final class MultipleFontLineHeightSemanticTokensTests: XCTestCase {

/// Tests if the unique value is applied for light and dark modes
Expand Down
Loading

0 comments on commit dee4293

Please sign in to comment.