Skip to content

Conversation

@librawish808
Copy link
Collaborator

@librawish808 librawish808 commented Jan 23, 2026

🔗 관련 이슈

📙 작업 설명

  • CalendarUiState 제거
    • 주간 캘린더에 필요한 값(selectedDate, weekDates)을
      WeeklyCalendar 컴포넌트의 파라미터로 직접 전달하도록 변경
  • CalendarViewModel 제거
    • 날짜 선택 및 주차 계산 로직을 각 상세 화면(ViewModel)으로 이동
  • WeeklyCalendar를 순수 UI 컴포넌트로 변경
    • 상태 보관 및 계산 책임 제거

📸 스크린샷 또는 시연 영상 (선택)

💬 추가 설명 or 리뷰 포인트 (선택)

Summary by CodeRabbit

릴리스 노트

  • Refactor

    • 캘린더 컴포넌트를 공통 모듈로 통합하여 재사용성 향상
    • 기존 중앙 캘린더 상태를 제거하고 각 상세 화면으로 날짜 관리 이동(아키텍처 단순화)
    • 위클리 캘린더 호출 방식 및 날짜 전달 방식 정리
  • New Features

    • 여러 상세 화면(식사, 약, 수면, 건강, 정신)에 선택된 날짜 및 주 단위 날짜 API 추가
    • 화면 재구성으로 날짜 변경 시 데이터 자동 로드 트리거 추가

✏️ Tip: You can customize this high-level summary in your review settings.

@librawish808 librawish808 self-assigned this Jan 23, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

Warning

Rate limit exceeded

@librawish808 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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

Cohort / File(s) 설명
캘린더 공용 컴포넌트 이동
app/src/main/java/com/konkuk/medicarecall/ui/common/component/DatePickerModal.kt, app/src/main/java/com/konkuk/medicarecall/ui/common/component/DateSelector.kt, app/src/main/java/com/konkuk/medicarecall/ui/common/component/WeeklyCalendar.kt
패키지 경로가 ui.feature.calendarui.common.component로 변경. WeeklyCalendar 시그니처가 calendarUiState 제거 및 selectedDate: LocalDate, weekDates: List<LocalDate> 직접 수신으로 변경. 일부 Color/Modifier 접근 방식(Companion 사용) 정규화.
삭제된 독립 캘린더 모듈
app/src/main/java/com/konkuk/medicarecall/ui/feature/calendar/viewmodel/CalendarUiState.kt, app/src/main/java/com/konkuk/medicarecall/ui/feature/calendar/viewmodel/CalendarViewModel.kt
CalendarUiState 데이터 클래스와 CalendarViewModel 파일 전체 삭제. 공유 캘린더 ViewModel 제거.
기능별 ViewModel에 날짜 상태 통합
app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/meal/viewmodel/MealViewModel.kt, .../medicine/viewmodel/MedicineViewModel.kt, .../sleep/viewmodel/SleepViewModel.kt, .../statehealth/viewmodel/HealthViewModel.kt, .../statemental/viewmodel/MentalViewModel.kt
각 ViewModel에 _selectedDate: MutableStateFlow<LocalDate> + selectedDate: StateFlow<LocalDate>, selectDate(date), resetToToday(), getCurrentWeekDates() 추가.
상세 화면들에서 CalendarViewModel 제거 및 호출 변경
app/src/main/java/com/konkuk/medicarecall/ui/feature/homedetail/meal/screen/MealDetailScreen.kt, .../medicine/screen/MedicineDetailScreen.kt, .../sleep/screen/SleepDetailScreen.kt, .../statehealth/screen/StateHealthDetailScreen.kt, .../statemental/screen/StateMentalDetailScreen.kt
각 Screen 시그니처에서 calendarViewModel 제거. selectedDate/weekDates/onDateSelected 호출을 해당 기능 ViewModel로 전환하고 WeeklyCalendar에 weekDatesselectedDate를 직접 전달하도록 수정.
Preview/임포트 및 소소한 문법 정리
여러 파일 (위의 컴포넌트·스크린 파일들 및 Preview 파일들)
Previews에서 CalendarUiState 제거하고 직접 selectedDate/weekDates를 생성. Modifier/Color 접근 방식 일관성 확보(Companion 표기 등).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • ikseong00
  • alswlekk

Poem

캘린더가 흩어져 각자 빛나네 🌤️
컴포넌트로 정리되어 깔끔히 가네 ✨
뷰모델은 각자의 품으로 돌아가고
날짜는 흐르되 책임은 명확해져라 ⏳
작은 리팩토링, 큰 숨결 😊

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 주요 변경사항을 명확하게 설명합니다. CalendarUiState와 CalendarViewModel 제거 및 캘린더 상태 분리라는 핵심 리팩토링을 정확히 반영합니다.
Linked Issues check ✅ Passed PR의 모든 코드 변경사항이 #226 이슈의 요구사항을 충족합니다. CalendarViewModel 제거, CalendarUiState 삭제, 캘린더 로직을 각 상세화면 ViewModel으로 이동했으며, WeeklyCalendar를 순수 UI 컴포넌트로 변환했습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 캘린더 리팩토링 범위 내입니다. Modifier.Companion, Color.Companion 사용 등 기술적 조정은 리팩토링 과정에서의 필요한 변경이며, 패키지 이동도 컴포넌트화 목표와 일치합니다.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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.CompanionAlignment.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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

HttpException 중복 import로 컴파일 충돌 위험

android.net.http.HttpExceptionretrofit2.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.

Suggested change
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] Calendar ViewModel 제거 및 컴포넌트화

2 participants