Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions buildSrc/src/main/kotlin/paparazzi.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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
*/

import org.gradle.api.DefaultTask

private val failuresDir = project.layout.buildDirectory.dir("paparazzi/failures").get().asFile

tasks.register<DefaultTask>("updatePaparazziFailures") {
group = "verification"
// Clean failures directory first to avoid copying old failures
dependsOn(tasks["cleanPaparazziFailures"])
// Using finalizedBy in cunjunction with mustRunAfter allows to run verifyPaparazzi and copyPaparazziFailures
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Using finalizedBy in cunjunction with mustRunAfter allows to run verifyPaparazzi and copyPaparazziFailures
// Using finalizedBy in conjunction with mustRunAfter allows to run verifyPaparazzi and copyPaparazziFailures

// in that order even if verifyPaparazzi fails
tasks["cleanPaparazziFailures"].finalizedBy("verifyPaparazzi", "copyPaparazziFailures")
tasks["copyPaparazziFailures"].mustRunAfter(tasks["verifyPaparazzi"])
}

tasks.register<DefaultTask>("cleanPaparazziFailures") {
doLast {
if (failuresDir.exists()) {
failuresDir.deleteRecursively()
logger.lifecycle("Cleaned failures in ${project.name}.")
}
}
}

tasks.register<DefaultTask>("copyPaparazziFailures") {
doLast {
val snapshotsDir = File("${project.projectDir}/src/test/snapshots/images")

// Get all PNG files except delta comparison images
val failureFiles = failuresDir.walkTopDown()
.filter { it.isFile && it.extension == "png" && !it.name.startsWith("delta-") }
.toList()

// Ensure snapshots directory exists
snapshotsDir.mkdirs()

// Copy failure files to snapshots directory
failureFiles.forEach { failureFile ->
val snapshotFile = snapshotsDir.resolve(failureFile.name)
failureFile.copyTo(snapshotFile, overwrite = true)
}

if (failureFiles.isEmpty()) {
logger.lifecycle("No snapshots updated in ${project.name}.")
} else {
val snapshotPlural = if (failureFiles.count() > 1) "s" else ""
logger.lifecycle("Updated ${failureFiles.count()} snapshot$snapshotPlural in ${project.name}.")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.core.utilities.OudsPreviewDevice
import com.orange.ouds.core.utilities.OudsPreviewableComponent
import com.orange.ouds.core.utilities.PreviewFlowRow
import com.orange.ouds.core.utilities.getPreviewTheme
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
import com.orange.ouds.theme.OudsThemeContract
Expand Down Expand Up @@ -416,25 +417,26 @@ internal fun PreviewOudsAlertMessage(
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
with(parameter) {
val icon = if (hasIcon) OudsAlertIcon(Icons.Outlined.FavoriteBorder) else null
Column {
listOf(
PreviewFlowRow(
items = listOf(
OudsAlertMessageStatus.Neutral(icon),
OudsAlertMessageStatus.Accent(icon),
OudsAlertMessageStatus.Negative,
OudsAlertMessageStatus.Positive,
OudsAlertMessageStatus.Info,
OudsAlertMessageStatus.Warning
).forEach { status ->
OudsAlertMessage(
modifier = Modifier.padding(all = 10.dp),
label = "Label",
status = status,
description = description,
onClose = onClose,
actionLink = actionLink,
bulletList = bulletList
)
}
),
itemName = { it::class.simpleName.orEmpty() },
maxItemsInEachRow = 1
) { status ->
OudsAlertMessage(
label = "Label",
status = status,
description = description,
onClose = onClose,
actionLink = actionLink,
bulletList = bulletList
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ internal fun PreviewOudsButton(
val label = if (hasLabel) appearance.name else null
val icon = if (hasIcon) OudsButtonIcon(Icons.Filled.FavoriteBorder, "") else null
val content: @Composable () -> Unit = {
PreviewEnumEntries<OudsButtonState>(columnCount = 2) {
PreviewEnumEntries<OudsButtonState>(maxEnumEntriesInEachRow = 2) {
OudsButton(
nullableIcon = icon,
nullableLabel = label,
Expand Down Expand Up @@ -811,7 +811,7 @@ private fun PreviewOudsButtonWithRoundedCorners() = PreviewOudsButtonWithRounded
internal fun PreviewOudsButtonWithRoundedCorners(theme: OudsThemeContract) =
OudsPreview(theme = theme.mapSettings { it.copy(roundedCornerButtons = true) }) {
val appearance = OudsButtonAppearance.Default
PreviewEnumEntries<OudsButtonState>(columnCount = 2) {
PreviewEnumEntries<OudsButtonState>(maxEnumEntriesInEachRow = 2) {
OudsButton(
nullableIcon = OudsButtonIcon(Icons.Filled.FavoriteBorder, ""),
nullableLabel = appearance.name,
Expand All @@ -829,7 +829,7 @@ private fun PreviewOudsButtonWithIconBadge(@PreviewParameter(OudsButtonWithIconB

@Composable
internal fun PreviewOudsButtonWithIconBadge(theme: OudsThemeContract, count: Int) = OudsPreview(theme = theme) {
PreviewEnumEntries<OudsButtonState>(columnCount = 2) {
PreviewEnumEntries<OudsButtonState>(maxEnumEntriesInEachRow = 2) {
OudsButton(
nullableIcon = OudsButtonIcon(Icons.Filled.FavoriteBorder, ""),
nullableLabel = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ internal fun PreviewOudsCheckboxItem(
parameter: OudsCheckboxItemPreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
with(parameter) {
PreviewEnumEntries<OudsControlState>(columnCount = 1, edgeToEdge = true) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1, edgeToEdge = true) {
OudsTriStateCheckboxItem(
state = value,
label = "Label",
Expand Down Expand Up @@ -286,7 +286,7 @@ internal fun PreviewOudsCheckboxItemHighContrastModeEnabled(
parameter: OudsCheckboxItemHighContrastModePreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled, highContrastModeEnabled = true) {
with(parameter) {
PreviewEnumEntries<OudsControlState>(columnCount = 1, edgeToEdge = true) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1, edgeToEdge = true) {
OudsTriStateCheckboxItem(
state = value,
label = "Label",
Expand Down Expand Up @@ -320,7 +320,7 @@ private fun PreviewOudsCheckboxItemWithEdgeToEdgeDisabled() = PreviewOudsCheckbo

@Composable
internal fun PreviewOudsCheckboxItemWithEdgeToEdgeDisabled(theme: OudsThemeContract) = OudsPreview(theme = theme) {
PreviewEnumEntries<OudsControlState>(columnCount = 1) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1) {
OudsCheckboxItem(
checked = true,
label = "Label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ internal fun PreviewOudsFilterChip(theme: OudsThemeContract, darkThemeEnabled: B
with(parameter) {
val label = if (hasLabel) "Label" else null
val icon = if (hasIcon) OudsChipIcon(Icons.Filled.FavoriteBorder, "") else null
PreviewEnumEntries<OudsChipState>(columnCount = 3) {
PreviewEnumEntries<OudsChipState>(maxEnumEntriesInEachRow = 3) {
OudsFilterChip(selected = selected, nullableIcon = icon, nullableLabel = label, onClick = {})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ package com.orange.ouds.core.component

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.material.icons.Icons
Expand All @@ -29,10 +27,10 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import com.orange.ouds.core.theme.OudsTheme
import com.orange.ouds.core.theme.value
import com.orange.ouds.core.utilities.OudsPreview
import com.orange.ouds.core.utilities.PreviewFlowRow
import com.orange.ouds.core.utilities.getPreviewTheme
import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
import com.orange.ouds.theme.OudsThemeContract
Expand Down Expand Up @@ -194,21 +192,22 @@ internal fun PreviewOudsInlineAlert(
label: String
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
val icon = OudsAlertIcon(Icons.Outlined.FavoriteBorder)
Column {
listOf(
PreviewFlowRow(
items = listOf(
OudsInlineAlertStatus.Neutral(icon),
OudsInlineAlertStatus.Accent(icon),
OudsInlineAlertStatus.Negative,
OudsInlineAlertStatus.Positive,
OudsInlineAlertStatus.Info,
OudsInlineAlertStatus.Warning
).forEach { status ->
OudsInlineAlert(
modifier = Modifier.padding(all = 10.dp),
label = label,
status = status
)
}
),
itemName = { it::class.simpleName.orEmpty() },
maxItemsInEachRow = 1
) { status ->
OudsInlineAlert(
label = label,
status = status
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private fun PreviewOudsInputTag() {
@Composable
internal fun PreviewOudsInputTag(theme: OudsThemeContract, darkThemeEnabled: Boolean) =
OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
PreviewEnumEntries<OudsInputTagState>(columnCount = 3) {
PreviewEnumEntries<OudsInputTagState>(maxEnumEntriesInEachRow = 3) {
OudsInputTag(label = "Label", onClick = {})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ internal fun PreviewOudsLink(
with(parameter) {
val icon = if (hasIcon) OudsLinkIcon(Icons.Filled.FavoriteBorder) else null
val linkPreview: @Composable () -> Unit = {
PreviewEnumEntries<OudsLinkState>(columnCount = 3) {
PreviewEnumEntries<OudsLinkState>(maxEnumEntriesInEachRow = 3) {
OudsLink(
icon = icon,
label = "Label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ internal fun PreviewOudsPasswordInput(
parameter: OudsPasswordInputPreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
with(parameter) {
PreviewEnumEntries<OudsTextInputState>(columnCount = 1) {
PreviewEnumEntries<OudsTextInputState>(maxEnumEntriesInEachRow = 1) {
OudsPasswordInput(
state = rememberOudsPasswordInputState(initialText),
label = label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ internal fun PreviewOudsRadioButtonItem(
parameter: OudsRadioButtonItemPreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
with(parameter) {
PreviewEnumEntries<OudsControlState>(columnCount = 1, edgeToEdge = true) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1, edgeToEdge = true) {
OudsRadioButtonItem(
selected = value,
label = "Label",
Expand Down Expand Up @@ -248,7 +248,7 @@ internal fun PreviewOudsRadioButtonItemHighContrastModeEnabled(
parameter: OudsRadioButtonItemHighContrastModePreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled, highContrastModeEnabled = true) {
with(parameter) {
PreviewEnumEntries<OudsControlState>(columnCount = 1, edgeToEdge = true) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1, edgeToEdge = true) {
OudsRadioButtonItem(
selected = value,
label = "Label",
Expand Down Expand Up @@ -284,7 +284,7 @@ private fun PreviewOudsRadioButtonItemWithEdgeToEdgeDisabled() = PreviewOudsRadi

@Composable
internal fun PreviewOudsRadioButtonItemWithEdgeToEdgeDisabled(theme: OudsThemeContract) = OudsPreview(theme = theme) {
PreviewEnumEntries<OudsControlState>(columnCount = 1) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1) {
OudsRadioButtonItem(
selected = true,
label = "Label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ internal fun PreviewOudsSuggestionChip(
with(parameter) {
val label = if (hasLabel) "Label" else null
val icon = if (hasIcon) OudsChipIcon(Icons.Filled.FavoriteBorder, "") else null
PreviewEnumEntries<OudsChipState>(columnCount = 3) {
PreviewEnumEntries<OudsChipState>(maxEnumEntriesInEachRow = 3) {
OudsSuggestionChip(nullableIcon = icon, nullableLabel = label, onClick = {})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ internal fun PreviewOudsSwitch(
darkThemeEnabled: Boolean,
checked: Boolean
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
PreviewEnumEntries<OudsControlState>(columnCount = 3) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 3) {
OudsSwitch(
checked = checked,
onCheckedChange = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ internal fun PreviewOudsSwitchItem(
parameter: OudsSwitchItemPreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
with(parameter) {
PreviewEnumEntries<OudsControlState>(columnCount = 1, edgeToEdge = true) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1, edgeToEdge = true) {
OudsSwitchItem(
checked = value,
label = "Label",
Expand Down Expand Up @@ -201,7 +201,7 @@ private fun PreviewOudsSwitchItemWithEdgeToEdgeDisabled() = PreviewOudsSwitchIte

@Composable
internal fun PreviewOudsSwitchItemWithEdgeToEdgeDisabled(theme: OudsThemeContract) = OudsPreview(theme = theme) {
PreviewEnumEntries<OudsControlState>(columnCount = 1) {
PreviewEnumEntries<OudsControlState>(maxEnumEntriesInEachRow = 1) {
OudsSwitchItem(
checked = true,
label = "Label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ internal fun PreviewOudsTextArea(
parameter: OudsTextAreaPreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
with(parameter) {
PreviewEnumEntries<OudsTextInputState>(columnCount = 1) { _ ->
PreviewEnumEntries<OudsTextInputState>(maxEnumEntriesInEachRow = 1) { _ ->
OudsTextArea(
textFieldState = rememberTextFieldState(value),
label = label,
Expand All @@ -653,7 +653,7 @@ private fun PreviewOudsTextAreaWithRoundedCorners() = PreviewOudsTextAreaWithRou
@Composable
internal fun PreviewOudsTextAreaWithRoundedCorners(theme: OudsThemeContract) =
OudsPreview(theme = theme.mapSettings { it.copy(roundedCornerTextInputs = true) }) {
PreviewEnumEntries<OudsTextInputState>(columnCount = 1) { _ ->
PreviewEnumEntries<OudsTextInputState>(maxEnumEntriesInEachRow = 1) { _ ->
OudsTextArea(
textFieldState = rememberTextFieldState(""),
label = "Label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ internal fun PreviewOudsTextInput(
parameter: OudsTextInputPreviewParameter
) = OudsPreview(theme = theme, darkThemeEnabled = darkThemeEnabled) {
with(parameter) {
PreviewEnumEntries<OudsTextInputState>(columnCount = 1) { _ ->
PreviewEnumEntries<OudsTextInputState>(maxEnumEntriesInEachRow = 1) { _ ->
OudsTextInput(
textFieldState = rememberTextFieldState(value),
label = label,
Expand All @@ -1069,7 +1069,7 @@ private fun PreviewOudsTextInputWithRoundedCorners() = PreviewOudsTextInputWithR
@Composable
internal fun PreviewOudsTextInputWithRoundedCorners(theme: OudsThemeContract) =
OudsPreview(theme = theme.mapSettings { it.copy(roundedCornerTextInputs = true) }) {
PreviewEnumEntries<OudsTextInputState>(columnCount = 1) { _ ->
PreviewEnumEntries<OudsTextInputState>(maxEnumEntriesInEachRow = 1) { _ ->
OudsTextInput(
textFieldState = rememberTextFieldState(""),
label = "Label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.FavoriteBorder
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.PreviewLightDark
import com.orange.ouds.core.component.OudsAlertMessage
import com.orange.ouds.core.component.OudsAlertIcon
import com.orange.ouds.core.component.OudsAlertMessage
import com.orange.ouds.core.component.OudsAlertMessageActionLink
import com.orange.ouds.core.component.OudsAlertMessageActionLinkPosition
import com.orange.ouds.core.component.OudsAlertMessageStatus
Expand Down
Loading
Loading