Skip to content

Commit

Permalink
[MOD/#309] 변수명 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Dec 20, 2024
1 parent 24d3ccd commit d68a2eb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,27 @@ fun HomeFilteringBottomSheet(
)
}

// todo : year와 month의 서버통신 값이 null이면 각각 false로 넣어주세요!
var isYearNull by remember { mutableStateOf(false) }
var isMonthNull by remember { mutableStateOf(false) }
// todo: year와 month의 서버통신 값이 null이면 true로 넣어주세요!
var isCheck by remember { mutableStateOf(false) }

var isFirstNullAndFirstChange by remember { mutableStateOf(false) }

val yearsList by remember(isYearNull) {
mutableStateOf(
if (isYearNull || isFirstNullAndFirstChange) years + "-"
else years
)
}
val monthsList by remember(isMonthNull) {
mutableStateOf(
if (isMonthNull || isFirstNullAndFirstChange) months + "-"
else months
)
}

TerningBasicBottomSheet(
content = {
Column(
Expand Down Expand Up @@ -133,29 +154,7 @@ fun HomeFilteringBottomSheet(
.padding(horizontal = 24.dp)
)

// todo : 만약 year와 month의 서버통신 값이 null이면 false로 넣기
var isYearNull by remember { mutableStateOf(false) }
var isMonthNull by remember { mutableStateOf(false) }
// todo: year와 month의 서버통신 값이 null이면 true로 넣기
var isCheck by remember { mutableStateOf(false) }

var isFirstNullAndFirstChange by remember { mutableStateOf(false) }

// todo: 변수명 바꾸기
val yearsWithNull by remember(isYearNull) {
mutableStateOf(
if (isYearNull || isFirstNullAndFirstChange) years + "-"
else years
)
}
val monthsWithNull by remember(isMonthNull) {
mutableStateOf(
if (isMonthNull || isFirstNullAndFirstChange) months + "-"
else months
)
}

//todo: 추후 삭제 부탁합니다!
//todo: 예시 체크박스로, 추후 수정 부탁합니다!
Checkbox(
checked = isCheck,
onCheckedChange = { isChecked ->
Expand Down Expand Up @@ -192,8 +191,8 @@ fun HomeFilteringBottomSheet(
},
isYearNull = isYearNull,
isMonthNull = isMonthNull,
years = yearsWithNull,
months = monthsWithNull,
yearsList = yearsList,
monthsList = monthsList,
isFirstNullAndFirstChange = isFirstNullAndFirstChange
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ fun HomeYearMonthPicker(
onMonthChosen: (Int?, Boolean) -> Unit,
isYearNull: Boolean,
isMonthNull: Boolean,
years: List<String>,
months: List<String>,
yearsList: List<String>,
monthsList: List<String>,
isFirstNullAndFirstChange: Boolean
) {
val yearPickerState = rememberPickerState()
Expand All @@ -72,11 +72,11 @@ fun HomeYearMonthPicker(
var isFirst = isFirstNullAndFirstChange

val startYearIndex =
if (isYearNull) years.lastIndex else years.indexOf("${chosenYear ?: "-"}")
if (isYearNull) yearsList.lastIndex else yearsList.indexOf("${chosenYear ?: "-"}")
.takeIf { it >= 0 } ?: 0

val startMonthIndex =
if (isMonthNull) months.lastIndex else months.indexOf("${chosenMonth ?: "-"}")
if (isMonthNull) monthsList.lastIndex else monthsList.indexOf("${chosenMonth ?: "-"}")
.takeIf { it >= 0 } ?: 0

Row(
Expand All @@ -88,7 +88,7 @@ fun HomeYearMonthPicker(
DatePicker(
modifier = Modifier.weight(1f),
pickerState = yearPickerState,
items = years,
items = yearsList,
startIndex = startYearIndex,
onItemSelected = { year ->
if (year == "-" && !isFirst) isFirst = true
Expand All @@ -99,7 +99,7 @@ fun HomeYearMonthPicker(
DatePicker(
modifier = Modifier.weight(1f),
pickerState = monthPickerState,
items = months,
items = monthsList,
startIndex = startMonthIndex,
onItemSelected = { month ->
if (month == "-" && !isFirst) isFirst = true
Expand Down

0 comments on commit d68a2eb

Please sign in to comment.