Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#322] 온보딩, 데이트피커 / 3차 스프린트 QA 반영 #327

Merged
merged 9 commits into from
Jan 9, 2025
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.terning.core.designsystem.util

import com.terning.core.designsystem.extension.currentMonth
import com.terning.core.designsystem.extension.currentYear
import java.util.Calendar

object CalendarDefaults {
const val START_YEAR = 2010
const val END_YEAR = 2030
val END_YEAR =
if (Calendar.getInstance().currentMonth >= 10) Calendar.getInstance().currentYear + 1
else Calendar.getInstance().currentYear
const val START_MONTH = 1
const val END_MONTH = 12
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fun StartFilteringScreen(
onStartClick = onStartClick,
onLaterClick = onLaterClick
)
Spacer(modifier = Modifier.height((24 * screenHeight).dp))
Spacer(modifier = Modifier.height((16 * screenHeight).dp))
}
}

Expand All @@ -133,7 +133,7 @@ private fun ButtonAnimation(
cornerRadius = 10.dp,
modifier = Modifier.padding(horizontal = 24.dp)
)
Spacer(modifier = Modifier.height(12.dp))
Spacer(modifier = Modifier.height(20.dp))
Text(
text = stringResource(R.string.start_filtering_later),
style = TerningTheme.typography.detail3.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,22 @@ private fun rememberPickerState() = remember { PickerState() }
internal fun HomeYearMonthPicker(
chosenYear: Int?,
chosenMonth: Int?,
onYearChosen: (Int?, Boolean) -> Unit,
onMonthChosen: (Int?, Boolean) -> Unit,
onYearChosen: (Int?) -> Unit,
onMonthChosen: (Int?) -> Unit,
isYearNull: Boolean,
isMonthNull: Boolean,
yearsList: ImmutableList<String>,
monthsList: ImmutableList<String>,
isInitialNullState: Boolean,
modifier: Modifier = Modifier,
) {
val yearPickerState = rememberPickerState()
val monthPickerState = rememberPickerState()

var isInitialSelection by remember { mutableStateOf(isInitialNullState) }

val startYearIndex =
if (isYearNull) yearsList.lastIndex else yearsList.indexOf("${chosenYear ?: "-"}년")
if (isYearNull) yearsList.lastIndex else yearsList.indexOf("${chosenYear ?: NULL_DATE}년")
.takeIf { it >= 0 } ?: yearsList.lastIndex
val startMonthIndex =
if (isMonthNull) monthsList.lastIndex else monthsList.indexOf("${chosenMonth ?: "-"}월")
if (isMonthNull) monthsList.lastIndex else monthsList.indexOf("${chosenMonth ?: NULL_DATE}월")
.takeIf { it >= 0 } ?: monthsList.lastIndex

Row(
Expand All @@ -91,10 +88,9 @@ internal fun HomeYearMonthPicker(
items = yearsList,
startIndex = startYearIndex,
onItemSelected = { year ->
if (year == NULL_DATE && !isInitialSelection) isInitialSelection = true
onYearChosen(
if (year == NULL_DATE) null else year.dropLast(1).toInt(),
isInitialSelection
if (year == NULL_DATE) null
else year.dropLast(1).toInt()
)
}
)
Expand All @@ -105,10 +101,9 @@ internal fun HomeYearMonthPicker(
items = monthsList,
startIndex = startMonthIndex,
onItemSelected = { month ->
if (month == NULL_DATE && !isInitialSelection) isInitialSelection = true
onMonthChosen(
if (month == NULL_DATE) null else month.dropLast(1).toInt(),
isInitialSelection
if (month == NULL_DATE) null
else month.dropLast(1).toInt()
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,15 @@ internal fun PlanFilteringScreen(
var isYearNull by remember { mutableStateOf(currentFilteringInfo.startYear == 0 || currentFilteringInfo.startYear == null) }
var isMonthNull by remember { mutableStateOf(currentFilteringInfo.startMonth == 0 || currentFilteringInfo.startMonth == null) }

var isInitialNullState by remember { mutableStateOf(false) }

val yearsList by remember(isYearNull) {
mutableStateOf(
if (isYearNull || isInitialNullState) years + NULL_DATE
if (isYearNull) years + NULL_DATE
else years
)
}
val monthsList by remember(isMonthNull) {
mutableStateOf(
if (isMonthNull || isInitialNullState) months + NULL_DATE
if (isMonthNull) months + NULL_DATE
else months
)
}
Expand Down Expand Up @@ -133,27 +131,24 @@ internal fun PlanFilteringScreen(
HomeYearMonthPicker(
chosenYear = currentFilteringInfo.startYear,
chosenMonth = currentFilteringInfo.startMonth,
onYearChosen = { year, isInitialSelection ->
onYearChosen = { year ->
updateStartYear(year)
if (year != null) {
updateIsCheckBoxChecked(false)
isYearNull = false
isInitialNullState = isInitialSelection
}
},
onMonthChosen = { month, isInitialSelection ->
onMonthChosen = { month ->
updateStartMonth(month)
if (month != null) {
updateIsCheckBoxChecked(false)
isMonthNull = false
isInitialNullState = isInitialSelection
}
},
isYearNull = isYearNull,
isMonthNull = isMonthNull,
yearsList = yearsList.toImmutableList(),
monthsList = monthsList.toImmutableList(),
isInitialNullState = isInitialNullState
)

Row(
Expand Down
Loading