Skip to content

Commit 01240ec

Browse files
pylappludovic35
andauthored
fix: code sample text alignment for RTL mode in Design Toolbox (#554) (#569)
Signed-off-by: Pierre-Yves Lapersonne <[email protected]> Co-authored-by: LudovicPinel <[email protected]>
1 parent e15f69f commit 01240ec

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323

2424
### Fixed
2525

26+
- [DesignToolbox] In RTL mode code sample text not aligned on the left ([#554](https://github.com/Orange-OpenSource/ouds-ios/issues/554))
2627
- [DesignToolbox] Chevron for navigation link pointing to bad direction in RTL mode ([#553](https://github.com/Orange-OpenSource/ouds-ios/issues/553))
2728
- [DesignToolbox] Broken wording in radio button page
2829
- [DesignToolbox] Update Checkbox and Radio button assets on the screen of component list ([#519](https://github.com/Orange-OpenSource/ouds-ios/issues/519))

DesignToolbox/DesignToolbox/Pages/Utils/DesignToolboxCode.swift

+8-6
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ import SwiftUI
1717

1818
struct DesignToolboxCode: View {
1919

20-
// MARK: Environment properties
21-
22-
@Environment(\.theme) private var theme
23-
@Environment(\.colorScheme) private var colorScheme
24-
2520
// MARK: Stored properties
2621

27-
@State private var isCodeVisible = false
2822
let code: String
2923
let titleText: LocalizedStringKey
3024

25+
@State private var isCodeVisible = false
26+
27+
@Environment(\.theme) private var theme
28+
@Environment(\.colorScheme) private var colorScheme
29+
@Environment(\.layoutDirection) private var layoutDirection
30+
3131
// MARK: Body
3232

3333
var body: some View {
@@ -71,6 +71,8 @@ struct DesignToolboxCode: View {
7171
.font(.system(.body, design: .monospaced))
7272
.foregroundStyle(theme.colors.colorContentDefault.color(for: colorScheme))
7373
.padding(.vertical, theme.spaces.spacePaddingInlineShort)
74+
.multilineTextAlignment(layoutDirection == .rightToLeft ? .trailing : .leading)
75+
// As the source code sample is written in english, keep text aligned on the left
7476

7577
Spacer(minLength: theme.spaces.spacePaddingBlockMedium)
7678

0 commit comments

Comments
 (0)