diff --git a/app/src/main/java/com/orange/ods/app/ui/MainTopAppBar.kt b/app/src/main/java/com/orange/ods/app/ui/MainTopAppBar.kt index 1d8f01c5f..2d1043488 100644 --- a/app/src/main/java/com/orange/ods/app/ui/MainTopAppBar.kt +++ b/app/src/main/java/com/orange/ods/app/ui/MainTopAppBar.kt @@ -108,8 +108,8 @@ fun MainTopAppBar( } @Composable -private fun getTopAppBarSearchTextFieldAction(searchedText: MutableState): OdsComponentContent { - return object : OdsComponentContent() { +private fun getTopAppBarSearchTextFieldAction(searchedText: MutableState): OdsComponentContent { + return object : OdsComponentContent() { @Composable override fun Content(modifier: Modifier) { diff --git a/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsLargeTopAppBar.kt b/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsLargeTopAppBar.kt index 4b4026db2..bde309f00 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsLargeTopAppBar.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsLargeTopAppBar.kt @@ -66,7 +66,7 @@ fun OdsLargeTopAppBarInternal( title: String, modifier: Modifier = Modifier, navigationIcon: OdsTopAppBarNavigationIcon? = null, - actions: List = emptyList(), + actions: List> = emptyList(), overflowMenuActions: List = emptyList(), scrollBehavior: TopAppBarScrollBehavior? = null ) { diff --git a/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBar.kt b/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBar.kt index a94340d28..81904ab5d 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBar.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBar.kt @@ -71,7 +71,7 @@ fun OdsTopAppBarInternal( title: String, modifier: Modifier = Modifier, navigationIcon: OdsTopAppBarNavigationIcon? = null, - actions: List = emptyList(), + actions: List> = emptyList(), overflowMenuActions: List = emptyList(), elevated: Boolean = true ) { diff --git a/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBarsCommon.kt b/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBarsCommon.kt index 4c7082626..b300057d0 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBarsCommon.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/appbar/top/OdsTopAppBarsCommon.kt @@ -31,7 +31,7 @@ import com.orange.ods.compose.component.menu.OdsDropdownMenuItem import com.orange.ods.compose.theme.OdsTheme @Composable -internal fun OdsTopAppBarActions(actions: List, overflowMenuActions: List) { +internal fun OdsTopAppBarActions(actions: List>, overflowMenuActions: List) { val maxTotalActionCount = 3 val maxActionCount = if (overflowMenuActions.isNotEmpty()) maxTotalActionCount - 1 else maxTotalActionCount actions.take(maxActionCount).forEach { it.Content() } @@ -53,7 +53,7 @@ internal fun OdsTopAppBarActions(actions: List, overflowMen /** * A navigation icon in an [OdsTopAppBar]. */ -class OdsTopAppBarNavigationIcon : OdsComponentIcon { +class OdsTopAppBarNavigationIcon : OdsComponentIcon { /** * Creates an instance of [OdsTopAppBarNavigationIcon]. @@ -86,7 +86,7 @@ class OdsTopAppBarNavigationIcon : OdsComponentIcon { /** * An action button displayed in an [OdsTopAppBar]. */ -open class OdsTopAppBarActionButton : OdsComponentIcon { +open class OdsTopAppBarActionButton : OdsComponentIcon { /** * Creates an instance of [OdsTopAppBarActionButton]. diff --git a/lib/src/main/java/com/orange/ods/compose/component/banner/OdsBanner.kt b/lib/src/main/java/com/orange/ods/compose/component/banner/OdsBanner.kt index 089d9a0ae..6886f5ea4 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/banner/OdsBanner.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/banner/OdsBanner.kt @@ -109,7 +109,7 @@ fun OdsBanner( * @param text Text of the button. * @param onClick Will be called when the user clicks the button. */ -class OdsBannerButton(private val text: String, private val onClick: () -> Unit) : OdsComponentContent() { +class OdsBannerButton(private val text: String, private val onClick: () -> Unit) : OdsComponentContent() { @Composable override fun Content(modifier: Modifier) { diff --git a/lib/src/main/java/com/orange/ods/compose/component/bottomnavigation/OdsBottomNavigation.kt b/lib/src/main/java/com/orange/ods/compose/component/bottomnavigation/OdsBottomNavigation.kt index 609f7757d..b41858b81 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/bottomnavigation/OdsBottomNavigation.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/bottomnavigation/OdsBottomNavigation.kt @@ -93,10 +93,10 @@ class OdsBottomNavigationItem( val enabled: Boolean = true, val label: String? = null, val alwaysShowLabel: Boolean = true -) : OdsComponentScopeContent() { +) : OdsComponentScopeContent() { @Composable - override fun RowScope.Content() { + override fun RowScope.Content(modifier: Modifier) { BottomNavigationItem( selected = selected, onClick = onClick, @@ -122,7 +122,7 @@ class OdsBottomNavigationItem( /** * An icon in an [OdsBottomNavigationItem]. */ -class OdsBottomNavigationItemIcon : OdsComponentIcon { +class OdsBottomNavigationItemIcon : OdsComponentIcon { /** * Creates an instance of [OdsBottomNavigationItemIcon]. diff --git a/lib/src/main/java/com/orange/ods/compose/component/button/OdsButtonsCommon.kt b/lib/src/main/java/com/orange/ods/compose/component/button/OdsButtonsCommon.kt index 9df5d8055..e5fe53d70 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/button/OdsButtonsCommon.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/button/OdsButtonsCommon.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.ImageBitmap import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.vector.ImageVector +import com.orange.ods.compose.component.content.OdsComponentContent import com.orange.ods.compose.component.content.OdsComponentIcon import com.orange.ods.compose.theme.OdsDisplaySurface @@ -27,7 +28,7 @@ import com.orange.ods.compose.theme.OdsDisplaySurface * A button icon in an [OdsButton]. * It is non-clickable and no content description is needed cause a button label is always present. */ -class OdsButtonIcon : OdsComponentIcon { +class OdsButtonIcon : OdsComponentIcon { /** * Creates an instance of [OdsButtonIcon]. @@ -60,7 +61,12 @@ class OdsButtonIcon : OdsComponentIcon { /** * An icon in an [OdsIconButton]. */ -class OdsIconButtonIcon : OdsComponentIcon { +class OdsIconButtonIcon : OdsComponentIcon { + + data class ExtraParameters( + val enabled: Boolean, + val displaySurface: OdsDisplaySurface + ) : OdsComponentContent.ExtraParameters() /** * Creates an instance of [OdsIconButtonIcon]. @@ -91,10 +97,10 @@ class OdsIconButtonIcon : OdsComponentIcon { get() = iconButtonTintColor(displaySurface = displaySurface) @Composable - internal fun Content(enabled: Boolean, displaySurface: OdsDisplaySurface = OdsDisplaySurface.Default) { - this.enabled = enabled - this.displaySurface = displaySurface - Content() + override fun Content(modifier: Modifier) { + enabled = extraParameters.enabled + displaySurface = extraParameters.displaySurface + super.Content(modifier) } } diff --git a/lib/src/main/java/com/orange/ods/compose/component/button/OdsFloatingActionButton.kt b/lib/src/main/java/com/orange/ods/compose/component/button/OdsFloatingActionButton.kt index 7a229b932..c13d14431 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/button/OdsFloatingActionButton.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/button/OdsFloatingActionButton.kt @@ -107,7 +107,7 @@ fun OdsExtendedFloatingActionButton( /** * A button icon in an [OdsFloatingActionButton]. */ -class OdsFloatingActionButtonIcon : OdsComponentIcon { +class OdsFloatingActionButtonIcon : OdsComponentIcon { /** * Creates an instance of [OdsFloatingActionButtonIcon]. diff --git a/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconButton.kt b/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconButton.kt index 2255e8912..e9797b168 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconButton.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconButton.kt @@ -53,7 +53,7 @@ fun OdsIconButton( LocalRippleTheme provides displaySurface.rippleTheme ) { IconButton(onClick = onClick, modifier = modifier, enabled = enabled) { - icon.Content(enabled = enabled, displaySurface = displaySurface) + icon.Content(OdsIconButtonIcon.ExtraParameters(enabled, displaySurface)) } } } diff --git a/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButton.kt b/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButton.kt index 33d2074a3..49d7bc66f 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButton.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButton.kt @@ -63,7 +63,7 @@ fun OdsIconToggleButton( enabled = enabled ) { val icon = if (checked) checkedIcon else uncheckedIcon - icon.Content(enabled = enabled, displaySurface = displaySurface) + icon.Content(OdsIconButtonIcon.ExtraParameters(enabled, displaySurface)) } } } diff --git a/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButtonsRow.kt b/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButtonsRow.kt index fe6c6acd8..d4a3c2806 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButtonsRow.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/button/OdsIconToggleButtonsRow.kt @@ -36,6 +36,7 @@ import androidx.compose.ui.semantics.semantics import androidx.compose.ui.semantics.stateDescription import androidx.compose.ui.unit.dp import com.orange.ods.compose.component.OdsComposable +import com.orange.ods.compose.component.content.OdsComponentContent import com.orange.ods.compose.component.content.OdsComponentIcon import com.orange.ods.compose.component.utilities.DisabledInteractionSource import com.orange.ods.compose.component.utilities.Preview @@ -76,9 +77,11 @@ fun OdsIconToggleButtonsRow( ) ) { icons.forEachIndexed { index, icon -> - icon.Content(index = index, displaySurface = displaySurface, selected = selectedIndex == index, onClick = { clickedButtonIndex -> - onSelectedIndexChange(clickedButtonIndex) - }) + icon.Content( + OdsIconToggleButtonsRowIcon.ExtraParameters(index, displaySurface, selectedIndex == index) { clickedButtonIndex -> + onSelectedIndexChange(clickedButtonIndex) + } + ) if (index < icons.size) { Divider( modifier = Modifier @@ -94,7 +97,14 @@ fun OdsIconToggleButtonsRow( /** * An icon of an [OdsIconToggleButtonsRow]. */ -class OdsIconToggleButtonsRowIcon : OdsComponentIcon { +class OdsIconToggleButtonsRowIcon : OdsComponentIcon { + + data class ExtraParameters( + val index: Int, + val displaySurface: OdsDisplaySurface, + val selected: Boolean, + val onClick: (Int) -> Unit + ) : OdsComponentContent.ExtraParameters() /** * Creates an instance of [OdsIconToggleButtonsRowIcon]. @@ -126,45 +136,34 @@ class OdsIconToggleButtonsRowIcon : OdsComponentIcon { */ constructor(bitmap: ImageBitmap, contentDescription: String, enabled: Boolean = true) : super(bitmap, contentDescription, enabled) - private var index: Int = 0 - private var onClick: (Int) -> Unit = {} - private var selected: Boolean = false - override val tint: Color @Composable get() { - return getIconColor(displaySurface, selected, enabled) + return with(extraParameters) { getIconColor(displaySurface, selected, enabled) } } - @Composable - internal fun Content(index: Int, onClick: (Int) -> Unit, displaySurface: OdsDisplaySurface = OdsDisplaySurface.Default, selected: Boolean = false) { - this.index = index - this.onClick = onClick - this.displaySurface = displaySurface - this.selected = selected - Content() - } - @Composable override fun Content(modifier: Modifier) { - val backgroundAlpha = if (selected && enabled) 0.12f else 0f - val toggleIconStateDescription = selectionStateDescription(selected = selected) + with(extraParameters) { + val backgroundAlpha = if (selected && enabled) 0.12f else 0f + val toggleIconStateDescription = selectionStateDescription(selected = selected) - super.Content( - modifier - .background(color = buttonToggleBackgroundColor(displaySurface).copy(alpha = backgroundAlpha)) - .padding(12.dp) - .run { - if (enabled) { - clickable(interactionSource = remember { DisabledInteractionSource() }, indication = null) { onClick(index) } - } else { - this + super.Content( + modifier + .background(color = buttonToggleBackgroundColor(displaySurface).copy(alpha = backgroundAlpha)) + .padding(12.dp) + .run { + if (enabled) { + clickable(interactionSource = remember { DisabledInteractionSource() }, indication = null) { onClick(index) } + } else { + this + } } - } - .semantics { - stateDescription = toggleIconStateDescription - } - ) + .semantics { + stateDescription = toggleIconStateDescription + } + ) + } } @Composable diff --git a/lib/src/main/java/com/orange/ods/compose/component/card/OdsCardsCommon.kt b/lib/src/main/java/com/orange/ods/compose/component/card/OdsCardsCommon.kt index 8077bc203..9bc927acf 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/card/OdsCardsCommon.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/card/OdsCardsCommon.kt @@ -45,7 +45,7 @@ internal fun OdsCard(modifier: Modifier, onClick: (() -> Unit)?, content: @Compo * @param text Text of the button. * @param onClick Will be called when the user clicks the button. */ -class OdsCardButton(private val text: String, private val onClick: () -> Unit) : OdsComponentContent() { +class OdsCardButton(private val text: String, private val onClick: () -> Unit) : OdsComponentContent() { @Composable override fun Content(modifier: Modifier) { @@ -62,7 +62,7 @@ class OdsCardImage private constructor( alignment: Alignment = Alignment.Center, contentScale: ContentScale = ContentScale.Crop, private val backgroundColor: Color? = null -) : OdsComponentImage(graphicsObject, contentDescription, alignment, contentScale) { +) : OdsComponentImage(graphicsObject, contentDescription, alignment, contentScale) { /** * Creates an instance of [OdsCardImage]. diff --git a/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChipCommon.kt b/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChipCommon.kt index 2403e8d23..14c87a934 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChipCommon.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/chip/OdsChipCommon.kt @@ -31,7 +31,7 @@ import com.orange.ods.compose.component.content.OdsComponentImage /** * A leading icon in an [OdsChip]. */ -class OdsChipLeadingIcon : OdsComponentIcon { +class OdsChipLeadingIcon : OdsComponentIcon { /** * Creates an instance of [OdsChipLeadingIcon]. @@ -66,7 +66,7 @@ class OdsChipLeadingIcon : OdsComponentIcon { /** * A leading avatar in an [OdsChip]. */ -class OdsChipLeadingAvatar : OdsComponentImage { +class OdsChipLeadingAvatar : OdsComponentImage { /** * Creates an instance of [OdsChipLeadingAvatar]. diff --git a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentCircleImage.kt b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentCircleImage.kt index f458096bc..8d138873e 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentCircleImage.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentCircleImage.kt @@ -24,7 +24,7 @@ import androidx.compose.ui.unit.dp abstract class OdsComponentCircleImage private constructor( graphicsObject: Any, contentDescription: String -) : OdsComponentImage(graphicsObject, contentDescription, contentScale = ContentScale.Crop) { +) : OdsComponentImage(graphicsObject, contentDescription, contentScale = ContentScale.Crop) { /** * Creates an instance of [OdsComponentCircleImage]. diff --git a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentContent.kt b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentContent.kt index 1c04ed80f..929003153 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentContent.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentContent.kt @@ -20,8 +20,20 @@ import androidx.compose.ui.Modifier * This prevents using generic composable methods that can encapsulate any kind of views and thus helps developers to follow UI guidelines more easily. * This also allows to group parameters that are related to the same content inside a component. * For instance it is possible to create an `Icon` subclass to replace both `icon: @Composable () -> Unit` and `onIconClick: () -> Unit` parameters with a single `icon: Icon` parameter. + * + * @param T the type of extra parameters. */ -abstract class OdsComponentContent { +abstract class OdsComponentContent where T : OdsComponentContent.ExtraParameters { + + /** + * Extra parameters that can be passed to the `Content` method when other parameters than those provided by the user are needed to layout the component. + */ + abstract class ExtraParameters + + /** + * The extra parameters. + */ + protected lateinit var extraParameters: T /** * The Jetpack Compose UI for this component content. @@ -29,7 +41,29 @@ abstract class OdsComponentContent { * Calls `Content(Modifier)` with the default `Modifier`. */ @Composable - fun Content() = Content(modifier = Modifier) + internal fun Content() = Content(modifier = Modifier) + + /** + * The Jetpack Compose UI for this component content. + * + * Calls `Content(Modifier, T)` with the default `Modifier`. + * + * @param extraParameters the extra parameters for this content. + */ + @Composable + internal fun Content(extraParameters: T) = Content(modifier = Modifier, extraParameters = extraParameters) + + /** + * The Jetpack Compose UI for this component content. + * + * @param modifier the Modifier for this content. + * @param extraParameters the extra parameters for this content. + */ + @Composable + internal fun Content(modifier: Modifier, extraParameters: T) { + this.extraParameters = extraParameters + Content(modifier = modifier) + } /** * The Jetpack Compose UI for this component content. diff --git a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentIcon.kt b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentIcon.kt index dcf846134..74103eb5e 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentIcon.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentIcon.kt @@ -25,13 +25,13 @@ import com.orange.ods.extension.orElse /** * An icon in a component. */ -abstract class OdsComponentIcon internal constructor( +abstract class OdsComponentIcon internal constructor( private val graphicsObject: Any, private val contentDescription: String, protected var enabled: Boolean = true, private val onClick: (() -> Unit)? = null, protected var displaySurface: OdsDisplaySurface = OdsDisplaySurface.Default -) : OdsComponentContent() { +) : OdsComponentContent() where T : OdsComponentContent.ExtraParameters { protected open val tint: Color? @Composable diff --git a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentImage.kt b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentImage.kt index db5cba588..c724202c0 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentImage.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentImage.kt @@ -22,12 +22,12 @@ import androidx.compose.ui.layout.ContentScale /** * An image in a component. */ -abstract class OdsComponentImage internal constructor( +abstract class OdsComponentImage internal constructor( private val graphicsObject: Any, private val contentDescription: String, private val alignment: Alignment = Alignment.Center, private val contentScale: ContentScale = ContentScale.Fit -) : OdsComponentContent() { +) : OdsComponentContent() where T: OdsComponentContent.ExtraParameters { protected constructor( painter: Painter, diff --git a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentScopeContent.kt b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentScopeContent.kt index 1cbe429b8..10e372045 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentScopeContent.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/content/OdsComponentScopeContent.kt @@ -11,6 +11,7 @@ package com.orange.ods.compose.component.content import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier /** * The content in the scope of a component. @@ -19,12 +20,49 @@ import androidx.compose.runtime.Composable * * @param T The type of the scope. */ -abstract class OdsComponentScopeContent { +abstract class OdsComponentScopeContent where S : OdsComponentContent.ExtraParameters { + + /** + * The extra parameters. + */ + protected lateinit var extraParameters: S + + /** + * The Jetpack Compose UI for this component content. + * + * Calls `Content(Modifier)` with the default `Modifier`. + */ + @Composable + internal fun T.Content() = Content(modifier = Modifier) + + /** + * The Jetpack Compose UI for this component content. + * + * Calls `Content(Modifier, T)` with the default `Modifier`. + * + * @param extraParameters the extra parameters for this content. + */ + @Composable + internal fun T.Content(extraParameters: S) = Content(modifier = Modifier, extraParameters = extraParameters) + + /** + * The Jetpack Compose UI for this component content. + * + * @param modifier the Modifier for this content. + * @param extraParameters the extra parameters for this content. + */ + @Composable + internal fun T.Content(modifier: Modifier, extraParameters: S) { + this@OdsComponentScopeContent.extraParameters = extraParameters + Content(modifier = modifier) + } /** * The Jetpack Compose UI for this component content. * Subclasses must implement this method to provide content. + * + * @param modifier the Modifier for this content. */ @Composable - internal abstract fun T.Content() + internal abstract fun T.Content(modifier: Modifier) } diff --git a/lib/src/main/java/com/orange/ods/compose/component/dialog/OdsAlertDialog.kt b/lib/src/main/java/com/orange/ods/compose/component/dialog/OdsAlertDialog.kt index 6e142a24e..f3dbc920b 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/dialog/OdsAlertDialog.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/dialog/OdsAlertDialog.kt @@ -76,7 +76,7 @@ fun OdsAlertDialog( * @param text Text of the button. * @param onClick Will be called when the user clicks the button. */ -class OdsAlertDialogButton(private val text: String, private val onClick: () -> Unit) : OdsComponentContent() { +class OdsAlertDialogButton(private val text: String, private val onClick: () -> Unit) : OdsComponentContent() { @Composable override fun Content(modifier: Modifier) { diff --git a/lib/src/main/java/com/orange/ods/compose/component/imagetile/OdsImageTile.kt b/lib/src/main/java/com/orange/ods/compose/component/imagetile/OdsImageTile.kt index 16d9b37b4..059196f02 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/imagetile/OdsImageTile.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/imagetile/OdsImageTile.kt @@ -130,7 +130,7 @@ fun OdsImageTile( /** * An image in an [OdsImageTile]. */ -class OdsImageTileImage : OdsComponentImage { +class OdsImageTileImage : OdsComponentImage { /** * Creates an instance of [OdsImageTileImage]. diff --git a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt index bc8017671..e5c033c56 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/menu/OdsDropdownMenu.kt @@ -64,7 +64,7 @@ fun OdsDropdownMenu( modifier = modifier.background(OdsTheme.colors.surface), offset = offset, properties = properties, - content = { items.forEach { it.Content(onDismissRequest) } } + content = { items.forEach { it.Content(OdsDropdownMenuItem.ExtraParameters(onDismissRequest)) } } ) } @@ -85,7 +85,9 @@ class OdsDropdownMenuItem private constructor( val enabled: Boolean, val divider: Boolean, val onClick: () -> Unit -) : OdsComponentContent() { +) : OdsComponentContent() { + + data class ExtraParameters(val onDismissRequest: () -> Unit) : OdsComponentContent.ExtraParameters() /** * Creates an instance of [OdsDropdownMenuItem]. @@ -153,20 +155,12 @@ class OdsDropdownMenuItem private constructor( onClick: () -> Unit ) : this(text, icon as Any?, enabled, divider, onClick) - private var onDismissRequest: () -> Unit = {} - - @Composable - internal fun Content(onDismissRequest: () -> Unit) { - this.onDismissRequest = onDismissRequest - Content() - } - @Composable override fun Content(modifier: Modifier) { DropdownMenuItem( onClick = { onClick() - onDismissRequest() + extraParameters.onDismissRequest() }, enabled = enabled ) { diff --git a/lib/src/main/java/com/orange/ods/compose/component/progressindicator/OdsLinearProgressIndicator.kt b/lib/src/main/java/com/orange/ods/compose/component/progressindicator/OdsLinearProgressIndicator.kt index eafd48430..d7e058320 100644 --- a/lib/src/main/java/com/orange/ods/compose/component/progressindicator/OdsLinearProgressIndicator.kt +++ b/lib/src/main/java/com/orange/ods/compose/component/progressindicator/OdsLinearProgressIndicator.kt @@ -117,7 +117,7 @@ fun OdsLinearProgressIndicator( * An icon in an [OdsLinearProgressIndicator]. * It is a non-clickable button. */ -class OdsLinearProgressIndicatorIcon : OdsComponentIcon { +class OdsLinearProgressIndicatorIcon : OdsComponentIcon { /** * Creates an instance of [OdsLinearProgressIndicatorIcon].