diff --git a/app/src/main/java/com/orange/ods/app/ui/components/cards/CardCustomizationState.kt b/app/src/main/java/com/orange/ods/app/ui/components/cards/CardCustomizationState.kt index e319f1032..42b858b32 100644 --- a/app/src/main/java/com/orange/ods/app/ui/components/cards/CardCustomizationState.kt +++ b/app/src/main/java/com/orange/ods/app/ui/components/cards/CardCustomizationState.kt @@ -15,7 +15,7 @@ import androidx.compose.runtime.MutableState import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable -import com.orange.ods.compose.component.card.OdsHorizontalCardImagePosition +import com.orange.ods.compose.component.card.OdsHorizontalCard @Composable fun rememberCardCustomizationState( @@ -25,7 +25,7 @@ fun rememberCardCustomizationState( subtitleChecked: MutableState = rememberSaveable { mutableStateOf(true) }, buttonCount: MutableState = rememberSaveable { mutableStateOf(CardCustomizationState.MinButtonCount) }, dividerChecked: MutableState = rememberSaveable { mutableStateOf(true) }, - imagePosition: MutableState = rememberSaveable { mutableStateOf(OdsHorizontalCardImagePosition.Start) } + imagePosition: MutableState = rememberSaveable { mutableStateOf(OdsHorizontalCard.Image.Position.Start) } ) = remember(clickable, thumbnailChecked, textChecked, subtitleChecked, buttonCount, dividerChecked, imagePosition) { CardCustomizationState(clickable, thumbnailChecked, textChecked, subtitleChecked, buttonCount, dividerChecked, imagePosition) @@ -38,7 +38,7 @@ class CardCustomizationState( val subtitleChecked: MutableState, val buttonCount: MutableState, val dividerChecked: MutableState, - val imagePosition: MutableState + val imagePosition: MutableState ) { companion object { diff --git a/app/src/main/java/com/orange/ods/app/ui/components/cards/ComponentCard.kt b/app/src/main/java/com/orange/ods/app/ui/components/cards/ComponentCard.kt index 4055d3b4d..226bc9b27 100644 --- a/app/src/main/java/com/orange/ods/app/ui/components/cards/ComponentCard.kt +++ b/app/src/main/java/com/orange/ods/app/ui/components/cards/ComponentCard.kt @@ -22,7 +22,7 @@ import com.orange.ods.app.ui.components.Variant import com.orange.ods.app.ui.components.utilities.ComponentCountRow import com.orange.ods.app.ui.components.utilities.ComponentCustomizationBottomSheetScaffold import com.orange.ods.app.ui.utilities.composable.Subtitle -import com.orange.ods.compose.component.card.OdsHorizontalCardImagePosition +import com.orange.ods.compose.component.card.OdsHorizontalCard import com.orange.ods.compose.component.chip.OdsChoiceChip import com.orange.ods.compose.component.chip.OdsChoiceChipsFlowRow import com.orange.ods.compose.component.list.OdsListItem @@ -54,11 +54,11 @@ fun ComponentCard(variant: Variant) { chips = listOf( OdsChoiceChip( text = stringResource(id = R.string.component_card_horizontal_image_position_start), - value = OdsHorizontalCardImagePosition.Start + value = OdsHorizontalCard.Image.Position.Start ), OdsChoiceChip( text = stringResource(id = R.string.component_card_horizontal_image_position_end), - value = OdsHorizontalCardImagePosition.End + value = OdsHorizontalCard.Image.Position.End ) ) ) diff --git a/docs/components/Cards.md b/docs/components/Cards.md index 510c133d6..4eed518d9 100644 --- a/docs/components/Cards.md +++ b/docs/components/Cards.md @@ -199,7 +199,7 @@ OdsHorizontalCard( text = "Text", firstButton = OdsCard.Button("First button") { doSomething() }, secondButton = OdsCard.Button("Second button") { doSomething() }, - imagePosition = OdsHorizontalCardImagePosition.Start, + imagePosition = OdsHorizontalCard.Image.Position.Start, divider = false, onClick = { doSomething() } ) @@ -216,7 +216,7 @@ Parameter | Default value | Description `text: String?` | `null` | Text displayed into the card `firstButton: OdsCard.Button?` | `null` | First button displayed into the card `secondButton: OdsCard.Button?` | `null` | Second button displayed into the card -`imagePosition: OdsHorizontalCardImagePosition` | `OdsHorizontalCardImagePosition.Start` | Position of the image within the card, it can be set to `OdsHorizontalCardImagePosition.Start` or `OdsHorizontalCardImagePosition.End` +`imagePosition: OdsHorizontalCard.Image.Position` | `OdsHorizontalCard.Image.Position.Start` | Position of the image within the card, it can be set to `OdsHorizontalCard.Image.Position.Start` or `OdsHorizontalCard.Image.Position.End` `divider: Boolean` | `true` | Controls the divider display. If `true`, it will be displayed between the card content and the action buttons. `onClick: (() -> Unit)?` | `null` | Callback invoked on card click {:.table} diff --git a/lib/src/main/java/com/orange/ods/compose/component/card/OdsHorizontalCard.kt b/lib/src/main/java/com/orange/ods/compose/component/card/OdsHorizontalCard.kt index e4016d929..709da31c1 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/card/OdsHorizontalCard.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/card/OdsHorizontalCard.kt @@ -48,7 +48,7 @@ import com.orange.ods.compose.theme.OdsTheme * @param text Text displayed into the card. * @param firstButton First [OdsCard.Button] displayed into the card. * @param secondButton Second [OdsCard.Button] displayed into the card. - * @param imagePosition Position of the image within the card, it can be set to [OdsHorizontalCardImagePosition.Start] or [OdsHorizontalCardImagePosition.End]. [OdsHorizontalCardImagePosition.Start] by default. + * @param imagePosition Position of the image within the card, it can be set to [OdsHorizontalCard.Image.Position.Start] or [OdsHorizontalCard.Image.Position.End]. [OdsHorizontalCard.Image.Position.Start] by default. * @param divider Controls the divider display. If `true`, it will be displayed between the card content and the action buttons. * @param onClick Callback invoked on card click. */ @@ -62,7 +62,7 @@ fun OdsHorizontalCard( text: String? = null, firstButton: OdsCard.Button? = null, secondButton: OdsCard.Button? = null, - imagePosition: OdsHorizontalCardImagePosition = OdsHorizontalCardImagePosition.Start, + imagePosition: OdsHorizontalCard.Image.Position = OdsHorizontalCard.Image.Position.Start, divider: Boolean = true, onClick: (() -> Unit)? = null, ) { @@ -92,8 +92,8 @@ fun OdsHorizontalCard( top.linkTo(parent.top) bottom.linkTo(dividerRef.top) when (imagePosition) { - OdsHorizontalCardImagePosition.Start -> start.linkTo(parent.start) - OdsHorizontalCardImagePosition.End -> end.linkTo(parent.end) + OdsHorizontalCard.Image.Position.Start -> start.linkTo(parent.start) + OdsHorizontalCard.Image.Position.End -> end.linkTo(parent.end) } width = Dimension.value(imageSize) height = Dimension.fillToConstraints.atLeast(imageSize) @@ -110,11 +110,11 @@ fun OdsHorizontalCard( text = title, modifier = Modifier.constrainAs(titleRef) { when (imagePosition) { - OdsHorizontalCardImagePosition.Start -> { + OdsHorizontalCard.Image.Position.Start -> { start.linkTo(imageRef.end, margin = mediumSpacing) end.linkTo(parent.end, margin = mediumSpacing) } - OdsHorizontalCardImagePosition.End -> { + OdsHorizontalCard.Image.Position.End -> { start.linkTo(parent.start, margin = mediumSpacing) end.linkTo(imageRef.start, margin = mediumSpacing) } @@ -180,8 +180,12 @@ fun OdsHorizontalCard( } } -enum class OdsHorizontalCardImagePosition { - Start, End +class OdsHorizontalCard { + class Image { + enum class Position { + Start, End + } + } } @UiModePreviews.Default @@ -202,7 +206,7 @@ private fun PreviewOdsHorizontalCard(@PreviewParameter(OdsHorizontalCardPreviewP internal data class OdsHorizontalCardPreviewParameter( val subtitle: String?, - val imagePosition: OdsHorizontalCardImagePosition, + val imagePosition: OdsHorizontalCard.Image.Position, val dividerEnabled: Boolean, val firstButtonText: String?, val secondButtonText: String? @@ -218,9 +222,9 @@ private val previewParameterValues: List val secondButtonText = "Second button" return listOf( - OdsHorizontalCardPreviewParameter(subtitle, OdsHorizontalCardImagePosition.Start, true, firstButtonText, secondButtonText), - OdsHorizontalCardPreviewParameter(subtitle, OdsHorizontalCardImagePosition.End, false, firstButtonText, null), - OdsHorizontalCardPreviewParameter(subtitle, OdsHorizontalCardImagePosition.Start, true, null, null), - OdsHorizontalCardPreviewParameter(null, OdsHorizontalCardImagePosition.Start, false, null, secondButtonText) + OdsHorizontalCardPreviewParameter(subtitle, OdsHorizontalCard.Image.Position.Start, true, firstButtonText, secondButtonText), + OdsHorizontalCardPreviewParameter(subtitle, OdsHorizontalCard.Image.Position.End, false, firstButtonText, null), + OdsHorizontalCardPreviewParameter(subtitle, OdsHorizontalCard.Image.Position.Start, true, null, null), + OdsHorizontalCardPreviewParameter(null, OdsHorizontalCard.Image.Position.Start, false, null, secondButtonText) ) }