From fab26cf66bb53633903d9445db092bdc125b2261 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 12 Jul 2024 16:10:28 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[UI/#57]=20=EB=9D=BC=EB=94=94=EC=98=A4?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EA=B7=B8=EB=A3=B9=20=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/item/RadioButtonGroups.kt | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt b/core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt new file mode 100644 index 000000000..b52993138 --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt @@ -0,0 +1,46 @@ +package com.terning.core.designsystem.component.item + +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.lazy.grid.GridCells +import androidx.compose.foundation.lazy.grid.LazyVerticalGrid +import androidx.compose.foundation.lazy.grid.items +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.Dp + +@Composable +fun RadioButtonGroups( + options: List, + buttonComposable: @Composable (T, Boolean, (T) -> Unit) -> Unit, + gridCellCount: Int, + verticalArrangementSpace: Dp, + horizontalArrangementSpace: Dp, + modifier: Modifier = Modifier, + onOptionSelected: (T) -> Unit = {}, + +) { + var selectedOption by remember { mutableStateOf(options[0]) } + + LazyVerticalGrid( + columns = GridCells.Fixed(gridCellCount), + verticalArrangement = Arrangement.spacedBy(verticalArrangementSpace), + horizontalArrangement = Arrangement.spacedBy(horizontalArrangementSpace), + modifier = modifier + //.padding(horizontal = 42.dp) + ) { + items(options) { option -> + buttonComposable( + option, + (selectedOption == option), + ) { + selectedOption = option + onOptionSelected(option) + } + } + } +} + From 2778b7662210d6b725af0fd7f961ff190510120e Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 12 Jul 2024 16:10:38 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[UI/#57]=20=EC=BB=AC=EB=9F=AC=20=ED=8C=94?= =?UTF-8?q?=EB=A0=88=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/item/ColorPalette.kt | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt new file mode 100644 index 000000000..2fb3f6805 --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt @@ -0,0 +1,99 @@ +package com.terning.core.designsystem.component.item + +import android.util.Log +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Check +import androidx.compose.material3.Icon +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.terning.core.designsystem.theme.CalBlue1 +import com.terning.core.designsystem.theme.CalBlue2 +import com.terning.core.designsystem.theme.CalGreen1 +import com.terning.core.designsystem.theme.CalGreen2 +import com.terning.core.designsystem.theme.CalOrange1 +import com.terning.core.designsystem.theme.CalOrange2 +import com.terning.core.designsystem.theme.CalPink +import com.terning.core.designsystem.theme.CalPurple +import com.terning.core.designsystem.theme.CalRed +import com.terning.core.designsystem.theme.CalYellow +import com.terning.core.extension.noRippleClickable + +@Composable +fun ColorPalette( + modifier: Modifier = Modifier, + onColorSelected:() -> Unit = {} +) { + val colorList = listOf( + CalRed, + CalOrange2, + CalGreen1, + CalBlue1, + CalPurple, + CalOrange1, + CalYellow, + CalGreen2, + CalBlue2, + CalPink + ) + + val colorButton: @Composable (Color, Boolean, (Color) -> Unit) -> Unit = { + color: Color, isSelected: Boolean, onOptionSelected:(Color)-> Unit -> + ColorButton(color = color, isSelected = isSelected, onColorSelected = onOptionSelected) + } + + RadioButtonGroups( + modifier = modifier.size(251.dp, 84.dp), + options = colorList, + gridCellCount = 5, + onOptionSelected = { color -> + Log.d("CalendarScreen","color: ${colorList.indexOf(color)}") + }, + buttonComposable = colorButton, + verticalArrangementSpace = 6.dp, + horizontalArrangementSpace = 14.dp, + ) +} + +@Composable +internal fun ColorButton( + modifier: Modifier = Modifier, + color: Color, + isSelected: Boolean, + onColorSelected: (Color) -> Unit +) { + Box(modifier = modifier.size(39.dp)) { + Box( + modifier = Modifier + .size(39.dp) + .background(shape = CircleShape, color = color) + .noRippleClickable { + onColorSelected(color) + }, + contentAlignment = Alignment.Center + ) { + if (isSelected) { + Icon( + imageVector = Icons.Outlined.Check, + tint = Color.White, + contentDescription = "" + ) + } + } + } +} + + +@Preview(showBackground = true) +@Composable +fun ColorPalettePreview() { + ColorPalette() +} + From 363c9ede63275b3104a0971bf5a66f12d8160cf3 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 12 Jul 2024 16:15:22 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[MOD/#57]=20=EC=BB=AC=EB=9F=AC=20=ED=8C=94?= =?UTF-8?q?=EB=A0=88=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designsystem/component/item/ColorPalette.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt index 2fb3f6805..420ff2656 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt @@ -44,11 +44,6 @@ fun ColorPalette( CalPink ) - val colorButton: @Composable (Color, Boolean, (Color) -> Unit) -> Unit = { - color: Color, isSelected: Boolean, onOptionSelected:(Color)-> Unit -> - ColorButton(color = color, isSelected = isSelected, onColorSelected = onOptionSelected) - } - RadioButtonGroups( modifier = modifier.size(251.dp, 84.dp), options = colorList, @@ -56,7 +51,13 @@ fun ColorPalette( onOptionSelected = { color -> Log.d("CalendarScreen","color: ${colorList.indexOf(color)}") }, - buttonComposable = colorButton, + buttonComposable = { + color, isSelected, onOptionSelected -> + ColorButton( + color = color, + isSelected = isSelected, + onColorSelected = onOptionSelected) + }, verticalArrangementSpace = 6.dp, horizontalArrangementSpace = 14.dp, ) From 4d08fca9f174649023f0125c19c1cf3d6589ba41 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 12 Jul 2024 16:31:30 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[REFACTOR/#57]=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=B0=98=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/designsystem/component/item/ColorPalette.kt | 12 +++++++----- .../designsystem/component/item/RadioButtonGroups.kt | 1 - core/src/main/res/drawable/ic_color_check.xml | 9 +++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 core/src/main/res/drawable/ic_color_check.xml diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt index 420ff2656..14bbd3fae 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt @@ -1,6 +1,7 @@ package com.terning.core.designsystem.component.item import android.util.Log +import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size @@ -12,8 +13,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.res.painterResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import com.terning.core.R import com.terning.core.designsystem.theme.CalBlue1 import com.terning.core.designsystem.theme.CalBlue2 import com.terning.core.designsystem.theme.CalGreen1 @@ -29,7 +32,7 @@ import com.terning.core.extension.noRippleClickable @Composable fun ColorPalette( modifier: Modifier = Modifier, - onColorSelected:() -> Unit = {} + onColorSelected:(Color) -> Unit = {} ) { val colorList = listOf( CalRed, @@ -49,7 +52,7 @@ fun ColorPalette( options = colorList, gridCellCount = 5, onOptionSelected = { color -> - Log.d("CalendarScreen","color: ${colorList.indexOf(color)}") + onColorSelected(color) }, buttonComposable = { color, isSelected, onOptionSelected -> @@ -81,9 +84,8 @@ internal fun ColorButton( contentAlignment = Alignment.Center ) { if (isSelected) { - Icon( - imageVector = Icons.Outlined.Check, - tint = Color.White, + Image( + painter = painterResource(id = R.drawable.ic_color_check), contentDescription = "" ) } diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt b/core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt index b52993138..3ed2d3919 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/item/RadioButtonGroups.kt @@ -30,7 +30,6 @@ fun RadioButtonGroups( verticalArrangement = Arrangement.spacedBy(verticalArrangementSpace), horizontalArrangement = Arrangement.spacedBy(horizontalArrangementSpace), modifier = modifier - //.padding(horizontal = 42.dp) ) { items(options) { option -> buttonComposable( diff --git a/core/src/main/res/drawable/ic_color_check.xml b/core/src/main/res/drawable/ic_color_check.xml new file mode 100644 index 000000000..7f91e1bdc --- /dev/null +++ b/core/src/main/res/drawable/ic_color_check.xml @@ -0,0 +1,9 @@ + + + From d13c0197b05d1ecd88c829f3eec937f7f8e5b6e9 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 12 Jul 2024 16:33:59 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[CHORE/#57]=20=EC=83=89=EC=83=81=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/terning/core/designsystem/theme/Color.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/theme/Color.kt b/core/src/main/java/com/terning/core/designsystem/theme/Color.kt index e9ed4d1be..32839d476 100644 --- a/core/src/main/java/com/terning/core/designsystem/theme/Color.kt +++ b/core/src/main/java/com/terning/core/designsystem/theme/Color.kt @@ -31,12 +31,12 @@ val ToastGrey = Color(0XFF666666) // Calendar Color val CalRed = Color(0xFFED4E54) val CalOrange1 = Color(0xFFEE7647) -val CalOrange2 = Color(0xFF5397F3) +val CalOrange2 = Color(0xFFF3A649) val CalYellow = Color(0xFFF5E660) val CalGreen1 = Color(0xFFC4E953) val CalGreen2 = Color(0xFF84D558) val CalBlue1 = Color(0xFF45D0CC) -val CalBlue2 = Color(0xFF4119F2) +val CalBlue2 = Color(0xFF4AA9F2) val CalPurple = Color(0xFF9B64E2) val CalPink = Color(0xFFF260AC) From 4103230732e635bbd32658272bbc98b851407ca1 Mon Sep 17 00:00:00 2001 From: boiledegg Date: Fri, 12 Jul 2024 16:37:15 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[REFACTOR/#57]=20=EC=9E=84=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terning/core/designsystem/component/item/ColorPalette.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt index 14bbd3fae..d263ad91d 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/item/ColorPalette.kt @@ -1,14 +1,10 @@ package com.terning.core.designsystem.component.item -import android.util.Log import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.outlined.Check -import androidx.compose.material3.Icon import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier