From fca8e984050c24e8c91411c820a033d21fda14c9 Mon Sep 17 00:00:00 2001 From: TaejungKim Date: Sun, 19 Jan 2025 03:30:51 +0900 Subject: [PATCH] =?UTF-8?q?[refactor/#21]=20chip=20selector=20=EC=84=A0?= =?UTF-8?q?=ED=83=9D=20=EC=A4=91=20=EB=B0=B0=EA=B2=BD=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/MementoChipSelector.kt | 39 ++++++++----------- .../plusbottomsheet/AddPlanScreen.kt | 24 +++++++----- .../plusbottomsheet/AddToDoScreen.kt | 4 +- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/org/memento/presentation/MementoChipSelector.kt b/app/src/main/java/org/memento/presentation/MementoChipSelector.kt index b388b4e..a60a679 100644 --- a/app/src/main/java/org/memento/presentation/MementoChipSelector.kt +++ b/app/src/main/java/org/memento/presentation/MementoChipSelector.kt @@ -10,8 +10,6 @@ import androidx.compose.material3.Icon import androidx.compose.material3.Text 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.Alignment import androidx.compose.ui.Modifier @@ -26,43 +24,38 @@ import org.memento.domain.type.SelectorType import org.memento.presentation.util.changeHexToColor import org.memento.presentation.util.noRippleClickable import org.memento.ui.theme.darkModeColors +import org.memento.ui.theme.mementoColors @Composable fun MementoChipSelector( selectorType: SelectorType, - isClicked: Boolean = false, + isClicked: Boolean, isLimited: Boolean? = null, onClickedChange: (Boolean) -> Unit = {}, content: String, tagColor: String?, modifier: Modifier = Modifier, + isBottomSheetOpen: Boolean = false ) { - var clicked by remember { mutableStateOf(isClicked) } + val backgroundColor = when { + isLimited == true -> darkModeColors.navy + isBottomSheetOpen -> selectorType.clickedBackgroundColor + isClicked -> selectorType.clickedBackgroundColor + else -> selectorType.unClickedBackgroundColor + } Box( modifier = Modifier .then(modifier) .clip(RoundedCornerShape(selectorType.cornerRadius)) - .background( - color = - when { - isLimited == true -> darkModeColors.navy - clicked -> selectorType.clickedBackgroundColor - else -> selectorType.unClickedBackgroundColor - }, - ) - .then( + .background(color = backgroundColor) + .noRippleClickable { if (isLimited != true) { - Modifier.noRippleClickable { - clicked = !clicked - onClickedChange(clicked) - } - } else { - Modifier - }, - ), - Alignment.Center, + onClickedChange(!isClicked) + } + }, + contentAlignment = Alignment.Center, ) { when (selectorType) { SelectorType.TIMESELECTOR -> { @@ -189,7 +182,7 @@ fun MementoChipSelector( Text( text = content, style = selectorType.textStyle, - color = selectorType.textColor, + color = if (content == "Select" || content == "Select Date") mementoColors.blue else selectorType.textColor, ) } } diff --git a/app/src/main/java/org/memento/presentation/plusbottomsheet/AddPlanScreen.kt b/app/src/main/java/org/memento/presentation/plusbottomsheet/AddPlanScreen.kt index 23253d0..09e0030 100644 --- a/app/src/main/java/org/memento/presentation/plusbottomsheet/AddPlanScreen.kt +++ b/app/src/main/java/org/memento/presentation/plusbottomsheet/AddPlanScreen.kt @@ -70,8 +70,6 @@ fun AddPlanScreen() { var isStartCalendarVisible by remember { mutableStateOf(false) } var isEndCalendarVisible by remember { mutableStateOf(false) } - var isStartTimeClicked by remember { mutableStateOf(false) } - fun initialTimeValue() { val currentTime = System.currentTimeMillis() val startDate = formatDate(currentTime) @@ -189,9 +187,10 @@ fun AddPlanScreen() { dateText = selectedStartDateText, onDateClick = { isStartCalendarVisible = true }, timeText = if (isAllDayChecked) "All-day" else selectedStartTimeText, - onTimeClick = { showStartTimePickerBottomSheet = true }, + onTimeClick = { + showStartTimePickerBottomSheet = true }, isAllChecked = isAllDayChecked, - isStartTimeClicked = isStartTimeClicked, + isChipClicked = showStartTimePickerBottomSheet ) } @@ -204,6 +203,7 @@ fun AddPlanScreen() { timeText = if (isAllDayChecked) "All-day" else selectedEndTimeText, onTimeClick = { showEndTimePickerBottomSheet = true }, isAllChecked = isAllDayChecked, + isChipClicked = showEndTimePickerBottomSheet ) } @@ -250,6 +250,7 @@ fun AddPlanScreen() { timeText = null, onTimeClick = null, tagColor = selectedTagColor, + isChipClicked = showTagBottomSheet ) } } @@ -264,7 +265,6 @@ fun AddPlanScreen() { }, sheetState = sheetTimePickerState, onConfirm = { - isStartTimeClicked = true showStartTimePickerBottomSheet = false }, ) @@ -341,8 +341,10 @@ fun AddPlanSelectComponent( onTimeClick: (() -> Unit)?, tagColor: String? = null, isAllChecked: Boolean? = null, - isStartTimeClicked: Boolean = false, + isChipClicked: Boolean = false, ) { + var isClicked by remember { mutableStateOf(false) } + Row( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, @@ -374,7 +376,9 @@ fun AddPlanSelectComponent( } }, isClicked = false, - onClickedChange = { onDateClick() }, + onClickedChange = { + onDateClick() + }, content = dateText, tagColor = tagColor, ) @@ -382,8 +386,10 @@ fun AddPlanSelectComponent( timeText?.let { MementoChipSelector( selectorType = SelectorType.TIMESELECTOR, - isClicked = isStartTimeClicked, - onClickedChange = { onTimeClick?.invoke() }, + isClicked = isChipClicked, + onClickedChange = { + isClicked = it + onTimeClick?.invoke() }, content = timeText, tagColor = null, modifier = Modifier.padding(start = 10.dp), diff --git a/app/src/main/java/org/memento/presentation/plusbottomsheet/AddToDoScreen.kt b/app/src/main/java/org/memento/presentation/plusbottomsheet/AddToDoScreen.kt index 236f469..672f53c 100644 --- a/app/src/main/java/org/memento/presentation/plusbottomsheet/AddToDoScreen.kt +++ b/app/src/main/java/org/memento/presentation/plusbottomsheet/AddToDoScreen.kt @@ -183,14 +183,14 @@ fun AddToDoScreen( .align(alignment = Alignment.CenterVertically) .padding(all = 8.dp) .noRippleClickable { - onNavigateTagSetting() + onNavigateEisenHourSetting() }, ) { Box( modifier = Modifier .background( - color = changeHexToColor(hex = tagColor), + color = darkModeColors.gray08, shape = RoundedCornerShape(2.dp), ) .padding(all = 2.dp),