From 0a824a210f9d39c7fe424e9c7a9b18f19abea752 Mon Sep 17 00:00:00 2001 From: buna Date: Wed, 5 Jun 2024 14:41:04 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20RoundedImage=EA=B0=80=20size?= =?UTF-8?q?=EB=A5=BC=20=EC=A0=84=EB=8B=AC=EB=B0=9B=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designsystem/component/RoundedImage.kt | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/core/designsystem/src/main/java/com/droidknights/app/core/designsystem/component/RoundedImage.kt b/core/designsystem/src/main/java/com/droidknights/app/core/designsystem/component/RoundedImage.kt index a57564f1..c3e49ec5 100644 --- a/core/designsystem/src/main/java/com/droidknights/app/core/designsystem/component/RoundedImage.kt +++ b/core/designsystem/src/main/java/com/droidknights/app/core/designsystem/component/RoundedImage.kt @@ -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 @@ -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 ) } }