Skip to content

Commit b4ece59

Browse files
committed
Improve existing documentation
1 parent e121441 commit b4ece59

File tree

3 files changed

+61
-36
lines changed

3 files changed

+61
-36
lines changed

core/src/main/java/com/orange/ouds/core/extensions/OudsLightDarkColorTokenExt.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ import androidx.compose.ui.graphics.Color
1818
import com.orange.ouds.core.theme.isOudsInDarkTheme
1919
import com.orange.ouds.theme.tokens.components.OudsLightDarkColor
2020

21+
/**
22+
* Returns the color corresponding to the current theme mode (Light or Dark).
23+
*
24+
* This extension property checks the current theme state using [isOudsInDarkTheme]
25+
* and returns either the [OudsLightDarkColor.dark] or [OudsLightDarkColor.light] value accordingly.
26+
*
27+
* @return The resolved [Color] for the current theme context.
28+
*/
2129
val OudsLightDarkColor.value: Color
2230
@ReadOnlyComposable
2331
@Composable

core/src/main/java/com/orange/ouds/core/theme/OudsTheme.kt

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import androidx.compose.runtime.compositionLocalOf
2222
import androidx.compose.runtime.staticCompositionLocalOf
2323
import androidx.compose.ui.platform.LocalContext
2424
import com.orange.ouds.core.extensions.isHighContrastModeEnabled
25+
import com.orange.ouds.core.theme.OudsTheme.Tweak.ForceDark
26+
import com.orange.ouds.core.theme.OudsTheme.Tweak.ForceLight
27+
import com.orange.ouds.core.theme.OudsTheme.Tweak.Invert
2528
import com.orange.ouds.theme.OudsDrawableResources
2629
import com.orange.ouds.theme.OudsThemeContract
2730
import com.orange.ouds.theme.OudsThemeSettings
@@ -57,9 +60,11 @@ internal val LocalComponents = staticCompositionLocalOf<OudsComponents> { missin
5760
object OudsTheme {
5861

5962
/**
60-
* Tweak of the current [OudsTheme] which can be passed to [OudsThemeTweak] composable:
61-
* - Invert set theme in dark when app is in light or in light when app is in dark
62-
* - ForceDark and ForceLight force the theme to be in dark or in light
63+
* Defines adjustments that can be applied to the current [OudsTheme] via the [OudsThemeTweak] composable.
64+
*
65+
* @property Invert Inverts the current theme (switches from Light to Dark or Dark to Light).
66+
* @property ForceDark Forces the theme to Dark mode, regardless of the system setting.
67+
* @property ForceLight Forces the theme to Light mode, regardless of the system setting.
6368
*/
6469
enum class Tweak {
6570
Invert, ForceDark, ForceLight
@@ -132,13 +137,15 @@ object OudsTheme {
132137
}
133138

134139
/**
135-
* [OudsTheme] is the theme to apply to your screens in a Jetpack Compose application. Use it at the top of
136-
* your application in replacement of the `MaterialTheme`.
137-
* Cause OUDS supports multi-theme, you should pass the OUDS supported [theme] used by your application.
140+
* Applies the OUDS theme to the composable hierarchy.
138141
*
139-
* @param theme Theme to apply to your application. It must implement [OudsThemeContract] (e.g. OrangeTheme, SoshTheme, ...)
140-
* @param darkThemeEnabled Indicates whether the dark theme is enabled or not.
141-
* @param content Theme nested content. The provided [theme] will be applied to this content.
142+
* Use this at the top of your application instead of `MaterialTheme`.
143+
* Since OUDS supports multiple themes, you must provide the specific [theme] implementation
144+
* used by your application.
145+
*
146+
* @param theme The theme configuration to apply. It must implement [OudsThemeContract] (e.g., OrangeTheme, SoshTheme).
147+
* @param darkThemeEnabled Controls whether the dark theme is enabled. Defaults to the system setting.
148+
* @param content The content to which the theme will be applied.
142149
*/
143150
@Composable
144151
fun OudsTheme(
@@ -181,12 +188,12 @@ fun OudsTheme(
181188
}
182189

183190
/**
184-
* Tweaks the current OUDS theme and displays given [content] according to the selected [tweak].
191+
* Modifies the current OUDS theme configuration and applies it to the given [content].
185192
*
186-
* Note: This composable is directly related to [OudsTheme] and MUST be used inside it.
193+
* Note: This composable relies on [OudsTheme] and must be nested within it.
187194
*
188-
* @param tweak Tweak applied to the current [OudsTheme].
189-
* @param content Theme tweak nested content. OudsThemeTweak will be applied to this content.
195+
* @param tweak The specific adjustment to apply to the current [OudsTheme] (e.g., forcing dark mode).
196+
* @param content The content to which the tweaked theme will be applied.
190197
*/
191198
@Composable
192199
fun OudsThemeTweak(tweak: OudsTheme.Tweak, content: @Composable () -> Unit) {
@@ -210,12 +217,16 @@ fun OudsThemeTweak(tweak: OudsTheme.Tweak, content: @Composable () -> Unit) {
210217
}
211218

212219
/**
213-
* This function is equivalent to [isSystemInDarkTheme] except it takes the OUDS theme setting into account instead of the system one.
220+
* Determines if the OUDS theme is currently in dark mode.
221+
*
222+
* This function is equivalent to [isSystemInDarkTheme], but it respects overrides applied by [OudsThemeTweak].
223+
*
224+
* The OUDS theme can be inverted or forced to light/dark modes using [OudsThemeTweak].
225+
* The value returned by this function reflects these effective changes.
214226
*
215-
* The OUDS theme can be inverted or forced to light or dark when calling [OudsThemeTweak] and the value returned by this method reflects that kind of change.
216-
* If there is no call to [OudsThemeTweak] anywhere in the layout hierarchy, then this function returns the same value as [isSystemInDarkTheme].
227+
* If [OudsThemeTweak] is not used in the layout hierarchy, this function returns the same value as [isSystemInDarkTheme].
217228
*
218-
* @return `true` if OUDS is considered to be in 'dark theme'.
229+
* @return `true` if the effective OUDS theme is dark, `false` otherwise.
219230
*/
220231
@Composable
221232
@ReadOnlyComposable

theme-contract/src/main/java/com/orange/ouds/theme/OudsThemeContract.kt

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,88 +29,94 @@ import com.orange.ouds.theme.tokens.semantic.OudsSpaceSemanticTokens
2929
/**
3030
* An interface to create an OUDS supported theme.
3131
*
32-
* Any values that are not set will inherit the Orange theme.
32+
* Implementations of this interface define the look and feel of the application by providing specific token values
33+
* (colors, typography, spacing, etc.). Any values not explicitly set will generally rely on abstract definitions,
34+
* but typical implementations should provide full sets of tokens.
3335
*/
3436
interface OudsThemeContract : Parcelable {
3537

3638
/**
37-
* The theme display name.
39+
* The display name of the theme (e.g., "Orange", "Sosh").
3840
*/
3941
val name: String
4042

4143
/**
42-
* The theme settings.
44+
* The general settings for the theme configuration.
4345
*/
4446
val settings: OudsThemeSettings
4547

4648
/**
47-
* Color semantic tokens values used in the theme.
49+
* The collection of semantic color tokens used in the theme.
4850
*/
4951
val colorTokens: OudsColorSemanticTokens
5052

5153
/**
52-
* Material color matching used in the theme.
54+
* The mapping of OUDS tokens to standard Material 3 color roles.
55+
* This ensures compatibility with standard Material components.
5356
*/
5457
val materialColorTokens: OudsMaterialColorTokens
5558

5659
/**
57-
* Border semantic tokens values used in the theme.
60+
* The collection of border-related tokens (width, radius, style) used in the theme.
5861
*/
5962
val borderTokens: OudsBorderSemanticTokens
6063

6164
/**
62-
* Effect semantic tokens values used in the theme.
65+
* The collection of visual effect tokens (e.g., blurs) used in the theme.
6366
*/
6467
val effectTokens: OudsEffectSemanticTokens
6568

6669
/**
67-
* Elevation semantic tokens values used in the theme.
70+
* The collection of elevation tokens (z-index, shadows) used in the theme.
6871
*/
6972
val elevationTokens: OudsElevationSemanticTokens
7073

7174
/**
72-
* Font family used in the theme.
73-
* You can provide your own theme font family `FontFamily(Font(R.font.my_theme_font))`.
75+
* The primary font family used in the theme.
76+
*
77+
* Defaults to [FontFamily.Default] (system font).
78+
* You can provide a custom font family, for example: `FontFamily(Font(R.font.my_custom_font))`.
7479
*/
7580
val fontFamily: FontFamily
7681
get() = FontFamily.Default
7782

7883
/**
79-
* Font semantic tokens values used in the theme.
84+
* The collection of typography semantic tokens (font sizes, weights, line heights) used in the theme.
8085
*/
8186
val fontTokens: OudsFontSemanticTokens
8287

8388
/**
84-
* Grid semantic tokens values used in the theme.
89+
* The collection of grid layout tokens used in the theme.
8590
*/
8691
val gridTokens: OudsGridSemanticTokens
8792

8893
/**
89-
* Opacity semantic tokens values used in the theme.
94+
* The collection of opacity tokens used in the theme.
9095
*/
9196
val opacityTokens: OudsOpacitySemanticTokens
9297

9398
/**
94-
* Size semantic tokens values used in the theme.
99+
* The collection of size tokens (icons, constraints) used in the theme.
95100
*/
96101
val sizeTokens: OudsSizeSemanticTokens
97102

98103
/**
99-
* Space semantic tokens values used in the theme.
104+
* The collection of spacing tokens (padding, margins, gaps) used in the theme.
100105
*/
101106
val spaceTokens: OudsSpaceSemanticTokens
102107

103108
/**
104-
* Allows customization of OUDS components.
109+
* Specific tokens for customizing the internal behavior or style of OUDS components.
105110
*/
106111
val componentsTokens: OudsComponentsTokens
107112

108113
/**
109-
* Allows customization of drawable resources used by OUDS components.
114+
* Allows customization of drawable resources used explicitly by OUDS components.
110115
*
111-
* Caution:
116+
* **Caution:**
112117
* To avoid resource conflicts, Android recommends using a prefix or other consistent naming scheme that is unique to the module (or is unique across all project modules).
113-
* So, we strongly recommend that you prefix your resources with the name of your theme. For example, if your theme is called "LoremIpsum" you might name your resources as ic_lorem_ipsum_checkbox_selected, ic_lorem_ipsum_chip_tick, etc.
118+
* We strongly recommend that you prefix your resources with the theme name.
119+
* Example: If your theme is "LoremIpsum", name resources like `ic_lorem_ipsum_checkbox_selected`, `ic_lorem_ipsum_chip_tick`, etc.
114120
*/
115121
val drawableResources: OudsDrawableResources
116122
}

0 commit comments

Comments
 (0)