From 449ae7b34abb5769ee3f8c0bb2647ded7147ba83 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sat, 21 Dec 2024 03:59:40 +0900 Subject: [PATCH] =?UTF-8?q?[MOD/#309]=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B0=8F=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/home/component/HomeYearMonthPicker.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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 c366247a..0a332753 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 @@ -94,7 +94,10 @@ fun HomeYearMonthPicker( startIndex = startYearIndex, onItemSelected = { year -> if (year == NULL_DATE && !isInitialSelection) isInitialSelection = true - onYearChosen(if (year == NULL_DATE) null else year.dropLast(1).toInt(), isInitialSelection) + onYearChosen( + if (year == NULL_DATE) null else year.dropLast(1).toInt(), + isInitialSelection + ) } ) Spacer(modifier = Modifier.width(18.dp)) @@ -136,15 +139,13 @@ fun DatePicker( } } - // todo: type safety 하게 수정 필요 && 변수명도 수정 - val isNullSize = items.size == 12 || items.size == 21 - LaunchedEffect(scrollState) { snapshotFlow { scrollState.firstVisibleItemIndex } .map { index -> - var newItem = items - if (isNullSize) newItem = items + NULL_DATE - newItem.getOrNull(index) + val hasNullDate = + items.size == (END_YEAR - START_YEAR + 1) || items.size == (END_MONTH - START_MONTH + 1) + val adjustedItems = if (hasNullDate) items + NULL_DATE else items + adjustedItems.getOrNull(index) } .distinctUntilChanged() .collect { item ->