Skip to content

Commit

Permalink
refactor: RoundedImage가 size를 전달받도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
tmdgh1592 committed Jun 5, 2024
1 parent b406031 commit 0a824a2
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.droidknights.app.core.designsystem.component
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
Expand All @@ -15,18 +16,44 @@ import androidx.compose.ui.unit.dp
fun RoundedImage(
imageRes: Int,
onClick: () -> Unit = {},
size: Dp? = null,
roundSize: Dp = 16.dp,
border: BorderStroke? = null,
) {
RoundedImage(
imageRes = imageRes,
onClick = onClick,
width = size,
height = size,
roundSize = roundSize,
border = border,
)
}

@Composable
fun RoundedImage(
imageRes: Int,
onClick: () -> Unit = {},
width: Dp? = null,
height: Dp? = null,
roundSize: Dp = 16.dp,
border: BorderStroke? = null,
) {
val modifier = if (width != null && height != null) {
Modifier.size(width, height)
} else {
Modifier.aspectRatio(1f)
}

Surface(
onClick = onClick,
shape = RoundedCornerShape(roundSize),
border = border,
modifier = modifier
) {
Image(
painter = painterResource(id = imageRes),
contentDescription = null,
modifier = Modifier.aspectRatio(1f),
contentDescription = null
)
}
}

0 comments on commit 0a824a2

Please sign in to comment.