diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/ComponentCode.kt b/app/src/main/java/com/orange/ouds/app/ui/components/ComponentCode.kt index 29c3e96cf..6a43a334e 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/ComponentCode.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/ComponentCode.kt @@ -48,6 +48,8 @@ fun FunctionCall.Builder.colorArgument(name: String, color: Color) { fun FunctionCall.Builder.stringArgument(name: String, @StringRes id: Int) = formattableArgument(name) { "\"${it.getString(id)}\"" } +fun FunctionCall.Builder.constrainedMaxWidthArgument(value: Boolean) = typedArgument(Argument.ConstrainedMaxWidth, value) + fun FunctionCall.Builder.contentDescriptionArgument(@StringRes id: Int) = stringArgument(Argument.ContentDescription, id) fun FunctionCall.Builder.contentDescriptionArgument(@StringRes id: Int, vararg formatArgs: Any) = stringResourceArgument(Argument.ContentDescription, id, *formatArgs) @@ -70,6 +72,7 @@ fun FunctionCall.Builder.readOnlyArgument(value: Boolean) = typedArgument(Argume private object Argument { const val Color = "color" + const val ConstrainedMaxWidth = "constrainedMaxWidth" const val ContentDescription = "contentDescription" const val Content = "content" const val Enabled = "enabled" diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoScreen.kt b/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoScreen.kt index 799fd37d7..b1756c82e 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoScreen.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoScreen.kt @@ -78,7 +78,8 @@ private fun CheckboxItemDemoContent(state: CheckboxItemDemoState) { reversed = reversed, enabled = enabled, readOnly = readOnly, - error = if (error) OudsError(if (isLastItem) errorMessage else "") else null + error = if (error) OudsError(if (isLastItem) errorMessage else "") else null, + constrainedMaxWidth = constrainedMaxWidth ) } } @@ -112,7 +113,8 @@ private fun IndeterminateCheckboxItemDemoContent(state: CheckboxItemDemoState) { reversed = reversed, enabled = enabled, readOnly = readOnly, - error = if (error) OudsError(if (isLastItem) errorMessage else "") else null + error = if (error) OudsError(if (isLastItem) errorMessage else "") else null, + constrainedMaxWidth = constrainedMaxWidth ) } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoState.kt b/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoState.kt index 75c1fa236..ff6cb3540 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoState.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/checkbox/CheckboxItemDemoState.kt @@ -39,7 +39,8 @@ fun rememberCheckboxItemDemoState( error: Boolean = false, errorMessage: String = stringResource(id = R.string.app_components_common_errorMessage_label), label: String = stringResource(id = R.string.app_components_common_label_label), - description: String? = null + description: String? = null, + constrainedMaxWidth: Boolean = false ) = rememberSaveable( checkedValues, toggleableStateValues, @@ -53,9 +54,24 @@ fun rememberCheckboxItemDemoState( errorMessage, label, description, + constrainedMaxWidth, saver = CheckboxItemDemoState.Saver ) { - CheckboxItemDemoState(checkedValues, toggleableStateValues, icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, label, description) + CheckboxItemDemoState( + checkedValues, + toggleableStateValues, + icon, + edgeToEdge, + divider, + reversed, + enabled, + readOnly, + error, + errorMessage, + label, + description, + constrainedMaxWidth + ) } class CheckboxItemDemoState( @@ -70,8 +86,9 @@ class CheckboxItemDemoState( error: Boolean, errorMessage: String, label: String, - description: String? -) : ControlItemDemoState(icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, label, description) { + description: String?, + constrainedMaxWidth: Boolean +) : ControlItemDemoState(icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, label, description, constrainedMaxWidth) { companion object { val Saver = listSaver( @@ -98,7 +115,8 @@ class CheckboxItemDemoState( error, errorMessage, label, - description + description, + constrainedMaxWidth ) } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoScreen.kt b/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoScreen.kt index e8e00c8ad..7fa974913 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoScreen.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoScreen.kt @@ -15,6 +15,7 @@ package com.orange.ouds.app.ui.components.controlitem import androidx.compose.runtime.Composable import androidx.compose.ui.res.stringResource import com.orange.ouds.app.R +import com.orange.ouds.app.ui.components.constrainedMaxWidthArgument import com.orange.ouds.app.ui.components.enabledArgument import com.orange.ouds.app.ui.components.labelArgument import com.orange.ouds.app.ui.components.painterArgument @@ -42,7 +43,8 @@ fun ControlItemCustomizations(state: ControlItemDemoState, extraCustomizations: { ControlItemErrorCustomization(state = state) }, { ControlItemErrorMessageCustomization(state = state) }, { ControlItemLabelCustomization(state = state) }, - { ControlItemDescriptionCustomization(state = state) } + { ControlItemDescriptionCustomization(state = state) }, + { ControlItemConstrainedMaxWidthCustomization(state = state) } ) extraCustomizations.forEach { (index, content) -> customizations.add(minOf(index, customizations.count()), content) @@ -168,6 +170,17 @@ private fun ControlItemDescriptionCustomization(state: ControlItemDemoState) { } } +@Composable +private fun ControlItemConstrainedMaxWidthCustomization(state: ControlItemDemoState) { + with(state) { + CustomizationSwitchItem( + label = stringResource(R.string.app_components_common_constrainedMaxWidth_label), + checked = constrainedMaxWidth, + onCheckedChange = { constrainedMaxWidth = it }, + ) + } +} + fun FunctionCall.Builder.controlItemArguments(state: ControlItemDemoState, themeDrawableResources: ThemeDrawableResources, hasErrorMessage: Boolean = false) = with(state) { labelArgument(label) @@ -187,4 +200,5 @@ fun FunctionCall.Builder.controlItemArguments(state: ControlItemDemoState, theme typedArgument("message", if (hasErrorMessage) errorMessage else "") } } + if (constrainedMaxWidth) constrainedMaxWidthArgument(constrainedMaxWidth) } \ No newline at end of file diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoState.kt b/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoState.kt index 9c41abed8..205e04b06 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoState.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/controlitem/ControlItemDemoState.kt @@ -27,7 +27,8 @@ open class ControlItemDemoState( error: Boolean, errorMessage: String, label: String, - description: String? + description: String?, + constrainedMaxWidth: Boolean ) { companion object { @@ -45,7 +46,8 @@ open class ControlItemDemoState( error, errorMessage, label, - description + description, + constrainedMaxWidth ) } }, @@ -59,14 +61,16 @@ open class ControlItemDemoState( list[5] as Boolean, list[6] as Boolean, list[7] as String, - list[7] as String, - list[8] as String? + list[8] as String, + list[9] as String?, + list[10] as Boolean ) } ) } var icon: Boolean by mutableStateOf(icon) + var constrainedMaxWidth: Boolean by mutableStateOf(constrainedMaxWidth) var edgeToEdge: Boolean by mutableStateOf(edgeToEdge) var divider: Boolean by mutableStateOf(divider) var reversed: Boolean by mutableStateOf(reversed) diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoScreen.kt b/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoScreen.kt index 8cd7ee058..6e19df97c 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoScreen.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoScreen.kt @@ -101,7 +101,8 @@ private fun RadioButtonItemDemoContent(state: RadioButtonItemDemoState) { reversed = reversed, enabled = enabled, readOnly = readOnly, - error = if (error) OudsError(if (isLastItem) errorMessage else "") else null + error = if (error) OudsError(if (isLastItem) errorMessage else "") else null, + constrainedMaxWidth = constrainedMaxWidth ) } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoState.kt b/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoState.kt index 9bb1aad67..cc2d2e9e6 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoState.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/radiobutton/RadioButtonItemDemoState.kt @@ -37,7 +37,8 @@ fun rememberRadioButtonItemDemoState( errorMessage: String = stringResource(id = R.string.app_components_common_errorMessage_label), label: String = stringResource(id = R.string.app_components_common_label_label), extraLabel: String? = null, - description: String? = null + description: String? = null, + constrainedMaxWidth: Boolean = false ) = rememberSaveable( selectedValue, icon, @@ -52,9 +53,25 @@ fun rememberRadioButtonItemDemoState( label, extraLabel, description, + constrainedMaxWidth, saver = RadioButtonItemDemoState.Saver ) { - RadioButtonItemDemoState(selectedValue, icon, edgeToEdge, divider, outlined, reversed, enabled, readOnly, error, errorMessage, label, extraLabel, description) + RadioButtonItemDemoState( + selectedValue, + icon, + edgeToEdge, + divider, + outlined, + reversed, + enabled, + readOnly, + error, + errorMessage, + label, + extraLabel, + description, + constrainedMaxWidth + ) } class RadioButtonItemDemoState( @@ -70,8 +87,9 @@ class RadioButtonItemDemoState( errorMessage: String, label: String, extraLabel: String?, - description: String? -) : ControlItemDemoState(icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, label, description) { + description: String?, + constrainedMaxWidth: Boolean, +) : ControlItemDemoState(icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, label, description, constrainedMaxWidth) { companion object { val values = listOf(1, 2) @@ -102,7 +120,8 @@ class RadioButtonItemDemoState( errorMessage, label, list[2] as String?, - description + description, + constrainedMaxWidth ) } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoScreen.kt b/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoScreen.kt index 8071acfca..4e19dd508 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoScreen.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoScreen.kt @@ -59,7 +59,8 @@ private fun SwitchItemDemoContent(state: SwitchItemDemoState) { reversed = reversed, enabled = enabled, readOnly = readOnly, - error = if (error) OudsError(errorMessage) else null + error = if (error) OudsError(errorMessage) else null, + constrainedMaxWidth = constrainedMaxWidth ) } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoState.kt b/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoState.kt index 08d60b1a1..6394e1c79 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoState.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/switch/SwitchItemDemoState.kt @@ -34,9 +34,24 @@ fun rememberSwitchItemDemoState( error: Boolean = false, errorMessage: String = stringResource(id = R.string.app_components_common_errorMessage_label), text: String = stringResource(id = R.string.app_components_common_label_label), - description: String? = null -) = rememberSaveable(checked, icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, text, description, saver = SwitchItemDemoState.Saver) { - SwitchItemDemoState(checked, icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, text, description) + description: String? = null, + constrainedMaxWidth: Boolean = false +) = rememberSaveable( + checked, + icon, + edgeToEdge, + divider, + reversed, + enabled, + readOnly, + error, + errorMessage, + text, + description, + constrainedMaxWidth, + saver = SwitchItemDemoState.Saver +) { + SwitchItemDemoState(checked, icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, text, description, constrainedMaxWidth) } class SwitchItemDemoState( @@ -50,8 +65,9 @@ class SwitchItemDemoState( error: Boolean, errorMessage: String, text: String, - description: String? -) : ControlItemDemoState(icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, text, description) { + description: String?, + constrainedMaxWidth: Boolean +) : ControlItemDemoState(icon, edgeToEdge, divider, reversed, enabled, readOnly, error, errorMessage, text, description, constrainedMaxWidth) { companion object { @@ -76,7 +92,8 @@ class SwitchItemDemoState( error, errorMessage, label, - description + description, + constrainedMaxWidth ) } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoScreen.kt b/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoScreen.kt index fa8a8b79e..a883c41d5 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoScreen.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoScreen.kt @@ -18,6 +18,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.PreviewLightDark import com.orange.ouds.app.R import com.orange.ouds.app.ui.components.Component +import com.orange.ouds.app.ui.components.constrainedMaxWidthArgument import com.orange.ouds.app.ui.components.contentDescriptionArgument import com.orange.ouds.app.ui.components.enabledArgument import com.orange.ouds.app.ui.components.onClickArgument @@ -136,6 +137,11 @@ private fun TextInputDemoBottomSheetContent(state: TextInputDemoState) { value = helperLink, onValueChange = { value -> helperLink = value } ) + CustomizationSwitchItem( + label = stringResource(R.string.app_components_common_constrainedMaxWidth_label), + checked = constrainedMaxWidth, + onCheckedChange = { constrainedMaxWidth = it }, + ) } } @@ -171,7 +177,8 @@ private fun TextInputDemoContent(state: TextInputDemoState) { prefix = prefix, suffix = suffix, helperText = helperText, - helperLink = if (helperLink.isNotEmpty()) OudsTextInputHelperLink(text = helperLink, onClick = { }) else null + helperLink = if (helperLink.isNotEmpty()) OudsTextInputHelperLink(text = helperLink, onClick = { }) else null, + constrainedMaxWidth = constrainedMaxWidth ) } } @@ -223,6 +230,7 @@ private fun Code.Builder.textInputDemoCodeSnippet(state: TextInputDemoState, the } } } + if (constrainedMaxWidth) constrainedMaxWidthArgument(true) } } } diff --git a/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoState.kt b/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoState.kt index 77a3dbe82..ef67c6042 100644 --- a/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoState.kt +++ b/app/src/main/java/com/orange/ouds/app/ui/components/textinput/TextInputDemoState.kt @@ -38,6 +38,7 @@ fun rememberTextInputDemoState( suffix: String = "", helperText: String = "", helperLink: String = "", + constrainedMaxWidth: Boolean = false ) = rememberSaveable( value, label, @@ -53,6 +54,7 @@ fun rememberTextInputDemoState( suffix, helperText, helperLink, + constrainedMaxWidth, saver = TextInputDemoState.Saver ) { TextInputDemoState( @@ -70,7 +72,8 @@ fun rememberTextInputDemoState( prefix, suffix, helperText, - helperLink + helperLink, + constrainedMaxWidth ) } @@ -90,6 +93,7 @@ class TextInputDemoState( suffix: String, helperText: String, helperLink: String, + constrainedMaxWidth: Boolean ) { companion object { @@ -112,7 +116,8 @@ class TextInputDemoState( prefix, suffix, helperText, - helperLink + helperLink, + constrainedMaxWidth ) } }, @@ -132,7 +137,8 @@ class TextInputDemoState( list[11] as String, list[12] as String, list[13] as String, - list[14] as String + list[14] as String, + list[15] as Boolean ) } ) @@ -168,6 +174,8 @@ class TextInputDemoState( var helperLink: String by mutableStateOf(helperLink) + var constrainedMaxWidth: Boolean by mutableStateOf(constrainedMaxWidth) + val enabledSwitchEnabled: Boolean get() = !error && !hasLoader diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5e5b5bcec..f3f87d4a0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -120,6 +120,7 @@ Appearance Clear value Color + Constrained max width Error message Error Error message diff --git a/core-test/src/main/java/com/orange/ouds/core/test/OudsCheckboxItemTest.kt b/core-test/src/main/java/com/orange/ouds/core/test/OudsCheckboxItemTest.kt index ca108685b..dbb65c2c9 100644 --- a/core-test/src/main/java/com/orange/ouds/core/test/OudsCheckboxItemTest.kt +++ b/core-test/src/main/java/com/orange/ouds/core/test/OudsCheckboxItemTest.kt @@ -59,4 +59,18 @@ class OudsCheckboxItemTest { parameter = null, OudsComponentTestSuite.theme ) + + @RunWith(Parameterized::class) + class ConstrainedMaxWidth(parameter: Any) : OudsComponentSnapshotTest( + OudsPreviewableComponent.CheckboxItem.ConstrainedMaxWidth, + parameter, + OudsComponentTestSuite.theme, + OudsPreviewableComponent.CheckboxItem.ConstrainedMaxWidth.PreviewWidthDp + ) { + companion object { + @JvmStatic + @Parameterized.Parameters + internal fun data() = OudsPreviewableComponent.CheckboxItem.ConstrainedMaxWidth.parameters + } + } } \ No newline at end of file diff --git a/core-test/src/main/java/com/orange/ouds/core/test/OudsRadioButtonItemTest.kt b/core-test/src/main/java/com/orange/ouds/core/test/OudsRadioButtonItemTest.kt index 881dc963a..a510a0848 100644 --- a/core-test/src/main/java/com/orange/ouds/core/test/OudsRadioButtonItemTest.kt +++ b/core-test/src/main/java/com/orange/ouds/core/test/OudsRadioButtonItemTest.kt @@ -59,4 +59,18 @@ class OudsRadioButtonItemTest { parameter = null, OudsComponentTestSuite.theme ) + + @RunWith(Parameterized::class) + class ConstrainedMaxWidth(parameter: Any) : OudsComponentSnapshotTest( + OudsPreviewableComponent.RadioButtonItem.ConstrainedMaxWidth, + parameter, + OudsComponentTestSuite.theme, + OudsPreviewableComponent.RadioButtonItem.ConstrainedMaxWidth.PreviewWidthDp + ) { + companion object { + @JvmStatic + @Parameterized.Parameters + internal fun data() = OudsPreviewableComponent.RadioButtonItem.ConstrainedMaxWidth.parameters + } + } } \ No newline at end of file diff --git a/core-test/src/main/java/com/orange/ouds/core/test/OudsSwitchItemTest.kt b/core-test/src/main/java/com/orange/ouds/core/test/OudsSwitchItemTest.kt index 255b0a105..a0e4bfdfb 100644 --- a/core-test/src/main/java/com/orange/ouds/core/test/OudsSwitchItemTest.kt +++ b/core-test/src/main/java/com/orange/ouds/core/test/OudsSwitchItemTest.kt @@ -45,4 +45,18 @@ class OudsSwitchItemTest { parameter = null, OudsComponentTestSuite.theme ) + + @RunWith(Parameterized::class) + class ConstrainedMaxWidth(parameter: Any) : OudsComponentSnapshotTest( + OudsPreviewableComponent.SwitchItem.ConstrainedMaxWidth, + parameter, + OudsComponentTestSuite.theme, + OudsPreviewableComponent.SwitchItem.ConstrainedMaxWidth.PreviewWidthDp + ) { + companion object { + @JvmStatic + @Parameterized.Parameters + internal fun data() = OudsPreviewableComponent.SwitchItem.ConstrainedMaxWidth.parameters + } + } } diff --git a/core-test/src/main/java/com/orange/ouds/core/test/OudsTextInputTest.kt b/core-test/src/main/java/com/orange/ouds/core/test/OudsTextInputTest.kt index eea60ce2c..a2c3f83f4 100644 --- a/core-test/src/main/java/com/orange/ouds/core/test/OudsTextInputTest.kt +++ b/core-test/src/main/java/com/orange/ouds/core/test/OudsTextInputTest.kt @@ -45,4 +45,18 @@ class OudsTextInputTest { parameter = null, OudsComponentTestSuite.theme ) + + @RunWith(Parameterized::class) + class ConstrainedMaxWidth(parameter: Any) : OudsComponentSnapshotTest( + OudsPreviewableComponent.TextInput.ConstrainedMaxWidth, + parameter, + OudsComponentTestSuite.theme, + OudsPreviewableComponent.TextInput.ConstrainedMaxWidth.PreviewWidthDp + ) { + companion object { + @JvmStatic + @Parameterized.Parameters + internal fun data() = OudsPreviewableComponent.TextInput.ConstrainedMaxWidth.parameters + } + } } diff --git a/core/src/main/java/com/orange/ouds/core/component/OudsCheckboxItem.kt b/core/src/main/java/com/orange/ouds/core/component/OudsCheckboxItem.kt index a650c00ac..787adb7f6 100644 --- a/core/src/main/java/com/orange/ouds/core/component/OudsCheckboxItem.kt +++ b/core/src/main/java/com/orange/ouds/core/component/OudsCheckboxItem.kt @@ -15,6 +15,7 @@ package com.orange.ouds.core.component import androidx.compose.foundation.interaction.Interaction import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.selection.triStateToggleable import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Call @@ -28,10 +29,12 @@ import androidx.compose.ui.state.ToggleableState import androidx.compose.ui.tooling.preview.Preview 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.component.common.OudsError import com.orange.ouds.core.extensions.collectInteractionStateAsState import com.orange.ouds.core.utilities.LoremIpsumText import com.orange.ouds.core.utilities.OudsPreview +import com.orange.ouds.core.utilities.OudsPreviewableComponent import com.orange.ouds.core.utilities.PreviewEnumEntries import com.orange.ouds.core.utilities.getPreviewTheme import com.orange.ouds.theme.OudsThemeContract @@ -67,6 +70,9 @@ import com.orange.ouds.theme.OudsThemeContract * @param readOnly Controls the read-only state of the checkbox item. When `true` the item's checkbox is disabled but the texts and the icon remain in * enabled color. Note that if it is set to `true` and [enabled] is set to `false`, the checkbox item will be displayed in disabled state. * @param error Optional [OudsError] to indicate that the checkbox item should appear in error state, `null` otherwise. + * @param constrainedMaxWidth When `true`, the item width is constrained to a maximum value defined by the design system. + * When `false`, no specific width constraint is applied, allowing the component to size itself or follow external modifiers. + * Defaults to `false`. * @param interactionSource Optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s for the item's checkbox. Note that if `null` * is provided, interactions will still happen internally. * @@ -86,6 +92,7 @@ fun OudsCheckboxItem( enabled: Boolean = true, readOnly: Boolean = false, error: OudsError? = null, + constrainedMaxWidth: Boolean = false, interactionSource: MutableInteractionSource? = null ) { OudsTriStateCheckboxItem( @@ -103,6 +110,7 @@ fun OudsCheckboxItem( enabled = enabled, readOnly = readOnly, error = error, + constrainedMaxWidth = constrainedMaxWidth, interactionSource = interactionSource ) } @@ -143,6 +151,9 @@ fun OudsCheckboxItem( * @param readOnly Controls the read-only state of the checkbox item. When `true` the item's checkbox is disabled but the texts and the icon remain in * enabled color. Note that if it is set to `true` and [enabled] is set to `false`, the checkbox item will be displayed in disabled state. * @param error Optional [OudsError] to indicate that the checkbox item should appear in error state, `null` otherwise. + * @param constrainedMaxWidth When `true`, the item width is constrained to a maximum value defined by the design system. + * When `false`, no specific width constraint is applied, allowing the component to size itself or follow external modifiers. + * Defaults to `false`. * @param interactionSource Optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s for the item's checkbox. Note that * if `null` is provided, interactions will still happen internally. * @@ -162,6 +173,7 @@ fun OudsTriStateCheckboxItem( enabled: Boolean = true, readOnly: Boolean = false, error: OudsError? = null, + constrainedMaxWidth: Boolean = false, interactionSource: MutableInteractionSource? = null ) { @Suppress("NAME_SHADOWING") val interactionSource = interactionSource ?: remember { MutableInteractionSource() } @@ -210,7 +222,8 @@ fun OudsTriStateCheckboxItem( modifier = modifier .then(toggleableModifier) .semantics(mergeDescendants = true) {}, - handleHighContrastMode = true + handleHighContrastMode = true, + constrainedMaxWidth = constrainedMaxWidth ) } @@ -309,6 +322,27 @@ internal fun PreviewOudsCheckboxItemWithEdgeToEdgeDisabled(theme: OudsThemeContr } } +@Preview(widthDp = OudsPreviewableComponent.CheckboxItem.ConstrainedMaxWidth.PreviewWidthDp) +@Composable +@Suppress("PreviewShouldNotBeCalledRecursively") +internal fun PreviewOudsCheckboxItemConstrainedMaxWidth(@PreviewParameter(OudsControlItemConstrainedMaxWidthPreviewParameterProvider::class) constrainedMaxWidth: Boolean) { + PreviewOudsCheckboxItemConstrainedMaxWidth(theme = getPreviewTheme(), constrainedMaxWidth = constrainedMaxWidth) +} + +@Composable +internal fun PreviewOudsCheckboxItemConstrainedMaxWidth(theme: OudsThemeContract, constrainedMaxWidth: Boolean) = OudsPreview(theme = theme) { + OudsCheckboxItem( + modifier = Modifier.padding(all = 10.dp), + checked = true, + label = "Label", + onCheckedChange = {}, + icon = OudsControlItemIcon(imageVector = Icons.Filled.Call), + constrainedMaxWidth = constrainedMaxWidth, + edgeToEdge = false, + divider = true + ) +} + internal typealias OudsCheckboxItemPreviewParameter = OudsControlItemPreviewParameter internal class OudsCheckboxItemPreviewParameterProvider : @@ -317,4 +351,4 @@ internal class OudsCheckboxItemPreviewParameterProvider : internal typealias OudsCheckboxItemHighContrastModePreviewParameter = OudsControlItemHighContrastModePreviewParameter internal class OudsCheckboxItemHighContrastModePreviewParameterProvider : - OudsControlItemHighContrastModePreviewParameterProvider(listOf(ToggleableState.Off, ToggleableState.On)) + OudsControlItemHighContrastModePreviewParameterProvider(listOf(ToggleableState.Off, ToggleableState.On)) \ No newline at end of file diff --git a/core/src/main/java/com/orange/ouds/core/component/OudsControlItem.kt b/core/src/main/java/com/orange/ouds/core/component/OudsControlItem.kt index 64695da50..f3877757b 100644 --- a/core/src/main/java/com/orange/ouds/core/component/OudsControlItem.kt +++ b/core/src/main/java/com/orange/ouds/core/component/OudsControlItem.kt @@ -39,6 +39,7 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.semantics.clearAndSetSemantics import androidx.compose.ui.semantics.error import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.max import com.orange.ouds.core.component.common.OudsError @@ -75,6 +76,7 @@ internal fun OudsControlItem( modifier: Modifier = Modifier, contentModifier: Modifier = Modifier, extraLabel: String? = null, + constrainedMaxWidth: Boolean = false, handleHighContrastMode: Boolean = false ) { val previewState = getPreviewEnumEntry() @@ -125,7 +127,7 @@ internal fun OudsControlItem( modifier = Modifier .height(IntrinsicSize.Min) .heightIn(min = controlItemTokens.sizeMinHeight.dp) - .widthIn(min = controlItemTokens.sizeMinWidth.dp, max = controlItemTokens.sizeMaxWidth.dp) + .widthIn(min = controlItemTokens.sizeMinWidth.dp, max = if (constrainedMaxWidth) controlItemTokens.sizeMaxWidth.dp else Dp.Unspecified) .background(color = backgroundColor, shape = shape) .then(contentModifier) .outerBorder(state = state, shape = shape, handleHighContrastMode = handleHighContrastMode), @@ -385,6 +387,8 @@ private fun getHighContrastModePreviewParameterValues(values: List): List } } +internal class OudsControlItemConstrainedMaxWidthPreviewParameterProvider : BasicPreviewParameterProvider(false, true) + /** * Error message used in control items previews. */ diff --git a/core/src/main/java/com/orange/ouds/core/component/OudsRadioButtonItem.kt b/core/src/main/java/com/orange/ouds/core/component/OudsRadioButtonItem.kt index 96c312a60..02532e31e 100644 --- a/core/src/main/java/com/orange/ouds/core/component/OudsRadioButtonItem.kt +++ b/core/src/main/java/com/orange/ouds/core/component/OudsRadioButtonItem.kt @@ -16,6 +16,7 @@ import androidx.compose.foundation.border import androidx.compose.foundation.interaction.Interaction import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.selection.selectable import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Call @@ -29,12 +30,14 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.tooling.preview.Preview 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.component.common.OudsError import com.orange.ouds.core.extensions.collectInteractionStateAsState import com.orange.ouds.core.theme.OudsTheme import com.orange.ouds.core.theme.takeUnlessHairline import com.orange.ouds.core.utilities.LoremIpsumText import com.orange.ouds.core.utilities.OudsPreview +import com.orange.ouds.core.utilities.OudsPreviewableComponent import com.orange.ouds.core.utilities.PreviewEnumEntries import com.orange.ouds.core.utilities.getPreviewTheme import com.orange.ouds.theme.OudsThemeContract @@ -71,6 +74,9 @@ import com.orange.ouds.theme.OudsThemeContract * @param readOnly Controls the read-only state of the radio button item. When `true` the item's radio button is disabled but the texts and the icon remain in * enabled color. Note that if it is set to `true` and [enabled] is set to `false`, the radio button item will be displayed in disabled state. * @param error Optional [OudsError] to indicate that the radio button item should appear in error state, `null` otherwise. + * @param constrainedMaxWidth When `true`, the item width is constrained to a maximum value defined by the design system. + * When `false`, no specific width constraint is applied, allowing the component to size itself or follow external modifiers. + * Defaults to `false`. * @param interactionSource Optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s for the item's radio button. Note that if `null` * is provided, interactions will still happen internally. * @@ -92,6 +98,7 @@ fun OudsRadioButtonItem( enabled: Boolean = true, readOnly: Boolean = false, error: OudsError? = null, + constrainedMaxWidth: Boolean = false, interactionSource: MutableInteractionSource? = null ) { @Suppress("NAME_SHADOWING") val interactionSource = interactionSource ?: remember { MutableInteractionSource() } @@ -140,6 +147,7 @@ fun OudsRadioButtonItem( .then(selectableModifier) .semantics(mergeDescendants = true) {}, contentModifier = Modifier.border(outlined = outlined, selected = selected, error = error, state = state), + constrainedMaxWidth = constrainedMaxWidth, handleHighContrastMode = true ) } @@ -280,6 +288,28 @@ internal fun PreviewOudsRadioButtonItemWithEdgeToEdgeDisabled(theme: OudsThemeCo } } +@Preview(widthDp = OudsPreviewableComponent.RadioButtonItem.ConstrainedMaxWidth.PreviewWidthDp) +@Composable +@Suppress("PreviewShouldNotBeCalledRecursively") +internal fun PreviewOudsRadioButtonItemConstrainedMaxWidth(@PreviewParameter(OudsControlItemConstrainedMaxWidthPreviewParameterProvider::class) constrainedMaxWidth: Boolean) { + PreviewOudsRadioButtonItemConstrainedMaxWidth(theme = getPreviewTheme(), constrainedMaxWidth = constrainedMaxWidth) +} + +@Composable +internal fun PreviewOudsRadioButtonItemConstrainedMaxWidth(theme: OudsThemeContract, constrainedMaxWidth: Boolean) = OudsPreview(theme = theme) { + OudsRadioButtonItem( + modifier = Modifier.padding(all = 10.dp), + selected = false, + label = "Label", + onClick = {}, + extraLabel = "Extra label", + icon = OudsControlItemIcon(imageVector = Icons.Filled.Call), + edgeToEdge = false, + divider = true, + constrainedMaxWidth = constrainedMaxWidth + ) +} + internal typealias OudsRadioButtonItemPreviewParameter = OudsControlItemPreviewParameter private val previewOutlinedValues = listOf(false, true, true) diff --git a/core/src/main/java/com/orange/ouds/core/component/OudsSwitchItem.kt b/core/src/main/java/com/orange/ouds/core/component/OudsSwitchItem.kt index d748fc6bf..fdd07136d 100644 --- a/core/src/main/java/com/orange/ouds/core/component/OudsSwitchItem.kt +++ b/core/src/main/java/com/orange/ouds/core/component/OudsSwitchItem.kt @@ -15,6 +15,7 @@ package com.orange.ouds.core.component import androidx.compose.foundation.interaction.Interaction import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.layout.padding import androidx.compose.foundation.selection.toggleable import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Call @@ -27,12 +28,15 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.tooling.preview.Preview 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.component.common.OudsError import com.orange.ouds.core.extensions.collectInteractionStateAsState import com.orange.ouds.core.utilities.LoremIpsumText import com.orange.ouds.core.utilities.OudsPreview +import com.orange.ouds.core.utilities.OudsPreviewableComponent import com.orange.ouds.core.utilities.PreviewEnumEntries import com.orange.ouds.core.utilities.getPreviewTheme +import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider import com.orange.ouds.theme.OudsThemeContract /** @@ -67,6 +71,9 @@ import com.orange.ouds.theme.OudsThemeContract * @param readOnly Controls the read-only state of the switch item. When `true`, the item's switch is disabled but the texts and the icon remain in the * enabled color. Note that if it is set to `true` and [enabled] is set to `false`, the switch item will be displayed in the disabled state. * @param error Optional [OudsError] to provide if the switch item should appear in an error state, `null` otherwise. + * @param constrainedMaxWidth When `true`, the item width is constrained to a maximum value defined by the design system. + * When `false`, no specific width constraint is applied, allowing the component to size itself or follow external modifiers. + * Defaults to `false`. * @param interactionSource Optional hoisted [MutableInteractionSource] for observing and emitting [Interaction]s for the item's switch. Note that if `null` * is provided, interactions will still happen internally. * @@ -86,6 +93,7 @@ fun OudsSwitchItem( enabled: Boolean = true, readOnly: Boolean = false, error: OudsError? = null, + constrainedMaxWidth: Boolean = false, interactionSource: MutableInteractionSource? = null ) { @Suppress("NAME_SHADOWING") val interactionSource = interactionSource ?: remember { MutableInteractionSource() } @@ -128,7 +136,8 @@ fun OudsSwitchItem( backgroundColor = backgroundColor.value, modifier = modifier .then(toggleableModifier) - .semantics(mergeDescendants = true) {} + .semantics(mergeDescendants = true) {}, + constrainedMaxWidth = constrainedMaxWidth ) } @@ -198,6 +207,27 @@ internal fun PreviewOudsSwitchItemWithEdgeToEdgeDisabled(theme: OudsThemeContrac } } +@Preview(widthDp = OudsPreviewableComponent.SwitchItem.ConstrainedMaxWidth.PreviewWidthDp) +@Composable +@Suppress("PreviewShouldNotBeCalledRecursively") +internal fun PreviewOudsSwitchItemConstrainedMaxWidth(@PreviewParameter(OudsControlItemConstrainedMaxWidthPreviewParameterProvider ::class) constrainedMaxWidth: Boolean) { + PreviewOudsSwitchItemConstrainedMaxWidth(theme = getPreviewTheme(), constrainedMaxWidth = constrainedMaxWidth) +} + +@Composable +internal fun PreviewOudsSwitchItemConstrainedMaxWidth(theme: OudsThemeContract, constrainedMaxWidth: Boolean) = OudsPreview(theme = theme) { + OudsSwitchItem( + modifier = Modifier.padding(all = 10.dp), + checked = true, + label = "Label", + onCheckedChange = {}, + icon = OudsControlItemIcon(imageVector = Icons.Filled.Call), + constrainedMaxWidth = constrainedMaxWidth, + edgeToEdge = false, + divider = true + ) +} + internal typealias OudsSwitchItemPreviewParameter = OudsControlItemPreviewParameter -internal class OudsSwitchItemPreviewParameterProvider : OudsControlItemPreviewParameterProvider(DefaultBooleanValues) +internal class OudsSwitchItemPreviewParameterProvider : OudsControlItemPreviewParameterProvider(DefaultBooleanValues) \ No newline at end of file diff --git a/core/src/main/java/com/orange/ouds/core/component/OudsTextInput.kt b/core/src/main/java/com/orange/ouds/core/component/OudsTextInput.kt index 8648dc3e6..1c7d89950 100644 --- a/core/src/main/java/com/orange/ouds/core/component/OudsTextInput.kt +++ b/core/src/main/java/com/orange/ouds/core/component/OudsTextInput.kt @@ -166,6 +166,7 @@ fun OudsTextInput( error: OudsError? = null, helperText: String? = null, helperLink: OudsTextInputHelperLink? = null, + constrainedMaxWidth: Boolean = false, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, onKeyboardAction: KeyboardActionHandler? = null, onTextLayout: (Density.(getResult: () -> TextLayoutResult?) -> Unit)? = null, @@ -216,7 +217,8 @@ fun OudsTextInput( outlined = outlined, error = error, helperText = helperText, - helperLink = helperLink + helperLink = helperLink, + constrainedMaxWidth = constrainedMaxWidth ) } ) @@ -287,6 +289,7 @@ fun OudsTextInput( error: OudsError? = null, helperText: String? = null, helperLink: OudsTextInputHelperLink? = null, + constrainedMaxWidth: Boolean = false, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, onTextLayout: (TextLayoutResult) -> Unit = {}, @@ -336,7 +339,8 @@ fun OudsTextInput( outlined = outlined, error = error, helperText = helperText, - helperLink = helperLink + helperLink = helperLink, + constrainedMaxWidth = constrainedMaxWidth ) } @@ -408,6 +412,7 @@ fun OudsTextInput( error: OudsError? = null, helperText: String? = null, helperLink: OudsTextInputHelperLink? = null, + constrainedMaxWidth: Boolean = false, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, keyboardActions: KeyboardActions = KeyboardActions.Default, onTextLayout: (TextLayoutResult) -> Unit = {}, @@ -457,7 +462,8 @@ fun OudsTextInput( outlined = outlined, error = error, helperText = helperText, - helperLink = helperLink + helperLink = helperLink, + constrainedMaxWidth = constrainedMaxWidth ) } ) @@ -523,6 +529,7 @@ private fun OudsTextInputDecorator( error: OudsError?, helperText: String?, helperLink: OudsTextInputHelperLink?, + constrainedMaxWidth: Boolean, ) { val hasError = error != null with(OudsTheme.componentsTokens.textInput) { @@ -553,7 +560,7 @@ private fun OudsTextInputDecorator( Column { Row( modifier = styleModifier - .sizeIn(minWidth = sizeMinWidth.dp, maxWidth = sizeMaxWidth.dp, minHeight = sizeMinHeight.dp) + .sizeIn(minWidth = sizeMinWidth.dp, maxWidth = if (constrainedMaxWidth) sizeMaxWidth.dp else Dp.Unspecified, minHeight = sizeMinHeight.dp) .padding(vertical = spacePaddingBlockDefault.value) .padding( start = spacePaddingInlineDefault.value, @@ -1110,6 +1117,24 @@ internal fun PreviewOudsTextInputWithLongLabels(theme: OudsThemeContract) = Ouds } } +@Preview(widthDp = OudsPreviewableComponent.TextInput.ConstrainedMaxWidth.PreviewWidthDp) +@Composable +@Suppress("PreviewShouldNotBeCalledRecursively") +internal fun PreviewOudsTextInputConstrainedMaxWidth(@PreviewParameter(OudsTextInputConstrainedMaxWidthPreviewParameterProvider::class) constrainedMaxWidth: Boolean) { + PreviewOudsTextInputConstrainedMaxWidth(theme = getPreviewTheme(), constrainedMaxWidth = constrainedMaxWidth) +} + +@Composable +internal fun PreviewOudsTextInputConstrainedMaxWidth(theme: OudsThemeContract, constrainedMaxWidth: Boolean) = OudsPreview(theme = theme) { + OudsTextInput( + modifier = Modifier.padding(all = 10.dp), + textFieldState = rememberTextFieldState(), + label = "Label", + placeholder = "Placeholder", + constrainedMaxWidth = constrainedMaxWidth + ) +} + internal data class OudsTextInputPreviewParameter( val value: String, val label: String? = null, @@ -1127,6 +1152,8 @@ internal data class OudsTextInputPreviewParameter( internal class OudsTextInputPreviewParameterProvider : BasicPreviewParameterProvider(*previewParameterValues.toTypedArray()) +internal class OudsTextInputConstrainedMaxWidthPreviewParameterProvider : BasicPreviewParameterProvider(false, true) + private val previewParameterValues: List get() { val label = "Label" diff --git a/core/src/main/java/com/orange/ouds/core/utilities/OudsPreviewableComponent.kt b/core/src/main/java/com/orange/ouds/core/utilities/OudsPreviewableComponent.kt index f9381bb08..c888cf888 100644 --- a/core/src/main/java/com/orange/ouds/core/utilities/OudsPreviewableComponent.kt +++ b/core/src/main/java/com/orange/ouds/core/utilities/OudsPreviewableComponent.kt @@ -28,6 +28,7 @@ import com.orange.ouds.core.component.OudsCheckboxPreviewParameter import com.orange.ouds.core.component.OudsCheckboxPreviewParameterProvider import com.orange.ouds.core.component.OudsColoredBoxColor import com.orange.ouds.core.component.OudsColoredBoxPreviewParameterProvider +import com.orange.ouds.core.component.OudsControlItemConstrainedMaxWidthPreviewParameterProvider import com.orange.ouds.core.component.OudsDividerColor import com.orange.ouds.core.component.OudsDividerOrientation import com.orange.ouds.core.component.OudsDividerPreviewParameterProvider @@ -50,6 +51,7 @@ import com.orange.ouds.core.component.OudsSwitchItemPreviewParameterProvider import com.orange.ouds.core.component.OudsSwitchPreviewParameterProvider import com.orange.ouds.core.component.OudsTagPreviewParameter import com.orange.ouds.core.component.OudsTagPreviewParameterProvider +import com.orange.ouds.core.component.OudsTextInputConstrainedMaxWidthPreviewParameterProvider import com.orange.ouds.core.component.OudsTextInputPreviewParameter import com.orange.ouds.core.component.OudsTextInputPreviewParameterProvider import com.orange.ouds.core.component.OudsTopAppBarPreviewParameter @@ -62,6 +64,7 @@ import com.orange.ouds.core.component.PreviewOudsButtonWithRoundedCorners import com.orange.ouds.core.component.PreviewOudsCenterAlignedTopAppBar import com.orange.ouds.core.component.PreviewOudsCheckbox import com.orange.ouds.core.component.PreviewOudsCheckboxItem +import com.orange.ouds.core.component.PreviewOudsCheckboxItemConstrainedMaxWidth import com.orange.ouds.core.component.PreviewOudsCheckboxItemHighContrastModeEnabled import com.orange.ouds.core.component.PreviewOudsCheckboxItemWithEdgeToEdgeDisabled import com.orange.ouds.core.component.PreviewOudsCheckboxItemWithLongDescription @@ -77,16 +80,19 @@ import com.orange.ouds.core.component.PreviewOudsNavigationBar import com.orange.ouds.core.component.PreviewOudsNavigationBarItem import com.orange.ouds.core.component.PreviewOudsRadioButton import com.orange.ouds.core.component.PreviewOudsRadioButtonItem +import com.orange.ouds.core.component.PreviewOudsRadioButtonItemConstrainedMaxWidth import com.orange.ouds.core.component.PreviewOudsRadioButtonItemHighContrastModeEnabled import com.orange.ouds.core.component.PreviewOudsRadioButtonItemWithDescriptionText import com.orange.ouds.core.component.PreviewOudsRadioButtonItemWithEdgeToEdgeDisabled import com.orange.ouds.core.component.PreviewOudsSuggestionChip import com.orange.ouds.core.component.PreviewOudsSwitch import com.orange.ouds.core.component.PreviewOudsSwitchItem +import com.orange.ouds.core.component.PreviewOudsSwitchItemConstrainedMaxWidth import com.orange.ouds.core.component.PreviewOudsSwitchItemWithEdgeToEdgeDisabled import com.orange.ouds.core.component.PreviewOudsSwitchItemWithLongDescription import com.orange.ouds.core.component.PreviewOudsTag import com.orange.ouds.core.component.PreviewOudsTextInput +import com.orange.ouds.core.component.PreviewOudsTextInputConstrainedMaxWidth import com.orange.ouds.core.component.PreviewOudsTextInputWithLongLabels import com.orange.ouds.core.component.PreviewOudsTextInputWithRoundedCorners import com.orange.ouds.core.component.PreviewOudsTopAppBar @@ -243,6 +249,20 @@ interface OudsPreviewableComponent { override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled } + + object ConstrainedMaxWidth : OudsPreviewableComponent { + + const val PreviewWidthDp = 600 + + override val parameters: List = OudsControlItemConstrainedMaxWidthPreviewParameterProvider().values.toList() + + @Composable + override fun Preview(theme: OudsThemeContract, darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean, parameter: Any?) { + PreviewOudsCheckboxItemConstrainedMaxWidth(theme, parameter as Boolean) + } + + override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled + } } object Checkbox : OudsPreviewableComponent { @@ -454,6 +474,21 @@ interface OudsPreviewableComponent { override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled } + + object ConstrainedMaxWidth : OudsPreviewableComponent { + + const val PreviewWidthDp = 600 + + override val parameters: List = OudsControlItemConstrainedMaxWidthPreviewParameterProvider().values.toList() + + @Composable + override fun Preview(theme: OudsThemeContract, darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean, parameter: Any?) { + PreviewOudsRadioButtonItemConstrainedMaxWidth(theme, parameter as Boolean) + } + + override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled + } + } object RadioButton : OudsPreviewableComponent { @@ -529,6 +564,20 @@ interface OudsPreviewableComponent { override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled } + + object ConstrainedMaxWidth : OudsPreviewableComponent { + + const val PreviewWidthDp = 600 + + override val parameters: List = OudsControlItemConstrainedMaxWidthPreviewParameterProvider().values.toList() + + @Composable + override fun Preview(theme: OudsThemeContract, darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean, parameter: Any?) { + PreviewOudsSwitchItemConstrainedMaxWidth(theme, parameter as Boolean) + } + + override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled + } } object Switch : OudsPreviewableComponent { @@ -600,6 +649,20 @@ interface OudsPreviewableComponent { override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled } + + object ConstrainedMaxWidth : OudsPreviewableComponent { + + const val PreviewWidthDp = 600 + + override val parameters: List = OudsTextInputConstrainedMaxWidthPreviewParameterProvider().values.toList() + + @Composable + override fun Preview(theme: OudsThemeContract, darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean, parameter: Any?) { + PreviewOudsTextInputConstrainedMaxWidth(theme = theme, constrainedMaxWidth = parameter as Boolean) + } + + override fun isPreviewAvailable(darkThemeEnabled: Boolean, highContrastModeEnabled: Boolean) = !darkThemeEnabled && !highContrastModeEnabled + } } object TopAppBar { diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..15938ff3e Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..c0218b3a5 Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..4e9955bd7 Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..5639ebb84 Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..b8c637681 Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..2d47a6cc7 Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..732dfb1eb Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..67159fe03 Binary files /dev/null and b/theme-orange/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..ef1b66e3e Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..12f9be418 Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..fb0b60d7f Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..72f3d8529 Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..904e94eea Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..8339ca122 Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..0311e0bab Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..9224d645a Binary files /dev/null and b/theme-sosh/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..580147cef Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..d87787046 Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsCheckboxItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..298500332 Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..f266f0d52 Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsRadioButtonItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..2706e99b4 Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..657e75bb6 Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsSwitchItemTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png new file mode 100644 index 000000000..2ab910857 Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[0].png differ diff --git a/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png new file mode 100644 index 000000000..53484bce2 Binary files /dev/null and b/theme-wireframe/src/test/snapshots/images/com.orange.ouds.core.test_OudsTextInputTest$ConstrainedMaxWidth_takeLightThemeSnapshot[1].png differ