@@ -42,7 +42,6 @@ import androidx.compose.ui.Modifier
4242import androidx.compose.ui.draw.clip
4343import androidx.compose.ui.graphics.Color
4444import androidx.compose.ui.graphics.ImageBitmap
45- import androidx.compose.ui.graphics.Shape
4645import androidx.compose.ui.graphics.painter.Painter
4746import androidx.compose.ui.graphics.vector.ImageVector
4847import androidx.compose.ui.layout.ContentScale
@@ -263,7 +262,7 @@ internal fun OudsListItem(
263262
264263 with (OudsTheme .components.listItem) {
265264 val borderRadius = if (card && LocalThemeSettings .current.roundedCornerCardItems == true ) border.radius.rounded else border.radius.default
266- val shape = shape(borderRadius)
265+ val shape = shape(cornerRadius = borderRadius)
267266
268267 val clickableModifier = if (onClick != null ) {
269268 Modifier .clickable(
@@ -284,7 +283,7 @@ internal fun OudsListItem(
284283 .fillMaxWidth()
285284 .heightIn(min = minHeight(size))
286285 .background(color = backgroundColor.value, shape = shape)
287- .border(state = state, decoration = decoration, shape = shape, borderRadius = borderRadius, outlineColor = outlineBorderColor.value)
286+ .border(state = state, decoration = decoration, cornerRadius = borderRadius, outlineColor = outlineBorderColor.value)
288287 .outerBorder(state = state, shape = shape)
289288 .containerPadding(size = size, verticalAlignment = verticalAlignment)
290289 .semantics(mergeDescendants = true ) { },
@@ -423,32 +422,23 @@ private fun backgroundColor(state: OudsListItemState, decoration: OudsListItemDe
423422}
424423
425424@Composable
426- private fun Modifier.border (state : OudsListItemState , decoration : OudsListItemDecoration , shape : Shape , borderRadius : Dp , outlineColor : Color ): Modifier {
427- val outlined: Boolean
428- when (decoration) {
429- is OudsListItemDecoration .Outlined -> {
430- outlined = true
431- }
432- is OudsListItemDecoration .OutlinedOnInteraction -> {
433- outlined = state in listOf (OudsListItemState .Hovered , OudsListItemState .Pressed , OudsListItemState .Focused )
434- }
435- is OudsListItemDecoration .Background ,
436- is OudsListItemDecoration .BackgroundOnInteraction ,
437- is OudsListItemDecoration .None -> {
438- outlined = false
439- }
440- }
425+ private fun Modifier.border (state : OudsListItemState , decoration : OudsListItemDecoration , cornerRadius : Dp , outlineColor : Color ): Modifier {
426+ val outlined = decoration is OudsListItemDecoration .Outlined || (decoration is OudsListItemDecoration .OutlinedOnInteraction && state in listOf (
427+ OudsListItemState .Hovered ,
428+ OudsListItemState .Pressed ,
429+ OudsListItemState .Focused
430+ ))
441431 val width = OudsTheme .borders.width.default.takeUnlessHairline
442432
443433 return when {
444- width != null && outlined -> border(width = width, color = outlineColor, shape = shape)
445- width != null && decoration.divider -> bottomBorder(width = width, color = OudsTheme .colorScheme.border.muted, cornerRadius = borderRadius )
434+ width != null && outlined -> border(width = width, color = outlineColor, shape = shape(cornerRadius = cornerRadius) )
435+ width != null && decoration.divider -> bottomBorder(width = width, color = OudsTheme .colorScheme.border.muted, cornerRadius = cornerRadius )
446436 else -> this
447437 }
448438}
449439
450440@Composable
451- private fun shape (borderRadius : Dp ) = RoundedCornerShape (borderRadius )
441+ private fun shape (cornerRadius : Dp ) = RoundedCornerShape (cornerRadius )
452442
453443@Composable
454444private fun outlineBorderColor (state : OudsListItemState ) = with (OudsTheme .colorScheme.action) {
@@ -785,18 +775,12 @@ open class OudsListItemImage internal constructor(
785775
786776 @Composable
787777 override fun Content (modifier : Modifier ) {
778+ val cornerRadius = with (OudsTheme .components.listItem.border.radius) { if (roundedCorner) mediaRounded else media }
788779 super .Content (
789780 modifier = modifier
790781 .height(size.value)
791782 .width(size.value * ratio.value)
792- .run {
793- if (roundedCorner) {
794- clip(RoundedCornerShape (OudsTheme .components.listItem.border.radius.mediaRounded))
795- } else {
796- this
797- }
798- }
799-
783+ .clip(RoundedCornerShape (cornerRadius))
800784 )
801785 }
802786}
@@ -862,7 +846,7 @@ sealed interface OudsListItemLeading : OudsListItemLeadingTrailing {
862846 constructor (
863847 painter: Painter ,
864848 contentDescription: String ,
865- size: OudsListItemIconSize = OudsListItemIconSize . Medium ,
849+ size: OudsListItemIconSize = OudsListItemDefaults . IconSize ,
866850 tinted: Boolean = true
867851 ) : this ({ painter as Any }, { contentDescription }, tinted, size, null )
868852
@@ -879,7 +863,7 @@ sealed interface OudsListItemLeading : OudsListItemLeadingTrailing {
879863 constructor (
880864 imageVector: ImageVector ,
881865 contentDescription: String ,
882- size: OudsListItemIconSize = OudsListItemIconSize . Medium ,
866+ size: OudsListItemIconSize = OudsListItemDefaults . IconSize ,
883867 tinted: Boolean = true
884868 ) : this ({ imageVector as Any }, { contentDescription }, tinted, size, null )
885869
@@ -896,7 +880,7 @@ sealed interface OudsListItemLeading : OudsListItemLeadingTrailing {
896880 constructor (
897881 bitmap: ImageBitmap ,
898882 contentDescription: String ,
899- size: OudsListItemIconSize = OudsListItemIconSize . Medium ,
883+ size: OudsListItemIconSize = OudsListItemDefaults . IconSize ,
900884 tinted: Boolean = true
901885 ) : this ({ bitmap as Any }, { contentDescription }, tinted, size, null )
902886
0 commit comments