Skip to content

Commit

Permalink
[MERGE] #322 -> develop
Browse files Browse the repository at this point in the history
[FIX/#322] 온보딩, 데이트피커 / 3차 스프린트 QA 반영
  • Loading branch information
leeeyubin authored Jan 9, 2025
2 parents f51f632 + 7720087 commit ed9c027
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
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

0 comments on commit ed9c027

Please sign in to comment.