From 43482a49236e559b71c7066e59c348adf379ee86 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 10 Jul 2024 17:36:25 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[ADD/#38]=20ScrapBox=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designsystem/component/box/ScrapBox.kt | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt diff --git a/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt b/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt new file mode 100644 index 000000000..20e63380e --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt @@ -0,0 +1,95 @@ +package com.terning.core.designsystem.component.box + +import androidx.compose.foundation.background +import androidx.compose.foundation.border +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp +import com.terning.core.designsystem.theme.CalPink +import com.terning.core.designsystem.theme.CalPurple +import com.terning.core.designsystem.theme.Grey150 +import com.terning.core.designsystem.theme.White + +@Composable +fun ScrapBox( + cornerRadius: Dp, + scrapColor: Color, + modifier: Modifier = Modifier, + elevation: Dp = 0.dp, + borderWidth: Dp = 0.dp, + borderColor: Color = Grey150, + content: @Composable () -> Unit, +) { + Box( + modifier = modifier + .border( + width = borderWidth, + color = borderColor, + RoundedCornerShape(cornerRadius), + ) + .shadow( + elevation = elevation, + RoundedCornerShape(cornerRadius), + ) + ) { + Box( + modifier = Modifier + .background( + color = scrapColor, + shape = RoundedCornerShape(cornerRadius) + ) + .fillMaxSize() + ) + Box( + modifier = Modifier + .fillMaxSize() + .padding(start = 9.dp) + .background( + shape = RoundedCornerShape( + topEnd = cornerRadius, bottomEnd = cornerRadius + ), color = White + ) + ) { + content() + } + } +} + +@Preview(showBackground = true, showSystemUi = true) +@Composable +fun ScrapBoxPreview() { + Column { + ScrapBox( + modifier = Modifier + .height(116.dp) + .width(140.dp), + scrapColor = CalPink, + cornerRadius = 5.dp, + borderWidth = 1.dp + ) {} + + Spacer(modifier = Modifier.height(10.dp)) + + ScrapBox( + modifier = Modifier + .height(height = 92.dp) + .fillMaxWidth(), + scrapColor = CalPurple, + cornerRadius = 10.dp, + elevation = 1.dp + ) {} + } +} \ No newline at end of file From d10d5477dcbf54a0556b0cd62f3af27efe46e03a Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 10 Jul 2024 17:37:02 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[ADD/#38]=20=EC=A3=BC=EC=84=9D=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terning/core/designsystem/component/box/ScrapBox.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt b/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt index 20e63380e..f47153360 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt @@ -23,6 +23,14 @@ import com.terning.core.designsystem.theme.CalPurple import com.terning.core.designsystem.theme.Grey150 import com.terning.core.designsystem.theme.White +/** + * ScrapBox is made for easy customization of scrap box used in Calendar & Home Screen + * + * [modifier] must be assigned for assigning size of the box and padding + * [elevation] must be set greater than zero for shadow effect, mainly used in Calendar + * [borderWidth] must be set greater than zero for border effect, mainly used in Home + */ + @Composable fun ScrapBox( cornerRadius: Dp, From 3b9c59f49bb15fbedd74c696ac69f70e6e25367e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Wed, 10 Jul 2024 18:01:26 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[CHORE/#38]=20=ED=94=84=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designsystem/component/box/ScrapBox.kt | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt b/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt index f47153360..03c6eb7f7 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/box/ScrapBox.kt @@ -76,28 +76,28 @@ fun ScrapBox( } } -@Preview(showBackground = true, showSystemUi = true) +@Preview(showBackground = true) @Composable -fun ScrapBoxPreview() { - Column { - ScrapBox( - modifier = Modifier - .height(116.dp) - .width(140.dp), - scrapColor = CalPink, - cornerRadius = 5.dp, - borderWidth = 1.dp - ) {} - - Spacer(modifier = Modifier.height(10.dp)) +fun BorderedScrapBoxPreview() { + ScrapBox( + modifier = Modifier + .height(116.dp) + .width(140.dp), + scrapColor = CalPink, + cornerRadius = 5.dp, + borderWidth = 1.dp + ) {} +} - ScrapBox( - modifier = Modifier - .height(height = 92.dp) - .fillMaxWidth(), - scrapColor = CalPurple, - cornerRadius = 10.dp, - elevation = 1.dp - ) {} - } +@Preview(showBackground = true) +@Composable +fun ShadowedScrapBoxPreview() { + ScrapBox( + modifier = Modifier + .height(height = 92.dp) + .fillMaxWidth(), + scrapColor = CalPurple, + cornerRadius = 10.dp, + elevation = 1.dp + ) {} } \ No newline at end of file