Skip to content

Commit

Permalink
[feat/#21] all-day 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
imtaejugkim committed Jan 17, 2025
1 parent d35d4b4 commit e41ba42
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 56 deletions.
89 changes: 51 additions & 38 deletions app/src/main/java/org/memento/presentation/MementoChipSelector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ import org.memento.R
import org.memento.domain.type.SelectorType
import org.memento.presentation.util.changeHexToColor
import org.memento.presentation.util.noRippleClickable
import org.memento.ui.theme.darkModeColors

@Composable
fun MementoChipSelector(
selectorType: SelectorType,
isClicked: Boolean = false,
isLimited: Boolean? = null,
onClickedChange: (Boolean) -> Unit = {},
content: String,
tagColor: String?,
Expand All @@ -38,15 +40,26 @@ fun MementoChipSelector(
var clicked by remember { mutableStateOf(isClicked) }

Box(
modifier =
Modifier
.then(modifier)
.clip(RoundedCornerShape(selectorType.cornerRadius))
.background(color = if (clicked) selectorType.clickedBackgroundColor else selectorType.unClickedBackgroundColor)
.noRippleClickable {
clicked = !clicked
onClickedChange(clicked)
},
modifier = Modifier
.then(modifier)
.clip(RoundedCornerShape(selectorType.cornerRadius))
.background(
color = when {
isLimited == true -> darkModeColors.navy
clicked -> selectorType.clickedBackgroundColor
else -> selectorType.unClickedBackgroundColor
}
)
.then(
if (isLimited != true) {
Modifier.noRippleClickable {
clicked = !clicked
onClickedChange(clicked)
}
} else {
Modifier
}
),
Alignment.Center,
) {
when (selectorType) {
Expand All @@ -56,15 +69,15 @@ fun MementoChipSelector(
style = selectorType.textStyle,
color = Color.Transparent,
modifier =
Modifier.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
Modifier.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
)
Text(
text = content,
style = selectorType.textStyle,
color = selectorType.textColor,
color = if(isLimited == true) darkModeColors.gray07 else selectorType.textColor,
)
}

Expand All @@ -74,11 +87,11 @@ fun MementoChipSelector(
style = selectorType.textStyle,
color = Color.Transparent,
modifier =
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
)
Text(
text = content,
Expand All @@ -90,16 +103,16 @@ fun MementoChipSelector(
SelectorType.TAG -> {
Box(
modifier =
Modifier
.align(Alignment.Center),
Modifier
.align(Alignment.Center),
) {
Row(
modifier =
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
) {
Icon(
imageVector = ImageVector.vectorResource(id = R.drawable.ic_tag),
Expand All @@ -115,8 +128,8 @@ fun MementoChipSelector(
}
Row(
modifier =
Modifier
.align(Alignment.Center),
Modifier
.align(Alignment.Center),
verticalAlignment = Alignment.CenterVertically,
) {
tagColor?.let { changeHexToColor(hex = it) }?.let {
Expand All @@ -139,11 +152,11 @@ fun MementoChipSelector(
SelectorType.DEADLINE -> {
Row(
modifier =
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
verticalAlignment = Alignment.CenterVertically,
) {
Image(
Expand All @@ -165,11 +178,11 @@ fun MementoChipSelector(
style = selectorType.textStyle,
color = Color.Transparent,
modifier =
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
Modifier
.padding(
horizontal = selectorType.paddingHorizontal,
vertical = selectorType.paddingVertical,
),
)
Text(
text = content,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -37,6 +38,8 @@ import org.memento.ui.TagSelectorContent
import org.memento.ui.theme.MementoTheme
import org.memento.ui.theme.darkModeColors
import org.memento.ui.theme.defaultMementoTypography
import org.memento.ui.theme.mementoColors
import java.util.Locale

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -66,6 +69,28 @@ fun AddPlanScreen() {
var isEndCalendarVisible by remember { mutableStateOf(false) }
var isEndRepeatCalendarVisible by remember { mutableStateOf(false) }

LaunchedEffect(Unit) {
val currentTime = System.currentTimeMillis()
val startDate = formatDate(System.currentTimeMillis())

val calendar = java.util.Calendar.getInstance().apply { timeInMillis = currentTime }

val hour = calendar.get(java.util.Calendar.HOUR_OF_DAY)
val minute = calendar.get(java.util.Calendar.MINUTE)

val roundedMinute = if (minute in 16..44) 30 else 0
val startTime = String.format(Locale.ENGLISH, "%02d:%02d %s", if (hour % 12 == 0) 12 else hour % 12, roundedMinute, if (hour < 12) "AM" else "PM")

calendar.add(java.util.Calendar.HOUR_OF_DAY, 2)
val endHour = calendar.get(java.util.Calendar.HOUR_OF_DAY)
val endTime = String.format(Locale.ENGLISH, "%02d:%02d %s", if (endHour % 12 == 0) 12 else endHour % 12, roundedMinute, if (endHour < 12) "AM" else "PM")

selectedStartDateText = startDate
selectedEndDateText = startDate
selectedStartTimeText = startTime
selectedEndTimeText = endTime
}

LazyColumn(
modifier = Modifier
.fillMaxSize()
Expand Down Expand Up @@ -111,12 +136,14 @@ fun AddPlanScreen() {
}

item {
// 시작 날짜와 시간 선택
AddPlanSelectComponent(
title = "Starts",
dateText = selectedStartDateText,
onDateClick = { isStartCalendarVisible = true },
timeText = selectedStartTimeText,
onTimeClick = { showStartTimePickerBottomSheet = true }
timeText = if(isAllDayChecked) "All-day" else selectedStartTimeText,
onTimeClick = { showStartTimePickerBottomSheet = true },
isAllChecked = isAllDayChecked
)
}

Expand All @@ -126,8 +153,9 @@ fun AddPlanScreen() {
title = "Ends",
dateText = selectedEndDateText,
onDateClick = { isEndCalendarVisible = true },
timeText = selectedEndTimeText,
onTimeClick = { showEndTimePickerBottomSheet = true }
timeText = if(isAllDayChecked) "All-day" else selectedEndTimeText,
onTimeClick = { showEndTimePickerBottomSheet = true },
isAllChecked = isAllDayChecked,
)
}

Expand Down Expand Up @@ -157,7 +185,7 @@ fun AddPlanScreen() {
}

item {
// 반복 설정
// 그냥 Repeat
AddPlanSelectComponent(
title = "Repeat",
dateText = selectedRepeatText,
Expand All @@ -167,19 +195,22 @@ fun AddPlanScreen() {
)
}

item {
// 반복 설정
AddPlanSelectComponent(
title = "End Repeat",
dateText = selectedEndRepeatText,
onDateClick = { isEndRepeatCalendarVisible = true },
timeText = null,
onTimeClick = null
)
if (isAllDayChecked) {
item {
// End Repeat
AddPlanSelectComponent(
title = "End Repeat",
dateText = selectedEndRepeatText,
onDateClick = { isEndRepeatCalendarVisible = true },
timeText = null,
onTimeClick = null,

)
}
}

item {
// 태그 설정
// Tag
AddPlanSelectComponent(
title = "Tag",
dateText = selectedTagText,
Expand Down Expand Up @@ -277,6 +308,7 @@ fun AddPlanSelectComponent(
timeText: String?,
onTimeClick: (() -> Unit)?,
tagColor: String? = null,
isAllChecked: Boolean? = null
) {
Row(
modifier = Modifier.fillMaxWidth(),
Expand All @@ -297,7 +329,7 @@ fun AddPlanSelectComponent(
selectorType = if (title == "Repeat" || title == "End Repeat") SelectorType.BASIC else if (title == "Tag") SelectorType.TAG else SelectorType.DATESELECTOR,
isClicked = false,
onClickedChange = { onDateClick() },
content = dateText,
content = dateText,
tagColor = tagColor,
)

Expand All @@ -308,7 +340,8 @@ fun AddPlanSelectComponent(
onClickedChange = { onTimeClick?.invoke() },
content = timeText,
tagColor = null,
modifier = Modifier.padding(start = 10.dp)
modifier = Modifier.padding(start = 10.dp),
isLimited = isAllChecked
)
}
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/org/memento/ui/MementoBottomSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ fun MementoBottomSheet(
}

ModalBottomSheet(
onDismissRequest = { },
onDismissRequest = {
onConfirm(null)
},
sheetState = sheetState,
shape = RoundedCornerShape(topStart = 0.dp, topEnd = 0.dp),
containerColor = darkModeColors.gray09,
Expand Down

0 comments on commit e41ba42

Please sign in to comment.