-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #421 Assisted-by: GPT-4o-mini (Dinootoo) Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
- Loading branch information
Showing
12 changed files
with
289 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...ange/Sources/Providers/ComponentTokens/OrangeThemeCheckRadioComponentTokensProvider.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import OUDS | ||
import OUDSFoundations | ||
import OUDSTokensSemantic | ||
|
||
// swiftlint:disable type_name | ||
|
||
/// A class which wraps all **component tokens of check radio** for *radio button* and *checkboxes* objects | ||
/// like `OUDSRadioButton` or `OUDSCheckbox`. | ||
/// Contains also references to semantic tokens providers so as to be able to use them to define the component tokens. | ||
/// This provider should be integrated as a `AllCheckRadioComponentTokensProvider` 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. | ||
/// Custom themes can use subclass of ``OrangeThemeCheckRadioComponentTokensProvider`` and apply the provider they need. | ||
/// It implements also the protocol `CheckRadioComponentTokens` so as to expose the component tokens for *radio button* | ||
/// and *checkboxes* through any `OUDSTheme`. | ||
/// *Radio button* and *checkboxes* components tokens are defined with raw and semantic tokens of sizes (from `AllSizeSemanticTokensProvider`), | ||
/// and dimensions (`DimensionRawTokens`). These components share the same type of tokens which are all gather here. | ||
/// | ||
/// ```swift | ||
/// // Define your own provider for radio / check component tokens | ||
/// // by inheriting from existing provider | ||
/// class CustomCheckRadioComponentTokensProvider: OrangeThemeCheckRadioComponentTokensProvider { | ||
/// | ||
/// // Then override the radio / check component tokens you want. | ||
/// | ||
/// override var checkRadioSize: SizeSemanticToken { sizes.sizeIconWithLabelLargeSizeXl } | ||
/// | ||
/// override var checkRadioSizeMaxHeightAssetsContainer: DimensionRawToken { DimensionRawTokens.dimension1000 } | ||
/// | ||
/// // ... | ||
/// } | ||
/// | ||
/// // Or define your own provider from scratch | ||
/// class CustomCheckRadioComponentTokensProvider: CheckRadioComponentTokens { | ||
/// | ||
/// // And implement hunders of tokens. | ||
/// // You are allowed to give semantic tokens providers if you want to define values. | ||
/// } | ||
/// ``` | ||
/// | ||
/// Then, you can give this `CustomCheckRadioComponentTokensProvider` to your own theme implementation: | ||
/// | ||
/// ```swift | ||
/// class LocalTheme: OrangeTheme { | ||
/// | ||
/// override init() { | ||
/// super.init(tokensProviders: [ CustomCheckRadioComponentTokensProvider(), ... ]) | ||
/// } | ||
/// } | ||
/// ``` | ||
/// | ||
/// or to an already existing theme for example: | ||
/// | ||
/// ```swift | ||
/// OrangeTheme(tokensProviders: [ CustomCheckRadioComponentTokensProvider(), ... ]) | ||
/// ``` | ||
/// | ||
/// - Since: 0.10.0 | ||
open class OrangeThemeCheckRadioComponentTokensProvider: AllCheckRadioComponentTokensProvider { | ||
|
||
/// Provider of size semantic tokens to use for check / radio sizes | ||
public let sizes: AllSizeSemanticTokensProvider | ||
|
||
/// Defines a provider of component tokens dedicated to `OUDSChip` | ||
/// - Parameter sizes: Provider for size semantic tokens | ||
public init(sizes: AllSizeSemanticTokensProvider) { | ||
OL.debug("Init of OrangeThemeCheckRadioComponentTokensProvider") | ||
self.sizes = sizes | ||
} | ||
|
||
deinit { } | ||
|
||
// ଘ( ・ω・)_/゚・:*:・。☆ | ||
// Note: So as to help the integration of generated code produced by the tokenator | ||
// the implemention of CheckRadioComponentTokens is not here but in Core/Themes/Orange/Values/ComponentTokens/OrangeTheme+CheckRadioComponentTokens.swift | ||
// This declaration of OrangeThemeCheckRadioComponentTokensProvider is here also to allow to write documentation. | ||
} | ||
|
||
// swiftlint:enable type_name |
30 changes: 30 additions & 0 deletions
30
...e/Themes/Orange/Sources/Values/ComponentTokens/OrangeTheme+CheckRadioComponenTokens.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import Foundation | ||
import OUDSTokensComponent | ||
import OUDSTokensRaw | ||
import OUDSTokensSemantic | ||
|
||
// ଘ( ・ω・)_/゚・:*:・。☆ | ||
// [File to generate with the tokenator] | ||
// Values are not the expected ones, manual fixes have been added | ||
// Create an issue for update https://github.com/Orange-OpenSource/ouds-ios/issues/new?template=token_update.yml | ||
|
||
extension OrangeThemeCheckRadioComponentTokensProvider: CheckRadioComponentTokens { | ||
@objc open var checkRadioSize: SizeSemanticToken { sizes.sizeIconWithLabelLargeSizeSm } | ||
@objc open var checkRadioSizeMinHeightSelectorOnly: DimensionRawToken { DimensionRawTokens.dimension600 } | ||
@objc open var checkRadioSizeMinWidthSelectorOnly: DimensionRawToken { DimensionRawTokens.dimension600 } | ||
@objc open var checkRadioSizeMaxHeightSelectorOnly: DimensionRawToken { DimensionRawTokens.dimension600 } | ||
@objc open var checkRadioSizeMaxHeightAssetsContainer: DimensionRawToken { DimensionRawTokens.dimension1200 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...range/Tests/Values/ComponentTokens/MockTheme/MockTheme+AllCheckRadioComponentTokens.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import Foundation | ||
import OUDS | ||
import OUDSThemesOrange | ||
import OUDSTokensComponent | ||
import OUDSTokensRaw | ||
import OUDSTokensSemantic | ||
|
||
// swiftlint:disable required_deinit | ||
// swiftlint:disable type_name | ||
|
||
final class MockThemeCheckRadioComponentTokenProvider: OrangeThemeCheckRadioComponentTokensProvider { | ||
|
||
// MARK: - Mocks and setup | ||
|
||
static let mockThemeCheckRadioSize: SizeSemanticToken = 118_218 | ||
static let mockThemeCheckRadioDimension: DimensionRawToken = 1_312 | ||
|
||
override public init(sizes: AllSizeSemanticTokensProvider) { | ||
super.init(sizes: sizes) | ||
} | ||
|
||
// MARK: - Badge component tokens | ||
|
||
override public var checkRadioSize: SizeSemanticToken { Self.mockThemeCheckRadioSize } | ||
override public var checkRadioSizeMinHeightSelectorOnly: DimensionRawToken { Self.mockThemeCheckRadioDimension } | ||
override public var checkRadioSizeMinWidthSelectorOnly: DimensionRawToken { Self.mockThemeCheckRadioDimension } | ||
override public var checkRadioSizeMaxHeightSelectorOnly: DimensionRawToken { Self.mockThemeCheckRadioDimension } | ||
override public var checkRadioSizeMaxHeightAssetsContainer: DimensionRawToken { Self.mockThemeCheckRadioDimension } | ||
} | ||
|
||
// swiftlint:enable required_deinit | ||
// swiftlint:enable type_name |
64 changes: 64 additions & 0 deletions
64
...mes/Orange/Tests/Values/ComponentTokens/TestThemeOverrideOCheckRadioComponentTokens.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import OUDS | ||
import OUDSThemesOrange | ||
import XCTest | ||
|
||
// swiftlint:disable required_deinit | ||
// swiftlint:disable implicitly_unwrapped_optional | ||
// swiftlint:disable type_name | ||
|
||
final class TestThemeOverrideOfCheckRadioComponentTokens: XCTestCase { | ||
|
||
private var abstractTheme: OUDSTheme! | ||
private var inheritedTheme: OUDSTheme! | ||
|
||
override func setUp() async throws { | ||
abstractTheme = OrangeTheme() | ||
inheritedTheme = MockTheme() | ||
} | ||
|
||
// MARK: - Sizes | ||
|
||
func testInheritedThemeCanOverrideCheckRadioComponentTokenSize() throws { | ||
XCTAssertNotEqual(inheritedTheme.checkRadio.checkRadioSize, abstractTheme.checkRadio.checkRadioSize) | ||
XCTAssertTrue(inheritedTheme.checkRadio.checkRadioSize == MockThemeCheckRadioComponentTokenProvider.mockThemeCheckRadioSize) | ||
} | ||
|
||
// MARK: - Dimensions | ||
|
||
func testInheritedThemeCanOverrideCheckRadioComponentTokenSizeMinHeightSelectorOnly() throws { | ||
XCTAssertNotEqual(inheritedTheme.checkRadio.checkRadioSizeMinHeightSelectorOnly, abstractTheme.checkRadio.checkRadioSizeMinHeightSelectorOnly) | ||
XCTAssertTrue(inheritedTheme.checkRadio.checkRadioSizeMinHeightSelectorOnly == MockThemeCheckRadioComponentTokenProvider.mockThemeCheckRadioDimension) | ||
} | ||
|
||
func testInheritedThemeCanOverrideCheckRadioComponentTokenSizeMinWidthSelectorOnly() throws { | ||
XCTAssertNotEqual(inheritedTheme.checkRadio.checkRadioSizeMinWidthSelectorOnly, abstractTheme.checkRadio.checkRadioSizeMinWidthSelectorOnly) | ||
XCTAssertTrue(inheritedTheme.checkRadio.checkRadioSizeMinWidthSelectorOnly == MockThemeCheckRadioComponentTokenProvider.mockThemeCheckRadioDimension) | ||
} | ||
|
||
func testInheritedThemeCanOverrideCheckRadioComponentTokenSizeMaxHeightSelectorOnly() throws { | ||
XCTAssertNotEqual(inheritedTheme.checkRadio.checkRadioSizeMaxHeightSelectorOnly, abstractTheme.checkRadio.checkRadioSizeMaxHeightSelectorOnly) | ||
XCTAssertTrue(inheritedTheme.checkRadio.checkRadioSizeMaxHeightSelectorOnly == MockThemeCheckRadioComponentTokenProvider.mockThemeCheckRadioDimension) | ||
} | ||
|
||
func testInheritedThemeCanOverrideCheckRadioComponentTokenSizeMaxHeightAssetsContainer() throws { | ||
XCTAssertNotEqual(inheritedTheme.checkRadio.checkRadioSizeMaxHeightAssetsContainer, abstractTheme.checkRadio.checkRadioSizeMaxHeightAssetsContainer) | ||
XCTAssertTrue(inheritedTheme.checkRadio.checkRadioSizeMaxHeightAssetsContainer == MockThemeCheckRadioComponentTokenProvider.mockThemeCheckRadioDimension) | ||
} | ||
} | ||
|
||
// swiftlint:enable required_deinit | ||
// swiftlint:enable implicitly_unwrapped_optional | ||
// swiftlint:enable type_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
OUDS/Core/Tokens/ComponentTokens/Sources/Values/CheckRadioComponentTokens.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// | ||
// Software Name: OUDS iOS | ||
// SPDX-FileCopyrightText: Copyright (c) Orange SA | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// This software is distributed under the MIT license, | ||
// the text of which is available at https://opensource.org/license/MIT/ | ||
// or see the "LICENSE" file for more details. | ||
// | ||
// Authors: See CONTRIBUTORS.txt | ||
// Software description: A SwiftUI components library with code examples for Orange Unified Design System | ||
// | ||
|
||
import OUDSTokensRaw | ||
import OUDSTokensSemantic | ||
|
||
// [File not generated by the tokenator] | ||
// WARNING: Not synchronized anymore with the Figjam / Figma by developers team | ||
// Create an issue for update https://github.com/Orange-OpenSource/ouds-ios/issues/new?template=token_update.yml | ||
|
||
// swiftlint:disable missing_docs | ||
|
||
/// Declares all component tokens for radio button and checkboxes components like `OUDSRadioButton` and `OUDSCheckbox`. | ||
/// Use for tokens providers like `OrangeThemeCheckRadioComponentTokensProvider`. | ||
/// | ||
/// - Since: 0.10.0 | ||
public protocol CheckRadioComponentTokens { | ||
|
||
// MARK: - Sizes | ||
|
||
var checkRadioSize: SizeSemanticToken { get } | ||
|
||
// MARK: - Dimensions | ||
|
||
var checkRadioSizeMinHeightSelectorOnly: DimensionRawToken { get } | ||
var checkRadioSizeMinWidthSelectorOnly: DimensionRawToken { get } | ||
var checkRadioSizeMaxHeightSelectorOnly: DimensionRawToken { get } | ||
var checkRadioSizeMaxHeightAssetsContainer: DimensionRawToken { get } | ||
} | ||
|
||
// swiftlint:enable missing_docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters