Skip to content

Commit 0c847ed

Browse files
committed
docs: add details about flip of icons with layout direction
Signed-off-by: Pierre-Yves Lapersonne <[email protected]>
1 parent e74fc47 commit 0c847ed

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

OUDS/Core/Components/Sources/_OUDSComponents.docc/_OUDSComponents.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ myView.oudsShadow(theme.elevations.drag)
3535
```
3636

3737
In details how it works:
38-
```
38+
```swift
3939
// In the theme this "drag" has been defined for example like:
4040
@objc open var drag: ElevationCompositeSemanticToken { ElevationCompositeSemanticToken(ElevationRawTokens.bottom_3_500) }
4141

@@ -124,6 +124,25 @@ someView.oudsBackground(theme.colors.bgPrimary)
124124
someView.oudsAccentColor(theme.colors.bgPrimary)
125125
```
126126

127+
## Flip images according to layouts
128+
129+
Images bring meanings, and are used in components. But sometimes, depending to your layouts (right to left (RTL) or left to right (LTR)), if the whole layout
130+
of your app changes, the images in use can loose meanings or have another one (except if they are asymetruc).
131+
If your application manages several languages with RTL and LTR, here is a simple trick to flip the icons depending to the layout.
132+
133+
```swift
134+
// Get the layout direction in your View
135+
@Environment(\.layoutDirection) private var layoutDirection
136+
137+
// Because by default icons are not flipped, i.e. more LTR flavoured, use a simple comparison
138+
// (layoutDirection == .rightToLeft)
139+
140+
// For example in a checkbox item
141+
OUDSCheckboxItem(...,
142+
flipIcon: (layoutDirection == .rightToLeft),
143+
)
144+
```
145+
127146
## Change font family according to locale or preferred language
128147

129148
If you use for example one of the Orange themes, you may for sure use the *Helvetica Neue* font family.

0 commit comments

Comments
 (0)