Skip to content

[FEAT/#9] 게이지바 공통 컴포넌트 구현#18

Merged
sohee6989 merged 7 commits intodevelopfrom
feat/#9-gaugebar-component
Jan 11, 2026
Merged

[FEAT/#9] 게이지바 공통 컴포넌트 구현#18
sohee6989 merged 7 commits intodevelopfrom
feat/#9-gaugebar-component

Conversation

@sohee6989
Copy link
Copy Markdown
Contributor

@sohee6989 sohee6989 commented Jan 9, 2026

Related issue 🛠

Work Description ✏️

  • 게이지바 공통 컴포넌트 구현

Screenshot 📸

스크린샷 2026-01-09 오후 11 43 53

Uncompleted Tasks 😅

  • N/A

To Reviewers 📢

일단 변수명 다른거 제안해주시는거 적극 환영합니다..!ㅎㅎ
몇몇 변수 이름이 좀 애매할수도 있는거 같은데 마땅한게 떠오르지 않아서 코드 보시다가 제안해주실 부분 있음 맘껏 제안해주세요!!

CherrishGaugeStyle가 GaugeBar의 레벨 단계, 활성/선택 상태에 따른 표현으로 gaugebar와 강하게 결합되어 있어 이걸 공통 스타일로 분리하기 보다는 gaugebar 패키지 내부에 함께 위치시키는 것이 적절하다고 판단하여 gaugebar 내부에 위치시켜놨는데 이것 관련해서 다른 분들의 의견이 궁금합니다아~~~

Summary by CodeRabbit

  • 새로운 기능
    • 게이지 바 UI 컴포넌트 추가 — 최대 4단계 게이지를 가로로 표시하고 현재 단계에 따라 활성/선택 상태를 반영합니다.
    • 레벨별 색상 및 테두리 구성 제공 — 활성/비활성 상태에 따라 자동으로 색상이 결정됩니다.
    • 라벨 생성 규칙 포함 — 각 레벨에 "Lv.x" 형식 라벨과 선택 상태에 따른 라벨 색상이 적용됩니다.

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

@sohee6989 sohee6989 requested a review from a team as a code owner January 9, 2026 14:49
@sohee6989 sohee6989 linked an issue Jan 9, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 9, 2026

Walkthrough

새로운 Jetpack Compose 게이지 컴포넌트 CherrishGaugeBar와 관련 타입·색상·스타일 유틸리티(CherrishGaugeType, CherrishGaugeColors, CherrishGaugeStyle)를 추가하여 여러 단계 게이지를 반응형으로 렌더링하고 활성/선택 상태에 따라 색상과 레이블을 결정합니다.

Changes

Cohort / File(s) Summary
Gauge Type Definition
app/src/main/java/com/cherrish/android/core/designsystem/component/type/CherrishGaugeType.kt
새 enum CherrishGaugeType(val step: Int) 추가 (LEVEL1..LEVEL4).
Gauge Colors
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeColors.kt
CherrishGaugeColors 데이터 클래스 및 cherrishGaugeActiveColors(...), cherrishGaugeInactiveColors(...) 함수 추가 (레벨별 배경·테두리 색 매핑).
Gauge Styling System
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeStyle.kt
CherrishGaugeStyle 데이터 클래스와 CherrishGaugeType.style(colors, isActive, isSelected) 확장함수 추가(레이블 및 색상 결정 로직).
Gauge Bar Component
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
@Composable fun CherrishGaugeBar(currentStep: Int, gauges: ImmutableList<CherrishGaugeType>, modifier: Modifier = Modifier) 추가: BoxWithConstraints 기반 반응형 계산, 커스텀 Layout으로 역순 게이지 렌더링, 각 세그먼트에 색상·레이블 적용; Preview 포함.
Project / Build
manifest_file, build.gradle.kts
프로젝트 메타/빌드 관련 라인 변경(파일별 일부 라인 추가).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 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
Title check ✅ Passed PR 제목은 게이지바 공통 컴포넌트 구현이라는 주요 변경 사항을 명확하게 요약하고 있으며, 이는 제시된 코드 변경사항과 일치합니다.
Description check ✅ Passed PR 설명은 관련 이슈, 작업 내용, 스크린샷, 미완료 작업, 리뷰 안내 등 템플릿의 주요 섹션을 포함하고 있으며 충분히 완성되어 있습니다.
Linked Issues check ✅ Passed PR은 이슈 #9의 게이지바 컴포넌트 구현 요구사항을 충족하고 있으며, CherrishGaugeBar, CherrishGaugeType, CherrishGaugeStyle, CherrishGaugeColors 등의 필요한 컴포넌트를 모두 구현했습니다.
Out of Scope Changes check ✅ Passed 모든 변경사항(4개 파일)은 게이지바 컴포넌트 구현이라는 명확한 범위 내에 있으며, 이슈 #9의 목표와 직접적으로 관련이 있습니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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
Copy Markdown

@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: 2

🤖 Fix all issues with AI agents
In
@app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt:
- Line 28: CherrishGaugeBar 컴포저블 상단에 붙은
@SuppressLint("UnusedBoxWithConstraintsScope") 어노테이션을 제거하세요: 실제로
BoxWithConstraints의 maxWidth를 (해당 컴포저블 내의 maxWidth 사용 코드) 사용하고 있으므로 억제할 필요가
없습니다. 구체적으로 CherrishGaugeBar 파일에서 @SuppressLint("UnusedBoxWithConstraintsScope")
줄을 삭제하여 경고 억제를 없애세요.
- Around line 38-44: There is a typo in the variable name baseSegmentOffest;
rename it to baseSegmentOffset everywhere it's used (declaration and usages in
totalBaseWidth calculation and the offsetWidth computation) so references like
totalBaseWidth, segmentWidth and offsetWidth use baseSegmentOffset consistently;
update any related occurrences in CherrishGaugeBar.kt to avoid the misspelling.
🧹 Nitpick comments (3)
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (3)

30-34: 함수 시그니처가 Compose 가이드라인을 잘 따르고 있습니다.

ImmutableList 사용으로 불필요한 recomposition을 방지하고 있으며, Modifier 파라미터가 마지막에 기본값과 함께 제공되어 적절합니다.

선택적 개선사항: currentStepgauges 범위를 벗어난 값일 경우에 대한 방어 로직을 추가하는 것을 고려해보세요. 현재는 모든 게이지가 활성화되거나 모두 비활성화될 수 있습니다.


46-80: 게이지 렌더링 로직이 올바르게 구현되었습니다.

각 게이지의 활성/선택 상태를 올바르게 계산하고 있으며, key(gauge)를 사용하여 Compose의 재구성 최적화를 적절히 활용하고 있습니다.

권장 최적화: 48번 라인과 90번 라인에서 gauges.asReversed()가 두 번 호출되고 있습니다. 이를 remember로 캐싱하면 불필요한 재계산을 방지할 수 있습니다.

♻️ 최적화 제안
+val reversedGauges = remember(gauges) { gauges.asReversed() }
+
 Layout(
     content = {
-        gauges.asReversed().forEach { gauge ->
+        reversedGauges.forEach { gauge ->
             key(gauge) {
                 // ...
             }
         }
     }
 ) { measurables, constraints ->
     // ...
     layout(width = constraints.maxWidth, height = layoutHeight) {
-        gauges.asReversed().forEachIndexed { i, gauge ->
+        reversedGauges.forEachIndexed { i, gauge ->
             // ...
         }
     }
 }

81-97: 레이아웃 배치 로직의 가정에 주의가 필요합니다.

91번 라인의 originalIndex = gauge.step - 1step 값이 1부터 시작하여 연속적이라고 가정하고 있습니다. 현재 CherrishGaugeType 구현에서는 문제없지만, 향후 enum 값이 변경되면(예: 0부터 시작하거나 값에 간격이 생기는 경우) 배치 로직이 깨질 수 있습니다.

개선 제안: step - 1 대신 원본 리스트에서의 실제 인덱스를 사용하거나, enum에 명시적인 index 속성을 추가하는 것을 고려해보세요.

💡 대안 구현

옵션 1: 원본 인덱스 맵 사용

val reversedGauges = remember(gauges) { gauges.asReversed() }
val indexMap = remember(gauges) { 
    gauges.withIndex().associate { it.value to it.index }
}

// ... in layout block:
reversedGauges.forEachIndexed { i, gauge ->
    val originalIndex = indexMap[gauge] ?: 0
    // ...
}

옵션 2: enum에 index 추가

enum class CherrishGaugeType(
    val step: Int,
    val index: Int
) {
    LEVEL1(1, 0),
    LEVEL2(2, 1),
    LEVEL3(3, 2),
    LEVEL4(4, 3)
}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d87269 and 6d5aeb1.

📒 Files selected for processing (3)
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeStyle.kt
  • app/src/main/java/com/cherrish/android/core/designsystem/component/type/CherrishGaugeType.kt
🧰 Additional context used
📓 Path-based instructions (1)
**/*.kt

⚙️ CodeRabbit configuration file

**/*.kt: - Jetpack Compose 구조, 상태 관리, recomposition 최적화에 집중

  • ViewModel, UiState, 단방향 데이터 흐름 패턴 검토
  • 불필요한 recomposition 가능성, remember/derivedStateOf 적절한 사용 확인
  • 네이밍 컨벤션, 가독성, Google 권장 Android 아키텍처 준수 여부

Files:

  • app/src/main/java/com/cherrish/android/core/designsystem/component/type/CherrishGaugeType.kt
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeStyle.kt
🧬 Code graph analysis (1)
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (1)
app/src/main/java/com/cherrish/android/core/designsystem/theme/Theme.kt (1)
  • CherrishTheme (38-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: PR Build Check
  • GitHub Check: PR Lint Check
🔇 Additional comments (4)
app/src/main/java/com/cherrish/android/core/designsystem/component/type/CherrishGaugeType.kt (1)

3-10: LGTM! 깔끔한 enum 정의입니다.

게이지 레벨을 표현하는 enum이 명확하게 정의되어 있습니다. step 프로퍼티를 통해 레벨 값에 직접 접근할 수 있어 사용성이 좋습니다.

app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeStyle.kt (2)

8-13: 데이터 클래스 구조가 적절합니다.

게이지 스타일링에 필요한 속성들이 명확하게 정의되어 있습니다. 레이블, 레이블 색상, 게이지 색상, 테두리 색상이 모두 포함되어 사용성이 좋습니다.


15-56: 스타일링 로직이 명확하고 올바르게 구현되었습니다.

활성/비활성 상태와 선택 여부에 따라 적절한 색상을 반환하고 있으며, 레벨별로 점진적으로 진한 red 계열 색상을 사용하는 것이 직관적입니다. @Composable 어노테이션은 CherrishTheme.colors 접근을 위해 필요하므로 올바르게 사용되었습니다.

패키지 위치 결정에 대한 의견:
PR 설명에서 언급하신 대로, CherrishGaugeStyleCherrishGaugeBar와 강하게 결합되어 있어 gaugebar 패키지 내부에 위치시킨 결정은 적절해 보입니다. 응집도를 높이는 좋은 선택입니다.

app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (1)

101-126: 프리뷰가 모든 상태를 잘 보여주고 있습니다.

각 레벨별로 게이지바의 상태를 미리 볼 수 있어 개발 중 시각적 검증이 용이합니다.

@sohee6989 sohee6989 self-assigned this Jan 9, 2026
@sohee6989 sohee6989 added FEAT✨ 새로운 기능 구현 소희🍒 소희 담당 labels Jan 9, 2026
Copy link
Copy Markdown

@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: 2

🤖 Fix all issues with AI agents
In
@app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt:
- Around line 27-32: CherrishGaugeBar lacks input validation for currentStep and
gauges; add checks at the start of the Composable: if gauges is empty either
return early (no UI) or throw an IllegalArgumentException (choose consistent
project behavior), and ensure currentStep is within valid range by clamping it
to 0..(gauges.lastIndex) or using require to validate and fail fast; update
references to currentStep inside CherrishGaugeBar to use the validated/clamped
value so downstream rendering cannot index out of bounds on the
ImmutableList<CherrishGaugeType>.
- Around line 88-93: The placement logic in CherrishGaugeBar.kt currently
computes originalIndex as gauge.step - 1 inside the
gauges.asReversed().forEachIndexed block, which assumes step is 1-based and
contiguous; change this to use the actual list index (or an explicit order/index
field on CherrishGaugeType) so layout doesn’t break if step values change or
reorder; locate the loop using gauges.asReversed().forEachIndexed and replace
usage of gauge.step - 1 with the correct list-derived index (or add and use a
dedicated order/index property on CherrishGaugeType) when computing xOffsetPx
for segmentPlaceables[i].placeRelative.
🧹 Nitpick comments (4)
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (4)

36-38: 매직 넘버를 상수로 추출 권장

하드코딩된 치수 값들(89.dp, 67.dp)을 명명된 상수로 추출하면 유지보수성과 가독성이 향상됩니다.

♻️ 제안하는 리팩토링
+private val BASE_SEGMENT_WIDTH = 89.dp
+private val BASE_SEGMENT_OFFSET = 67.dp
+
 @Composable
 fun CherrishGaugeBar(
     currentStep: Int,
     gauges: ImmutableList<CherrishGaugeType>,
     modifier: Modifier = Modifier
 ) {
     BoxWithConstraints(
         modifier = modifier.fillMaxWidth()
     ) {
-        val baseSegmentWidth = 89.dp
-        val baseSegmentOffset = 67.dp
+        val baseSegmentWidth = BASE_SEGMENT_WIDTH
+        val baseSegmentOffset = BASE_SEGMENT_OFFSET
         val totalBaseWidth = baseSegmentWidth + baseSegmentOffset * (gauges.size - 1)

40-42: recomposition 최적화 고려 (선택사항)

계산된 스케일 값들이 매 recomposition마다 재계산됩니다. gauges.sizemaxWidth가 변경되지 않는 경우가 많다면 remember로 메모이제이션을 고려할 수 있습니다.

♻️ 선택적 최적화 예시
+        val (segmentWidth, offsetWidth) = remember(maxWidth, gauges.size) {
             val screenScale = maxWidth / totalBaseWidth
-            val segmentWidth = baseSegmentWidth * screenScale
-            val offsetWidth = baseSegmentOffset * screenScale
+            Pair(
+                baseSegmentWidth * screenScale,
+                baseSegmentOffset * screenScale
+            )
+        }

46-46: 리스트 역순 처리 최적화 제안

asReversed()는 매번 새로운 리스트를 생성합니다. ImmutableList의 경우 역순 반복이 자주 필요하다면 성능에 영향을 줄 수 있습니다. 다만 게이지 개수가 적다면(일반적으로 4개) 큰 문제는 아닙니다.

더 효율적인 대안으로 인덱스 기반 역순 반복을 고려할 수 있습니다:

for (i in gauges.indices.reversed()) {
    val gauge = gauges[i]
    key(gauge) {
        // ...
    }
}

27-32: 공개 API 문서화 추가 권장

공통 컴포넌트로서 다른 팀원들이 사용할 public composable이므로 KDoc 문서를 추가하면 사용성이 크게 향상됩니다.

📝 제안하는 KDoc 예시
+/**
+ * 여러 단계의 게이지를 표시하는 게이지바 컴포넌트입니다.
+ * 
+ * @param currentStep 현재 활성화된 단계 (1부터 시작)
+ * @param gauges 표시할 게이지 목록 (ImmutableList로 제공되어야 함)
+ * @param modifier 이 컴포넌트에 적용할 Modifier
+ * 
+ * @sample Preview
+ */
 @Composable
 fun CherrishGaugeBar(
     currentStep: Int,
     gauges: ImmutableList<CherrishGaugeType>,
     modifier: Modifier = Modifier
 ) {
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5aeb1 and 1c8a46d.

📒 Files selected for processing (1)
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
🧰 Additional context used
📓 Path-based instructions (1)
**/*.kt

⚙️ CodeRabbit configuration file

**/*.kt: - Jetpack Compose 구조, 상태 관리, recomposition 최적화에 집중

  • ViewModel, UiState, 단방향 데이터 흐름 패턴 검토
  • 불필요한 recomposition 가능성, remember/derivedStateOf 적절한 사용 확인
  • 네이밍 컨벤션, 가독성, Google 권장 Android 아키텍처 준수 여부

Files:

  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
🧬 Code graph analysis (1)
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (1)
app/src/main/java/com/cherrish/android/core/designsystem/theme/Theme.kt (1)
  • CherrishTheme (38-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: PR Build Check
  • GitHub Check: PR Lint Check
🔇 Additional comments (2)
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (2)

27-97: PR 설명에서 언급하신 사항들에 대한 피드백

  1. 변수명: 전반적으로 명확합니다. 개선 제안:

    • screenScalewidthScaleFactor (스케일이 너비 기반임을 명확히)
    • offsetWidthsegmentOverlapOffset 또는 segmentSpacing (의도가 더 명확함)
  2. CherrishGaugeStyle 위치: gaugebar 패키지 내부에 두신 결정이 합리적입니다. 강하게 결합된 스타일 로직을 게이지바 근처에 두는 것이 응집도 측면에서 좋습니다.

전반적으로 Compose 구조가 잘 설계되었고 ImmutableList 사용, key() 활용 등 좋은 패턴을 따르고 있습니다. 위에서 언급한 검증 로직과 인덱싱 이슈만 개선하시면 프로덕션 준비 완료될 것 같습니다!


24-25: 의존성 및 Kotlin 버전 확인 완료

  • Line 106의 CherrishGaugeType.entries 사용은 프로젝트의 Kotlin 2.1.20 버전으로 완전히 지원됩니다.
  • Lines 24-25의 kotlinx.collections.immutable 라이브러리는 gradle/libs.versions.toml에서 버전 0.4.0으로 선언되어 있으며, app/build.gradle.kts의 kotlin-extensions 번들을 통해 올바르게 포함되어 있습니다.

Comment on lines +88 to +93
gauges.asReversed().forEachIndexed { i, gauge ->
val originalIndex = gauge.step - 1
val xOffsetPx = (offsetWidth.toPx() * originalIndex).toInt()

segmentPlaceables[i].placeRelative(x = xOffsetPx, y = 0)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

레이아웃 위치 계산 로직의 취약성

gauge.step - 1originalIndex로 사용하여 배치 위치를 계산하는 로직이 CherrishGaugeTypestep 값이 1부터 시작하고 연속적이라는 가정에 강하게 결합되어 있습니다. step 값이 변경되거나 순서가 바뀌면 레이아웃이 깨질 수 있습니다.

더 명확하고 안전한 접근:

  1. gauges 리스트의 원본 인덱스를 직접 사용하거나
  2. CherrishGaugeType에 명시적인 order 또는 index 속성 추가
✅ 제안하는 개선 방안
             layout(width = constraints.maxWidth, height = layoutHeight) {
-                gauges.asReversed().forEachIndexed { i, gauge ->
-                    val originalIndex = gauge.step - 1
+                gauges.forEachIndexed { originalIndex, gauge ->
+                    val reversedIndex = gauges.size - 1 - originalIndex
                     val xOffsetPx = (offsetWidth.toPx() * originalIndex).toInt()
 
-                    segmentPlaceables[i].placeRelative(x = xOffsetPx, y = 0)
+                    segmentPlaceables[reversedIndex].placeRelative(x = xOffsetPx, y = 0)
                 }
             }

이렇게 하면 step 값에 의존하지 않고 리스트의 실제 인덱스를 사용하여 배치합니다.

🤖 Prompt for AI Agents
In
@app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
around lines 88 - 93, The placement logic in CherrishGaugeBar.kt currently
computes originalIndex as gauge.step - 1 inside the
gauges.asReversed().forEachIndexed block, which assumes step is 1-based and
contiguous; change this to use the actual list index (or an explicit order/index
field on CherrishGaugeType) so layout doesn’t break if step values change or
reorder; locate the loop using gauges.asReversed().forEachIndexed and replace
usage of gauge.step - 1 with the correct list-derived index (or add and use a
dedicated order/index property on CherrishGaugeType) when computing xOffsetPx
for segmentPlaceables[i].placeRelative.

Copy link
Copy Markdown
Contributor

@nhyeonii nhyeonii left a comment

Choose a reason for hiding this comment

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

아니 앱잼 내 구현 너무 복잡할 것 같아 그냥 사진으로 넣으려고 햇는데 이걸 구현해내는 그녀는..... 진짜 최고!!!!!!! 또 한번 반햇다...... 🫰🫰 넘 머싯다 리뷰 한번만 확인해죠요 ~~ !!!

@sohee6989 sohee6989 requested a review from nhyeonii January 10, 2026 14:47
Copy link
Copy Markdown
Contributor

@usuuhyn usuuhyn left a comment

Choose a reason for hiding this comment

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

수고하셨습니다! 짱이다옹~ 😻👍

Copy link
Copy Markdown

@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: 3

🤖 Fix all issues with AI agents
In
@app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt:
- Around line 34-46: The calculation for totalBaseWidth uses (gauges.size - 1)
which breaks semantics when gauges is empty; guard against empty or zero-count
gauges before computing totalBaseWidth and screenScale. Change the computation
in CherrishGaugeBar: derive a safe count like val segmentCount = max(1,
gauges.size) or early-return/empty-state when gauges.isEmpty(), then compute
totalBaseWidth = baseSegmentWidth + baseSegmentOffset * (segmentCount - 1) and
continue using segmentWidth/offsetWidth; ensure remember(gauges) and
reversedGauges logic still runs correctly with the empty-case handling.
- Around line 49-60: In CherrishGaugeBar update the remember call that computes
gaugeStyle to include the theme colors so it invalidates on theme changes: the
current remember(gauge, isActive, isSelected) should also depend on
cherrishColor (CherrishTheme.colors) so gauge.style is recomputed when the theme
changes; adjust the remember key for the gaugeStyle variable (referencing
gaugeStyle, remember, cherrishColor, and gauge.style) accordingly.
- Around line 37-45: The current use of reversedGauges (remember(gauges) {
gauges.asReversed() }) flips draw order so lower steps are placed last and end
up on top; remove the reversed collection and iterate the original gauges (e.g.,
gauges.forEachIndexed { i, gauge -> ... }) to preserve z-order where higher
steps are drawn last, compute positions using gauge.step (or gauge.step - 1) and
the existing offsetWidth/segmentWidth math for placement, and eliminate
reversedGauges and its remember wrapper so z-order matches intended
right-to-left stacking.
🧹 Nitpick comments (3)
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeColors.kt (2)

7-10: CherrishGaugeColors는 Compose 최적화를 위해 @Immutable(또는 @Stable) 고려

UI 레이어에서 빈번히 전달/비교될 가능성이 높아서, 안정성 어노테이션을 붙이면 불필요한 recomposition 판단에 도움이 됩니다. (팀 내 어노테이션 컨벤션이 없다면 스킵해도 무방)


12-36: 색상 매핑 API는 깔끔함(단, 확장성 위해 KDoc/의도 주석 정도만 있으면 더 좋음)

when (gaugeType)가 exhaustive라 레벨 추가 시 컴파일 타임에 깨지는 구조도 좋습니다.

Also applies to: 38-43

app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (1)

113-133: Preview는 간단히 간격만 주면 가독성 좋아짐(선택)

제안 diff
-        Column {
+        Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
             CherrishGaugeBar(
                 currentStep = 1,
                 gauges = CherrishGaugeType.entries.toImmutableList()
             )
@@
         }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c8a46d and 2a0aa19.

📒 Files selected for processing (3)
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeColors.kt
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeStyle.kt
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeStyle.kt
🧰 Additional context used
📓 Path-based instructions (1)
**/*.kt

⚙️ CodeRabbit configuration file

**/*.kt: - Jetpack Compose 구조, 상태 관리, recomposition 최적화에 집중

  • ViewModel, UiState, 단방향 데이터 흐름 패턴 검토
  • 불필요한 recomposition 가능성, remember/derivedStateOf 적절한 사용 확인
  • 네이밍 컨벤션, 가독성, Google 권장 Android 아키텍처 준수 여부

Files:

  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeColors.kt
  • app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
🧬 Code graph analysis (1)
app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt (1)
app/src/main/java/com/cherrish/android/core/designsystem/theme/Theme.kt (1)
  • CherrishTheme (38-61)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: PR Lint Check
  • GitHub Check: PR Build Check

Comment on lines +34 to +46
BoxWithConstraints(
modifier = modifier.fillMaxWidth()
) {
val reversedGauges = remember(gauges) { gauges.asReversed() }

val baseSegmentWidth = 89.dp
val baseSegmentOffset = 67.dp
val totalBaseWidth = baseSegmentWidth + baseSegmentOffset * (gauges.size - 1)

val screenScale = maxWidth / totalBaseWidth
val segmentWidth = baseSegmentWidth * screenScale
val offsetWidth = baseSegmentOffset * screenScale

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

gauges.size - 1 계산은 빈 리스트에서 의미가 깨짐(가드 추천)

gauges가 비었을 때 totalBaseWidth가 “기준 디자인”과 다른 값이 되고, scale 계산도 의도와 달라질 수 있습니다(현재는 크래시까진 안 나도 예측 불가).

제안 diff
-        val totalBaseWidth = baseSegmentWidth + baseSegmentOffset * (gauges.size - 1)
+        val segmentCount = gauges.size.coerceAtLeast(1)
+        val totalBaseWidth = baseSegmentWidth + baseSegmentOffset * (segmentCount - 1)
🤖 Prompt for AI Agents
In
@app/src/main/java/com/cherrish/android/core/designsystem/component/gaugebar/CherrishGaugeBar.kt
around lines 34 - 46, The calculation for totalBaseWidth uses (gauges.size - 1)
which breaks semantics when gauges is empty; guard against empty or zero-count
gauges before computing totalBaseWidth and screenScale. Change the computation
in CherrishGaugeBar: derive a safe count like val segmentCount = max(1,
gauges.size) or early-return/empty-state when gauges.isEmpty(), then compute
totalBaseWidth = baseSegmentWidth + baseSegmentOffset * (segmentCount - 1) and
continue using segmentWidth/offsetWidth; ensure remember(gauges) and
reversedGauges logic still runs correctly with the empty-case handling.

Copy link
Copy Markdown
Contributor

@nhyeonii nhyeonii left a comment

Choose a reason for hiding this comment

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

LGTM ~~ 🚀🚀🚀🚀 넘 고생햇슈 !!

Copy link
Copy Markdown
Contributor

@hyeminililo hyeminililo left a comment

Choose a reason for hiding this comment

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

코드가 완벽해여,,,!1 수고하셨습니당 !!

@sohee6989 sohee6989 merged commit aa9b226 into develop Jan 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

FEAT✨ 새로운 기능 구현 소희🍒 소희 담당

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] 게이지바 컴포넌트 구현

4 participants