From 2e6917e86c5fecdc5dfabc02905f192917316566 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Lapersonne Date: Tue, 17 Dec 2024 12:05:22 +0100 Subject: [PATCH] refactor(review): rename wrapper to provider for tokens of spaces (#79) Signed-off-by: Pierre-Yves Lapersonne --- .../OUDSTheme+SpaceMultipleSemanticTokens.swift | 4 ++-- .../OUDSTheme+SpaceSemanticTokens.swift | 2 +- OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift | 4 ++-- OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md | 4 ++-- .../MockThemes/MockTheme+AllSpaceSemanticTokens.swift | 4 ++-- OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift | 4 ++-- .../Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md | 4 ++-- ...rapper.swift => OUDSSpaceSemanticTokensProvider.swift} | 8 ++++---- .../Wrappers/SemanticTokensWrappers+TypeAliases.swift | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) rename OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/{OUDSSpaceSemanticTokensWrapper.swift => OUDSSpaceSemanticTokensProvider.swift} (88%) diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceMultipleSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceMultipleSemanticTokens.swift index eca84f902b..cc1b685fbb 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceMultipleSemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceMultipleSemanticTokens.swift @@ -20,8 +20,8 @@ import OUDSTokensSemantic // Create an issue for update https://github.com/Orange-OpenSource/ouds-ios/issues/new?template=token_update.yml /// Defines wrapper objects for space semantic tokens (i.e. in the end `DimensionRawTokens`). -/// These values can be overriden inside ``OUDSSpaceSemanticTokensWrapper`` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination. -extension OUDSSpaceSemanticTokensWrapper: SpaceMultipleSemanticTokens { +/// These values can be overriden inside ``OUDSSpaceSemanticTokensProvider`` subclasses (in extensions or not, in the same module or not) thanks to the `@objc open` combination. +extension OUDSSpaceSemanticTokensProvider: SpaceMultipleSemanticTokens { // MARK: Semantic token - Spacing - Layout fluid diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceSemanticTokens.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceSemanticTokens.swift index 3a009a4ca0..1bd780e9a8 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceSemanticTokens.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceSemanticTokens.swift @@ -15,7 +15,7 @@ import Foundation import OUDSTokensRaw import OUDSTokensSemantic -extension OUDSSpaceSemanticTokensWrapper: SpaceSemanticTokens { +extension OUDSSpaceSemanticTokensProvider: SpaceSemanticTokens { @objc open var spaceColumnGapMedium: SpaceSemanticToken { DimensionRawTokens.dimension150 } @objc open var spaceColumnGapNone: SpaceSemanticToken { DimensionRawTokens.dimension0 } @objc open var spaceColumnGapShort: SpaceSemanticToken { DimensionRawTokens.dimension100 } diff --git a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift index 4611fd2271..224b04bb60 100644 --- a/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift +++ b/OUDS/Core/OUDS/Sources/OUDSTheme/OUDSTheme.swift @@ -70,7 +70,7 @@ open class OUDSTheme: @unchecked Sendable { /// - grids: An object providing all the grid semantic tokens, by default `OUDSGridSemanticTokensProvider` /// - opacities: An object providing all the opacity semantic tokens, by default `OUDSOpacitySemanticTokensProvider` /// - sizes: An object providing all the size semantic tokens, by default `OUDSSizeSemanticTokensProvider` - /// - spaces: An object providing all the space semantic tokens, by default `OUDSSpaceSemanticTokensWrapper` + /// - spaces: An object providing all the space semantic tokens, by default `OUDSSpaceSemanticTokensProvider` public init(colors: AllColorSemanticTokens = OUDSColorSemanticTokensProvider(), borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(), elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(), @@ -78,7 +78,7 @@ open class OUDSTheme: @unchecked Sendable { grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(), opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensProvider(), sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensProvider(), - spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) { + spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensProvider()) { self.colors = colors self.borders = borders self.elevations = elevations diff --git a/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md b/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md index e12000c13c..fb33d7b28b 100644 --- a/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md +++ b/OUDS/Core/OUDS/Sources/_OUDS.docc/Themes.md @@ -54,7 +54,7 @@ If your theme needs to define its own _raw tokens_, you can also define them usi You may want to define your own theme, thus you can override the `OrangeTheme` with your own class or just override the wrappers. You will have to override the tokens wrapper you need. To do that, make a subclass of the wrapper you target: -- spaces tokens are `OUDSSpaceSemanticTokensWrapper` +- spaces tokens are `OUDSSpaceSemanticTokensProvider` - sizes tokens are in `OUDSSizeSemanticTokensProvider` - colors tokens are all defined in `OrangeThemeColorSemanticTokensWrapper` - borders tokens are in `OUDSBorderSemanticTokensProvider` @@ -71,7 +71,7 @@ import OUDSTokensRaw // To use raw tokens if needed // Token wrapper for spaces -class YourAppThemeSpaceTokensWrapper: OUDSSpaceSemanticTokensWrapper { +class YourAppThemeSpaceTokensWrapper: OUDSSpaceSemanticTokensProvider { override var spaceFixedMedium: SpaceSemanticToken { DimensionRawTokens.dimension400 } diff --git a/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllSpaceSemanticTokens.swift b/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllSpaceSemanticTokens.swift index 5fa8c2f7bf..d0f6646f52 100644 --- a/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllSpaceSemanticTokens.swift +++ b/OUDS/Core/OUDS/Tests/OUDSTheme/MockThemes/MockTheme+AllSpaceSemanticTokens.swift @@ -16,9 +16,9 @@ import OUDSTokensSemantic // swiftlint:disable required_deinit -/// Overrides **all** the space semantic tokens (from its super class, i.e. `OUDSSpaceSemanticTokensWrapper` so as to test overriding of them (unit tests) +/// Overrides **all** the space semantic tokens (from its super class, i.e. `OUDSSpaceSemanticTokensProvider` so as to test overriding of them (unit tests) /// and to act like smoke tests with crashing tests if some tokens disappeared. -final class MockThemeSpaceSemanticTokensWrapper: OUDSSpaceSemanticTokensWrapper { +final class MockThemeSpaceSemanticTokensWrapper: OUDSSpaceSemanticTokensProvider { static let mockThemeSpaceRawToken: DimensionRawToken = 911 static let mockThemeSpaceSemanticToken = MultipleSpaceSemanticTokens(compact: 1, regular: 151) diff --git a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift index f3aea98e3c..0f61a5d48a 100644 --- a/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift +++ b/OUDS/Core/Themes/Orange/Sources/OrangeTheme.swift @@ -72,7 +72,7 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable { /// - grids: An object providing all the grid semantic tokens, by default `AllGridSemanticTokens`, default set to `OUDSGridSemanticTokensProvider` /// - opacities: An object providing all the opacity semantic tokens, as `OpacitySemanticTokens` implementation, default set to `OUDSOpacitySemanticTokensProvider` /// - sizes: An object providing all the size semantic tokens, as `AllSizeSemanticTokens` implementation, default set to `OUDSSizeSemanticTokensProvider` - /// - spaces: An object providing all the space semantic tokens, as `AllSpaceSemanticTokens` implementation, default set to `OUDSSpaceSemanticTokensWrapper` + /// - spaces: An object providing all the space semantic tokens, as `AllSpaceSemanticTokens` implementation, default set to `OUDSSpaceSemanticTokensProvider` override public init(colors: AllColorSemanticTokens = OrangeThemeColorSemanticTokensWrapper(), borders: AllBorderSemanticTokens = OUDSBorderSemanticTokensProvider(), elevations: AllElevationSemanticTokens = OUDSElevationSemanticTokensProvider(), @@ -80,7 +80,7 @@ open class OrangeTheme: OUDSTheme, @unchecked Sendable { grids: AllGridSemanticTokens = OUDSGridSemanticTokensProvider(), opacities: AllOpacitySemanticTokens = OUDSOpacitySemanticTokensProvider(), sizes: AllSizeSemanticTokens = OUDSSizeSemanticTokensProvider(), - spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensWrapper()) { + spaces: AllSpaceSemanticTokens = OUDSSpaceSemanticTokensProvider()) { OUDSLogger.debug("Init of OrangeTheme") super.init(colors: colors, borders: borders, diff --git a/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md b/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md index ad43c14567..696357a490 100644 --- a/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md +++ b/OUDS/Core/Themes/Orange/Sources/_OUDSThemesOrange.docc/OUDSThemesOrange.md @@ -65,7 +65,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 wrappers. You will have to override the tokens wrapper you need. To do that, make a subclass of the wrapper you target: -- spaces tokens are `OUDSSpaceSemanticTokensWrapper` +- spaces tokens are `OUDSSpaceSemanticTokensProvider` - sizes tokens are in `OUDSSizeSemanticTokensProvider` - colors tokens are all defined in `OrangeThemeColorSemanticTokensWrapper` - borders tokens are in `OUDSBorderSemanticTokensProvider` @@ -80,7 +80,7 @@ import OUDSTokensRaw // To use raw tokens if needed // Token wrapper for spaces -class YourAppThemeSpaceTokensWrapper: OUDSSpaceSemanticTokensWrapper { +class YourAppThemeSpaceTokensWrapper: OUDSSpaceSemanticTokensProvider { override var spaceFixedMedium: SpaceSemanticToken { DimensionRawTokens.dimension400 } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSSpaceSemanticTokensWrapper.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSSpaceSemanticTokensProvider.swift similarity index 88% rename from OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSSpaceSemanticTokensWrapper.swift rename to OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSSpaceSemanticTokensProvider.swift index 6fcb8308d7..f11ee39dce 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSSpaceSemanticTokensWrapper.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/OUDSSpaceSemanticTokensProvider.swift @@ -19,7 +19,7 @@ import OUDSFoundations /// /// ```swift /// // Define your own wrapper for space semantic tokens -/// class CustomSpaceTokensWrapper: OUDSSpaceSemanticTokensWrapper { +/// class CustomSpaceTokensWrapper: OUDSSpaceSemanticTokensProvider { /// /// // Then override the space semantic tokens you want, using the dimension raw tokens available /// @@ -49,11 +49,11 @@ import OUDSFoundations /// ```swift /// OrangeTheme(spaces: CustomSpaceTokensWrapper()) /// ``` -open class OUDSSpaceSemanticTokensWrapper { +open class OUDSSpaceSemanticTokensProvider { /// Intializes the wrapper public init() { - OUDSLogger.debug("Init of OUDSSpaceSemanticTokensWrapper") + OUDSLogger.debug("Init of OUDSSpaceSemanticTokensProvider") } deinit{ } @@ -63,5 +63,5 @@ open class OUDSSpaceSemanticTokensWrapper { // the implemention of SpaceSemanticTokens and SpaceMultipleSemanticTokens are not here // but in OUDS/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceSemanticTokens.swift // and in OUDS/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+SpaceMultipleSemanticTokens.swift. - // This declaration of OUDSSpaceSemanticTokensWrapper is here to allow to write documentation. + // This declaration of OUDSSpaceSemanticTokensProvider is here to allow to write documentation. } diff --git a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift index c6ac2bc39d..6eec008dc1 100644 --- a/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift +++ b/OUDS/Core/Tokens/SemanticTokens/Sources/Wrappers/SemanticTokensWrappers+TypeAliases.swift @@ -48,5 +48,5 @@ public typealias AllSizeSemanticTokens = SizeSemanticTokens & SizeMultipleSemant /// 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. -/// For example ``OUDSSpaceSemanticTokensWrapper`` matches this type alias. +/// For example ``OUDSSpaceSemanticTokensProvider`` matches this type alias. public typealias AllSpaceSemanticTokens = SpaceSemanticTokens & SpaceMultipleSemanticTokens