Skip to content

Commit

Permalink
[refactor/#21] chip selector 선택 중 배경 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
imtaejugkim committed Jan 18, 2025
1 parent f1323f5 commit fca8e98
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
39 changes: 16 additions & 23 deletions app/src/main/java/org/memento/presentation/MementoChipSelector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 -> {
Expand Down Expand Up @@ -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,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
}

Expand All @@ -204,6 +203,7 @@ fun AddPlanScreen() {
timeText = if (isAllDayChecked) "All-day" else selectedEndTimeText,
onTimeClick = { showEndTimePickerBottomSheet = true },
isAllChecked = isAllDayChecked,
isChipClicked = showEndTimePickerBottomSheet
)
}

Expand Down Expand Up @@ -250,6 +250,7 @@ fun AddPlanScreen() {
timeText = null,
onTimeClick = null,
tagColor = selectedTagColor,
isChipClicked = showTagBottomSheet
)
}
}
Expand All @@ -264,7 +265,6 @@ fun AddPlanScreen() {
},
sheetState = sheetTimePickerState,
onConfirm = {
isStartTimeClicked = true
showStartTimePickerBottomSheet = false
},
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -374,16 +376,20 @@ fun AddPlanSelectComponent(
}
},
isClicked = false,
onClickedChange = { onDateClick() },
onClickedChange = {
onDateClick()
},
content = dateText,
tagColor = tagColor,
)

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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit fca8e98

Please sign in to comment.