-
Notifications
You must be signed in to change notification settings - Fork 0
[Refactor] CalendarUiState / CalendarViewModel 제거 및 캘린더 상태 분리 #226 #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. Walkthrough캘린더 ViewModel/CalendarUiState를 제거하고 DatePickerModal, DateSelector, WeeklyCalendar를 공용 컴포넌트로 이동했으며, 각 홈 상세 기능의 ViewModel(Meal/Medicine/Sleep/Health/Mental)에 날짜 상태(selectedDate 등)와 주 계산 API를 통합했습니다. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
app/src/main/java/com/konkuk/medicarecall/ui/common/component/DateSelector.kt (1)
30-30: 사용되지 않는 파라미터 처리 필요
onMonthClick파라미터가 선언만 되고 실제로 사용되지 않습니다. 현재 라인 30의onMonthClick문은 아무 동작도 하지 않습니다. 파라미터를 제거하거나, 실제로 사용하거나,@Suppress("UNUSED_PARAMETER")를 추가해 주세요.🔧 제안된 수정 - 파라미터 제거
`@Composable` fun DateSelector( selectedDate: LocalDate, - onMonthClick: () -> Unit, onDateSelected: (LocalDate) -> Unit, ) { - onMonthClick // TODO: 현재 사용되지 않는 변수입니다. 추후 기능 추가 시 활용할 수 있습니다. var showDatePicker by remember { mutableStateOf(false) }app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/meal/screen/MealDetailScreen.kt (1)
104-108: Detekt indentation 실패 — 정렬 수정 필요CI가
Unexpected indentation로 깨지고 있어요. 들여쓰기만 맞추면 해결됩니다.🛠️ 제안 수정안
- WeeklyCalendar( - weekDates = weekDates, - selectedDate = selectedDate, - onDateSelected = onDateSelected, - ) + WeeklyCalendar( + weekDates = weekDates, + selectedDate = selectedDate, + onDateSelected = onDateSelected, + )
🤖 Fix all issues with AI agents
In
`@app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/statemental/viewmodel/MentalViewModel.kt`:
- Line 3: The file imports two different HttpException types causing ambiguity;
in MentalViewModel remove the android.net.http.HttpException import and keep (or
add) retrofit2.HttpException so all references to HttpException in
MentalViewModel resolve to Retrofit's exception, or fully-qualify any remaining
usages with retrofit2.HttpException if preferred.
♻️ Duplicate comments (3)
app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/sleep/viewmodel/SleepViewModel.kt (1)
21-37: 캘린더 로직 중복 (MealViewModel과 동일)이 캘린더 상태 관리 로직은
MealViewModel과 완전히 동일합니다. 앞서 제안한 대로 공통 유틸리티로 추출하면 유지보수성이 향상됩니다.app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/medicine/viewmodel/MedicineViewModel.kt (1)
23-39: 캘린더 로직 중복 (MealViewModel과 동일)다른 ViewModel들과 동일한 중복 패턴입니다.
app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/statehealth/viewmodel/HealthViewModel.kt (1)
20-36: 캘린더 로직 중복 (MealViewModel과 동일)다른 ViewModel들과 동일한 중복 패턴입니다.
🧹 Nitpick comments (4)
app/src/main/java/com/konkuk/medicarecall/ui/common/component/DatePickerModal.kt (1)
32-32:Color.Companion.White대신Color.White사용 권장
Color.Companion.White는 동작에 문제는 없지만, Kotlin에서는 일반적으로Color.White로 직접 접근하는 것이 관용적입니다. 이 패턴이 의도적인 것인지 확인해 주세요.♻️ 제안된 수정
- containerColor = Color.Companion.White, + containerColor = Color.White,- selectedDayContentColor = Color.Companion.White, + selectedDayContentColor = Color.White,- Surface(shape = RoundedCornerShape(16.dp), color = Color.Companion.White) { + Surface(shape = RoundedCornerShape(16.dp), color = Color.White) {Also applies to: 43-43, 95-95
app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/meal/viewmodel/MealViewModel.kt (1)
22-38: 캘린더 상태 관리 로직 중복이 캘린더 상태 관리 코드(
_selectedDate,selectDate,resetToToday,getCurrentWeekDates)가MealViewModel,SleepViewModel,MedicineViewModel,HealthViewModel에 동일하게 반복됩니다. 중복을 줄이기 위해 공통 유틸리티나 delegate 패턴으로 추출하는 것을 고려해 보세요.♻️ 제안: CalendarStateHolder delegate 추출
// CalendarStateHolder.kt class CalendarStateHolder { private val _selectedDate = MutableStateFlow(LocalDate.now()) val selectedDate: StateFlow<LocalDate> = _selectedDate fun selectDate(date: LocalDate) { _selectedDate.value = date } fun resetToToday() { _selectedDate.value = LocalDate.now() } fun getCurrentWeekDates(): List<LocalDate> { val base = _selectedDate.value val startOfWeek = base.with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY)) return (0..6).map { startOfWeek.plusDays(it.toLong()) } } }그런 다음 각 ViewModel에서:
class MealViewModel( private val mealRepository: MealRepository, ) : ViewModel() { private val calendarState = CalendarStateHolder() val selectedDate = calendarState.selectedDate fun selectDate(date: LocalDate) = calendarState.selectDate(date) fun resetToToday() = calendarState.resetToToday() fun getCurrentWeekDates() = calendarState.getCurrentWeekDates() // ... }app/src/main/java/com/konkuk/medicarecall/ui/common/component/DateSelector.kt (1)
37-37:Modifier.Companion및Alignment.Companion대신 직접 접근 권장
Modifier.Companion.fillMaxWidth()대신Modifier.fillMaxWidth(),Alignment.Companion.CenterVertically대신Alignment.CenterVertically가 Kotlin에서 더 관용적인 표현입니다.♻️ 제안된 수정
Row( - modifier = Modifier.Companion + modifier = Modifier .fillMaxWidth() .clickable(- verticalAlignment = Alignment.Companion.CenterVertically, + verticalAlignment = Alignment.CenterVertically,- modifier = Modifier.Companion.padding(end = 4.dp), + modifier = Modifier.padding(end = 4.dp),Also applies to: 45-45, 51-51
app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/sleep/screen/SleepDetailScreen.kt (1)
60-62:getCurrentWeekDates()는 호출할 때마다 새 리스트를 생성해요.현재 구현을 보면 (0..6).map으로 매 호출마다 새로운 List 인스턴스를 만들고 있어요. SleepDetailScreen에서 리컴포지션이 발생할 때마다 이 함수가 실행되면, 같은 날짜들을 담은 다른 리스트 객체가 계속 생성돼요. 이러면 이 리스트를 받는 자식 Composable이 불필요하게 리컴포지션될 수 있어요.
_selectedDate가 이미 StateFlow니까,getCurrentWeekDates()도 StateFlow<List>로 만들거나, 컴포저블 쪽에서remember(selectedDate)로 캐싱하는 방향을 고려해보세요.
| @@ -1,5 +1,6 @@ | |||
| package com.konkuk.medicarecall.ui.feature.homedetail.statemental.viewmodel | |||
|
|
|||
| import android.net.http.HttpException | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpException 중복 import로 컴파일 충돌 위험
android.net.http.HttpException과 retrofit2.HttpException을 동시에 import해서 이름이 모호해집니다. 하나만 남겨주세요.
🛠️ 제안 수정안
-import android.net.http.HttpException📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import android.net.http.HttpException |
🤖 Prompt for AI Agents
In
`@app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/statemental/viewmodel/MentalViewModel.kt`
at line 3, The file imports two different HttpException types causing ambiguity;
in MentalViewModel remove the android.net.http.HttpException import and keep (or
add) retrofit2.HttpException so all references to HttpException in
MentalViewModel resolve to Retrofit's exception, or fully-qualify any remaining
usages with retrofit2.HttpException if preferred.
# Conflicts: # app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/meal/viewmodel/MealViewModel.kt # app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/medicine/viewmodel/MedicineViewModel.kt # app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/sleep/viewmodel/SleepViewModel.kt # app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/statemental/viewmodel/MentalViewModel.kt
🔗 관련 이슈
📙 작업 설명
selectedDate,weekDates)을WeeklyCalendar컴포넌트의 파라미터로 직접 전달하도록 변경📸 스크린샷 또는 시연 영상 (선택)
💬 추가 설명 or 리뷰 포인트 (선택)
Summary by CodeRabbit
릴리스 노트
Refactor
New Features
✏️ Tip: You can customize this high-level summary in your review settings.