-
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.
Browse files
Browse the repository at this point in the history
Signed-off-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com> Co-authored-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com> Reviewed-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com> Tested-by: Pierre-Yves Lapersonne <pierreyves.lapersonne@orange.com>
- Loading branch information
Showing
22 changed files
with
448 additions
and
7 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
100 changes: 100 additions & 0 deletions
100
.../OUDS/Sources/OUDSTheme/OUDSTheme+SemanticTokens/OUDSTheme+GridSemanticTokensHelper.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,100 @@ | ||
// | ||
// 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 | ||
|
||
extension OUDSTheme { | ||
|
||
// MARK: Semantic Grid token - Helper | ||
|
||
/// The min column width of a grid. | ||
/// - Parameter sizeClass: The current interface size class | ||
/// - Returns `GridRawToken`: The minimal width according to viewports / size classes. | ||
public final func gridMinWidth(for sizeClass: OUDSUserInterfaceSizeClass) -> GridRawToken { | ||
switch sizeClass { | ||
case .extraCompact: | ||
return gridExtraCompactMinWidth | ||
case .compact: | ||
return gridCompactMinWidth | ||
case .regular: | ||
return gridRegularMinWidth | ||
@unknown default: | ||
fatalError("🤖 Raw token unavailable for \(sizeClass)!") | ||
} | ||
} | ||
|
||
/// The max column width of a grid. | ||
/// - Parameter sizeClass: The current interface size class | ||
/// - Returns `GridRawToken`: The maximal width according to viewports / size classes. | ||
public final func gridMaxWidth(for sizeClass: OUDSUserInterfaceSizeClass) -> GridRawToken { | ||
switch sizeClass { | ||
case .extraCompact: | ||
return gridExtraCompactMaxWidth | ||
case .compact: | ||
return gridCompactMaxWidth | ||
case .regular: | ||
return gridRegularMaxWidth | ||
@unknown default: | ||
fatalError("🤖 Raw token unavailable for \(sizeClass)!") | ||
} | ||
} | ||
|
||
/// The margin of a grid. | ||
/// - Parameter sizeClass: The current interface size class | ||
/// - Returns `GridRawToken`: The margin according to viewports / size classes. | ||
public final func gridMargin(for sizeClass: OUDSUserInterfaceSizeClass) -> GridRawToken { | ||
switch sizeClass { | ||
case .extraCompact: | ||
return gridExtraCompactMargin | ||
case .compact: | ||
return gridCompactMargin | ||
case .regular: | ||
return gridRegularMargin | ||
@unknown default: | ||
fatalError("🤖 Raw token unavailable for \(sizeClass)!") | ||
} | ||
} | ||
|
||
/// The column gap of a grid. | ||
/// - Parameter sizeClass: The current interface size class | ||
/// - Returns `GridRawToken`: The column gap according to viewports / size classes. | ||
public final func gridColumnGap(for sizeClass: OUDSUserInterfaceSizeClass) -> GridRawToken { | ||
switch sizeClass { | ||
case .extraCompact: | ||
return gridExtraCompactColumnGap | ||
case .compact: | ||
return gridCompactColumnGap | ||
case .regular: | ||
return gridRegularColumnGap | ||
@unknown default: | ||
fatalError("🤖 Raw token unavailable for \(sizeClass)!") | ||
} | ||
} | ||
|
||
/// The column count of a grid. | ||
/// - Parameter sizeClass: The current interface size class | ||
/// - Returns `GridRawToken`: The column count according to viewports / size classes. | ||
public final func gridColumnCount(for sizeClass: OUDSUserInterfaceSizeClass) -> GridRawToken { | ||
switch sizeClass { | ||
case .extraCompact: | ||
return gridExtraCompactColumnCount | ||
case .compact: | ||
return gridCompactColumnCount | ||
case .regular: | ||
return gridRegularColumnCount | ||
@unknown default: | ||
fatalError("🤖 Raw token unavailable for \(sizeClass)!") | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// 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 SwiftUICore | ||
import UIKit | ||
|
||
// MARK: - Environment values | ||
|
||
private struct HorizontalSizeClassEnvironmentKey: EnvironmentKey { | ||
|
||
static let defaultValue = OUDSUserInterfaceSizeClass.regular | ||
} | ||
|
||
private struct VerticalSizeClassEnvironmentKey: EnvironmentKey { | ||
|
||
static let defaultValue = OUDSUserInterfaceSizeClass.regular | ||
} | ||
|
||
extension EnvironmentValues { | ||
|
||
/// The `OUDSUserInterfaceSizeClass` instance exposed as en environment values across the library for the horizontal viewport. | ||
/// | ||
/// You receive a ``OUDSUserInterfaceSizeClass`` value when you read this environment value. | ||
/// The value tells you about the amount of horizontal space available to the view that reads it. | ||
/// You can read this size class like any other of the ``EnvironmentValues``, by creating a property with the ``Environment`` property wrapper: | ||
/// | ||
/// @Environment(\.oudsHorizontalSizeClass) private var horizontalSizeClass | ||
/// | ||
public var oudsHorizontalSizeClass: OUDSUserInterfaceSizeClass { | ||
get { | ||
self[HorizontalSizeClassEnvironmentKey.self] | ||
} | ||
set { | ||
self[HorizontalSizeClassEnvironmentKey.self] = newValue | ||
} | ||
} | ||
|
||
/// The `OUDSUserInterfaceSizeClass` instance exposed as en environment values across the library for the vertical viewport. | ||
/// | ||
/// You receive a ``OUDSUserInterfaceSizeClass`` value when you read this environment value. | ||
/// The value tells you about the amount of vertical space available to the view that reads it. | ||
/// You can read this size class like any other of the ``EnvironmentValues``, by creating a property with the ``Environment`` property wrapper: | ||
/// | ||
/// @Environment(\.oudsVerticalSizeClass) private var verticalSizeClass | ||
/// | ||
public var oudsVerticalSizeClass: OUDSUserInterfaceSizeClass { | ||
get { | ||
self[VerticalSizeClassEnvironmentKey.self] | ||
} | ||
set { | ||
self[VerticalSizeClassEnvironmentKey.self] = newValue | ||
} | ||
} | ||
} | ||
|
||
/// Enumerates the size classes defined by the design system. | ||
/// The __extraCompact__ size class if for screens with width < 389. | ||
/// The __compact__ and __regular__ size classes are the standard Apple classes. | ||
/// | ||
/// See: https://developer.apple.com/design/human-interface-guidelines/layout#iOS-iPadOS-device-size-classes | ||
/// Remark: This enum is defined as a string to easily display its raw value. | ||
public enum OUDSUserInterfaceSizeClass: String, Sendable { | ||
case extraCompact = "Extra Compact" | ||
case compact = "Compact" | ||
case regular = "Regular" | ||
} |
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
2 changes: 1 addition & 1 deletion
2
Showcase/Showcase.xcworkspace/xcshareddata/swiftpm/Package.resolved
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
28 changes: 28 additions & 0 deletions
28
Showcase/Showcase/Pages/Tokens/Grid/GridTokenElement.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,28 @@ | ||
// | ||
// 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 SwiftUI | ||
|
||
struct GridTokenElement: TokenElement { | ||
let name: String | ||
let imageName: String | ||
let description: String | ||
let pageDescription: AnyView | ||
|
||
init() { | ||
name = "app_tokens_grid_label" | ||
imageName = "ic_grid" | ||
description = "app_tokens_grid_description_text" | ||
pageDescription = AnyView(GridTokenPage()) | ||
} | ||
} |
Oops, something went wrong.