DatePicker 지난 날짜에 대한 컴포넌트 수정#81
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough이 PR은 DatePicker 컴포넌트의 내부 구조를 리팩토링합니다. 기존의 Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| }.toPersistentList() | ||
| } | ||
|
|
||
| internal fun lastWeekIndexToRender(cells: List<LocalDate?>): Int { |
There was a problem hiding this comment.
lastWeekIndexToRender함수는 기존에 무조건 6x7로 42칸을 그리던 함수여서 제거했습니다.
- 제거함에 따라 buildMonthGrid 파일에 함수 하나밖에 남지않아 MonthGrid.kt 안으로 옮겼습니다.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerMonth.kt (1)
76-83:dates를remember의존성에서 제거하는 것이 좋습니다.
dates는 이미yearMonth로부터 파생되므로,weeks의remember키에 포함할 필요가 없습니다.yearMonth,selectedDate,today만 의존성으로 두면 충분합니다.♻️ 제안된 수정
- val weeks = remember(dates, selectedDate, today) { - dates + val weeks = remember(yearMonth, selectedDate, today) { + buildMonthGrid(yearMonth) .map { date -> if (date == null) return@map null DayCellType.from(date = date, selectedDate = selectedDate, today = today) }.chunked(7) .filter { week -> week.any { cell -> cell != null && cell !is DayCellType.Past } } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerMonth.kt` around lines 76 - 83, The remember key for weeks currently includes dates but dates is derived from yearMonth; update the remember call to depend on yearMonth, selectedDate, and today instead of dates (i.e., change remember(dates, selectedDate, today) to remember(yearMonth, selectedDate, today)) so weeks recomputes when the source yearMonth changes; keep the mapping that uses dates and DayCellType.from(date, selectedDate, today) unchanged.Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DayCell.kt (1)
27-34:null셀에 대한enabled조건을 명확히 하는 것이 좋습니다.현재
dayCell !is DayCellType.Past조건은dayCell이null일 때true를 반환하여 빈 셀도 터치 가능한 상태가 됩니다. 호출부에서null체크를 하고 있어 실제 문제는 없지만, 의도를 명확히 하면 좋겠습니다.♻️ 제안된 수정
PrezelTouchArea( - enabled = dayCell !is DayCellType.Past, + enabled = dayCell != null && dayCell !is DayCellType.Past, modifier = modifier🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DayCell.kt` around lines 27 - 34, The enabled expression currently treats a null dayCell as enabled; update the PrezelTouchArea(enabled = ...) check so null cells are disabled by making the condition explicit (e.g., ensure enabled is true only when dayCell is non-null and not a DayCellType.Past). Locate the PrezelTouchArea usage and change the enabled parameter to check dayCell != null && dayCell !is DayCellType.Past (or equivalent) so empty cells are not touchable while preserving existing onClick and modifier behavior.Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerDefaults.kt (1)
49-49: 선택된 날짜 텍스트 색상이 다크 테마 색상으로 고정되어 있습니다.
PrezelColorScheme.Dark.textLarge를 직접 사용하여 선택된 날짜의 텍스트 색상을 고정하고 있습니다. 이는interactiveRegular배경색과의 대비를 위한 의도적인 선택으로 보이지만, 테마 시스템을 따르지 않으므로 향후 유지보수 시 주의가 필요합니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerDefaults.kt` at line 49, DatePickerDefaults currently hardcodes selectedDayTextColor to PrezelColorScheme.Dark.textLarge; change this to use the theme-aware semantic color (e.g., the current theme’s text-on-interactive or equivalent) so the selectedDayTextColor follows the app theme rather than always using PrezelColorScheme.Dark.textLarge; update the assignment in DatePickerDefaults (symbol: selectedDayTextColor) to reference the theme color provider (e.g., PrezelTheme/PrezelColorScheme current accessor or the semantic onInteractiveRegular token) and ensure contrast with interactiveRegular is preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DayCellType.kt`:
- Around line 31-33: The isHoliday() implementation in DayCellType currently
only treats Sundays as holidays; update the DayCellType companion object's fun
isHoliday(date: LocalDate) to also return true for Saturdays (i.e., consider
date.dayOfWeek == DayOfWeek.SATURDAY || date.dayOfWeek == DayOfWeek.SUNDAY) so
weekend days are both marked as holidays in the calendar UI.
In
`@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/PrezelDatePicker.kt`:
- Around line 59-63: The construction of the months list uses
YearMonth(...).plus(value = offset, unit = DateTimeUnit.MONTH), which is invalid
for YearMonth; update the remember(today) block that builds months to call
YearMonth(today.year, today.month).plusMonth(offset) for each offset (i.e.,
replace the .plus(...) call with .plusMonth(offset)) so the months List is
produced correctly.
- Line 58: selectedDate is declared with remember(initialSelectedDate) but not
as a MutableState, so assignments like selectedDate = date won't trigger
recomposition; update the declaration in PrezelDatePicker (selectedDate) to use
remember { mutableStateOf(initialSelectedDate) } (or rememberSaveable {
mutableStateOf(...) } if state should survive process death) and, if preferred,
use the by delegation pattern (var selectedDate by remember {
mutableStateOf(initialSelectedDate) }) so UI updates when you assign
selectedDate = date.
---
Nitpick comments:
In
`@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerDefaults.kt`:
- Line 49: DatePickerDefaults currently hardcodes selectedDayTextColor to
PrezelColorScheme.Dark.textLarge; change this to use the theme-aware semantic
color (e.g., the current theme’s text-on-interactive or equivalent) so the
selectedDayTextColor follows the app theme rather than always using
PrezelColorScheme.Dark.textLarge; update the assignment in DatePickerDefaults
(symbol: selectedDayTextColor) to reference the theme color provider (e.g.,
PrezelTheme/PrezelColorScheme current accessor or the semantic
onInteractiveRegular token) and ensure contrast with interactiveRegular is
preserved.
In
`@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerMonth.kt`:
- Around line 76-83: The remember key for weeks currently includes dates but
dates is derived from yearMonth; update the remember call to depend on
yearMonth, selectedDate, and today instead of dates (i.e., change
remember(dates, selectedDate, today) to remember(yearMonth, selectedDate,
today)) so weeks recomputes when the source yearMonth changes; keep the mapping
that uses dates and DayCellType.from(date, selectedDate, today) unchanged.
In
`@Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DayCell.kt`:
- Around line 27-34: The enabled expression currently treats a null dayCell as
enabled; update the PrezelTouchArea(enabled = ...) check so null cells are
disabled by making the condition explicit (e.g., ensure enabled is true only
when dayCell is non-null and not a DayCellType.Past). Locate the PrezelTouchArea
usage and change the enabled parameter to check dayCell != null && dayCell !is
DayCellType.Past (or equivalent) so empty cells are not touchable while
preserving existing onClick and modifier behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 48205158-7cd1-4c3b-9120-341394222d96
📒 Files selected for processing (9)
Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/DatePickerDayCellView.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/DayCell.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/MonthGrid.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/MonthSection.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/PrezelDatePicker.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerDefaults.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DatePickerMonth.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DayCell.ktPrezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/config/DayCellType.kt
💤 Files with no reviewable changes (4)
- Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/DayCell.kt
- Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/MonthGrid.kt
- Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/MonthSection.kt
- Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/DatePickerDayCellView.kt
DatePicker의 `MonthGrid` 컴포넌트에서 불필요한 인덱스 계산 로직을 제거하고, 오늘 날짜를 기준으로 가시적인 주(week)만 필터링하여 렌더링하도록 개선했습니다.
* `MonthGridBuilder.kt`: 사용되지 않는 `lastWeekIndexToRender` 함수를 삭제했습니다.
* `MonthGrid.kt`:
* `buildMonthGrid`의 결과를 7일 단위로 청크(`chunked`)화하고, `hasVisibleDate` 확장 함수를 통해 오늘 이후의 날짜가 포함된 주만 노출하도록 수정했습니다.
* `WeekRow`에서 인덱스 기반의 `for` 루프를 `forEach` 문으로 교체하여 가독성을 높였습니다.
* 불필요한 `ImmutableList` 의존성을 제거하고 `List`를 사용하도록 변경했습니다.
* `MonthGridPreview`의 데이터를 최신 날짜 기준으로 업데이트했습니다.
# Conflicts:
# Prezel/core/designsystem/src/main/java/com/team/prezel/core/designsystem/component/datepicker/MonthGrid.kt
`DatePickerDayCellView`, `MonthSection`, `PrezelDatePicker` 컴포넌트의 프리뷰에서 사용되는 날짜 데이터 및 레이아웃 설정을 실제 동작 확인이 용이하도록 업데이트했습니다.
- `MonthGridBuilder.kt` 파일을 삭제하고 `buildMonthGrid` 함수를 `MonthGrid.kt` 내부의 private 함수로 이동하였습니다. - 별도의 파일로 관리되던 그리드 생성 로직을 컴포넌트 파일로 통합하여 응집도를 높였습니다.
CodeRabbit 설정 파일의 옵션을 조정하여 코드 리뷰 시 제공되는 요약 기능을 강화하고 리뷰 프로필을 변경했습니다. * `reviews.profile`을 `chill`로 설정했습니다. * `high_level_summary` 및 `changed_files_summary` 옵션을 `true`로 변경하여 요약 기능을 활성화했습니다. * `collapse_walkthrough` 옵션을 `true`로 수정했습니다.
DatePicker 관련 스타일 결정 로직을 `DatePickerDefaults` 객체로 통합하여 가독성과 유지보수성을 개선했습니다. * `DatePickerDefaults.kt` 파일을 생성하여 `dayTextColor`, `dayContainerColor`, `dayTextStyle` 로직을 한 곳에서 관리하도록 수정했습니다. * `DatePickerDayCellView`에서 하드코딩된 스타일 로직을 `DatePickerDefaults` 호출 방식으로 변경했습니다. * `DatePickerStyle.kt` 파일을 삭제하고 기존 확장 함수 로직을 `DatePickerDefaults`로 이관했습니다. * `MonthGrid.kt` 내 불필요한 `ThemePreview` 어노테이션을 제거했습니다.
* `androidx.compose.material3.DatePickerDefaults` 등 사용하지 않는 import 문을 제거했습니다. * `DatePickerDefault`를 `DatePickerDefaults`로 수정하여 명칭의 일관성을 맞추었습니다.
`DayCellView` 컴포넌트에서 `dayCell`이 `null`인 경우에도 클릭 영역이 활성화되던 문제를 수정하기 위해 `enabled` 조건을 강화했습니다. * `dayCell`이 `null`이 아니고, 과거 날짜(`DayCellType.Past`)가 아닐 때만 `PrezelTouchArea`가 활성화되도록 수정했습니다.
628f770 to
7d3b797
Compare
`PrezelDatePicker`에서 날짜가 선택되지 않은 상태를 지원하도록 관련 로직을 수정하였습니다. * `PrezelDatePicker`의 `initialSelectedDate` 파라미터 타입을 `LocalDate?`로 변경하고 기본값을 `null`로 설정하였습니다. * 날짜가 선택되지 않았을 때를 대응하기 위해 `DayCellType.from`, `DatePickerMonth`, `MonthGrid` 등 내부 컴포넌트의 `selectedDate` 타입을 `LocalDate?`로 변경하였습니다. * `DatePickerFooter`의 확인 버튼 클릭 시, 선택된 날짜가 존재할 때만(`selectedDate?`) `onConfirm` 콜백이 실행되도록 방어 로직을 추가하였습니다.
📌 작업 내용
🧩 관련 이슈
close #67
📸 스크린샷
📢 논의하고 싶은 내용
Summary by CodeRabbit
릴리스 노트
신규 기능
리팩토링