From d68a2eb871bc53ed664831cb5a406a3593205410 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sat, 21 Dec 2024 02:48:11 +0900 Subject: [PATCH] =?UTF-8?q?[MOD/#309]=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/HomeFilteringBottomSheet.kt | 49 +++++++++---------- .../home/component/HomeYearMonthPicker.kt | 12 ++--- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/feature/home/src/main/java/com/terning/feature/home/component/HomeFilteringBottomSheet.kt b/feature/home/src/main/java/com/terning/feature/home/component/HomeFilteringBottomSheet.kt index e32abf55..aa3ee2cf 100644 --- a/feature/home/src/main/java/com/terning/feature/home/component/HomeFilteringBottomSheet.kt +++ b/feature/home/src/main/java/com/terning/feature/home/component/HomeFilteringBottomSheet.kt @@ -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( @@ -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 -> @@ -192,8 +191,8 @@ fun HomeFilteringBottomSheet( }, isYearNull = isYearNull, isMonthNull = isMonthNull, - years = yearsWithNull, - months = monthsWithNull, + yearsList = yearsList, + monthsList = monthsList, isFirstNullAndFirstChange = isFirstNullAndFirstChange ) diff --git a/feature/home/src/main/java/com/terning/feature/home/component/HomeYearMonthPicker.kt b/feature/home/src/main/java/com/terning/feature/home/component/HomeYearMonthPicker.kt index a5a3a28b..82f09556 100644 --- a/feature/home/src/main/java/com/terning/feature/home/component/HomeYearMonthPicker.kt +++ b/feature/home/src/main/java/com/terning/feature/home/component/HomeYearMonthPicker.kt @@ -62,8 +62,8 @@ fun HomeYearMonthPicker( onMonthChosen: (Int?, Boolean) -> Unit, isYearNull: Boolean, isMonthNull: Boolean, - years: List, - months: List, + yearsList: List, + monthsList: List, isFirstNullAndFirstChange: Boolean ) { val yearPickerState = rememberPickerState() @@ -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( @@ -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 @@ -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