-
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.
- Loading branch information
1 parent
ad71e17
commit c69e968
Showing
38 changed files
with
201 additions
and
9 deletions.
There are no files selected for viewing
110 changes: 110 additions & 0 deletions
110
core/src/main/java/com/orange/ouds/core/component/contrastedsurface/OudsContrastedSurface.kt
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,110 @@ | ||
/* | ||
* Software Name: OUDS Android | ||
* 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. | ||
* | ||
* Software description: Android library of reusable graphical components | ||
*/ | ||
|
||
package com.orange.ouds.core.component.contrastedsurface | ||
|
||
import androidx.compose.foundation.BorderStroke | ||
import androidx.compose.foundation.isSystemInDarkTheme | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.material3.Surface | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.graphics.RectangleShape | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.tooling.preview.PreviewParameter | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.dp | ||
import com.orange.ouds.core.theme.value | ||
import com.orange.ouds.core.utilities.OudsPreview | ||
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider | ||
import com.orange.ouds.foundation.utilities.UiModePreviews | ||
import com.orange.ouds.theme.tokens.OudsColorKeyToken | ||
import com.orange.ouds.theme.tokens.OudsSpaceKeyToken | ||
|
||
@Composable | ||
fun OudsContrastedSurface( | ||
color: OudsColorKeyToken.Surface, | ||
modifier: Modifier = Modifier, | ||
shape: Shape = RectangleShape, | ||
tonalElevation: Dp = 0.dp, | ||
shadowElevation: Dp = 0.dp, | ||
border: BorderStroke? = null, | ||
content: @Composable () -> Unit | ||
) { | ||
Surface( | ||
modifier = modifier, | ||
shape = shape, | ||
color = color.value, | ||
contentColor = contentColorFor(color), | ||
tonalElevation = tonalElevation, | ||
shadowElevation = shadowElevation, | ||
border = border, | ||
content = content | ||
) | ||
} | ||
|
||
@Composable | ||
private fun contentColorFor(color: OudsColorKeyToken.Surface): Color { | ||
return when (color) { | ||
OudsColorKeyToken.Surface.Brand.Primary -> OudsColorKeyToken.Content.OnBrand.Primary | ||
OudsColorKeyToken.Surface.Status.Accent.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Info.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Negative.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Positive.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Warning.Emphasized -> OudsColorKeyToken.Content.OnStatus.Emphasized | ||
OudsColorKeyToken.Surface.Status.Neutral.Emphasized -> OudsColorKeyToken.Content.OnStatus.EmphasizedNeutral | ||
OudsColorKeyToken.Surface.Status.Accent.Muted, | ||
OudsColorKeyToken.Surface.Status.Info.Muted, | ||
OudsColorKeyToken.Surface.Status.Negative.Muted, | ||
OudsColorKeyToken.Surface.Status.Positive.Muted, | ||
OudsColorKeyToken.Surface.Status.Neutral.Muted, | ||
OudsColorKeyToken.Surface.Status.Warning.Muted -> OudsColorKeyToken.Content.OnStatus.Muted | ||
}.value | ||
} | ||
|
||
@Suppress("PreviewShouldNotBeCalledRecursively") | ||
@UiModePreviews.Default | ||
@Composable | ||
private fun PreviewOudsContrastedSurface(@PreviewParameter(OudsContrastedSurfacePreviewParameterProvider::class) parameter: OudsColorKeyToken.Surface) { | ||
PreviewOudsContrastedSurface(darkThemeEnabled = isSystemInDarkTheme(), parameter = parameter) | ||
} | ||
|
||
@Composable | ||
internal fun PreviewOudsContrastedSurface(darkThemeEnabled: Boolean, parameter: OudsColorKeyToken.Surface) = OudsPreview(darkThemeEnabled = darkThemeEnabled) { | ||
OudsContrastedSurface(color = parameter) { | ||
Text( | ||
modifier = Modifier.padding(all = OudsSpaceKeyToken.Fixed.Medium.value), | ||
text = parameter.name.removePrefix("OudsColorKeyToken."), | ||
) | ||
} | ||
} | ||
|
||
internal class OudsContrastedSurfacePreviewParameterProvider : BasicPreviewParameterProvider<OudsColorKeyToken.Surface>(*previewParameterValues.toTypedArray()) | ||
|
||
private val previewParameterValues: List<OudsColorKeyToken.Surface> | ||
get() = listOf( | ||
OudsColorKeyToken.Surface.Brand.Primary, | ||
OudsColorKeyToken.Surface.Status.Accent.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Accent.Muted, | ||
OudsColorKeyToken.Surface.Status.Info.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Info.Muted, | ||
OudsColorKeyToken.Surface.Status.Negative.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Negative.Muted, | ||
OudsColorKeyToken.Surface.Status.Neutral.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Neutral.Muted, | ||
OudsColorKeyToken.Surface.Status.Positive.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Positive.Muted, | ||
OudsColorKeyToken.Surface.Status.Warning.Emphasized, | ||
OudsColorKeyToken.Surface.Status.Warning.Muted, | ||
) |
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
54 changes: 54 additions & 0 deletions
54
...c/test/java/com/orange/ouds/core/component/contrastedsurface/OudsContrastedSurfaceTest.kt
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,54 @@ | ||
/* | ||
* Software Name: OUDS Android | ||
* 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. | ||
* | ||
* Software description: Android library of reusable graphical components | ||
*/ | ||
|
||
package com.orange.ouds.core.component.contrastedsurface | ||
|
||
import app.cash.paparazzi.Paparazzi | ||
import com.android.ide.common.rendering.api.SessionParams | ||
import com.orange.ouds.theme.tokens.OudsColorKeyToken | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
|
||
@RunWith(Parameterized::class) | ||
internal class OudsContrastedSurfaceTest(private val parameter: OudsColorKeyToken.Surface) { | ||
|
||
companion object { | ||
@JvmStatic | ||
@Parameterized.Parameters | ||
internal fun data() = OudsContrastedSurfacePreviewParameterProvider().values.toList() | ||
} | ||
|
||
@get:Rule | ||
val paparazzi = Paparazzi(renderingMode = SessionParams.RenderingMode.SHRINK, maxPercentDifference = 0.0) | ||
|
||
@Test | ||
fun takeOudsContrastedSurfaceLightThemeSnapshot() { | ||
paparazzi.snapshot { | ||
PreviewOudsContrastedSurface( | ||
darkThemeEnabled = false, | ||
parameter = parameter | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun takeOudsContrastedSurfaceDarkThemeSnapshot() { | ||
paparazzi.snapshot { | ||
PreviewOudsContrastedSurface( | ||
darkThemeEnabled = true, | ||
parameter = parameter | ||
) | ||
} | ||
} | ||
} |
Binary file added
BIN
+6 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[0].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.57 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[10].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.74 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[11].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.02 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[12].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.81 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[1].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.98 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[2].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.63 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[3].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.78 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[4].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.73 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[5].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.92 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[6].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.58 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[7].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.67 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[8].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.47 KB
...ace_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceDarkThemeSnapshot[9].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[0].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.63 KB
...e_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[10].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.35 KB
...e_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[11].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8 KB
...e_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[12].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.43 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[1].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.02 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[2].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.68 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[3].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.78 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[4].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.88 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[5].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.9 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[6].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.56 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[7].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.84 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[8].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.43 KB
...ce_OudsContrastedSurfaceTest_takeOudsContrastedSurfaceLightThemeSnapshot[9].png
Oops, something went wrong.
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
22 changes: 22 additions & 0 deletions
22
theme-contract/src/main/java/com/orange/ouds/theme/tokens/OudsKeyToken.kt
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,22 @@ | ||
/* | ||
* Software Name: OUDS Android | ||
* 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. | ||
* | ||
* Software description: Android library of reusable graphical components | ||
*/ | ||
|
||
package com.orange.ouds.theme.tokens | ||
|
||
sealed interface OudsKeyToken { | ||
|
||
val name: String | ||
get() { | ||
val packageName = this::class.java.`package`?.name.orEmpty() | ||
return this::class.qualifiedName.orEmpty().removePrefix("$packageName.") | ||
} | ||
} |
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