feat: 햅틱 적용#878
Conversation
둘러보기RatingRangeSlider 컴포넌트에 드래그 제스처 중 햅틱 피드백을 추가했습니다. LocalView를 통해 뷰에 접근하고, 각 엄지손가락의 마지막 스냅 값을 추적한 후, 스냅 값이 변경될 때만 CLOCK_TICK 피드백을 트리거합니다. 변경 사항별점 슬라이더 햅틱 피드백
🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/src/main/java/com/into/websoso/ui/detailExplore/component/RatingRangeSlider.kt (1)
111-116: 💤 Low value중복 계산 제거를 고려하세요.
스냅된 값이 두 번 계산됩니다(햅틱 체크용,
onValueChange호출용). 변수에 저장하여 재사용하면 코드가 더 명확해집니다.♻️ 리팩토링 제안
onDrag = { change, _ -> change.consume() val newValue = valueAtX(change.position.x) if (activeThumb == 1) { val snapped = newValue.coerceAtMost(latestMax) if (snapped != lastMinSnapped) { view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK) lastMinSnapped = snapped } - onValueChange(newValue.coerceAtMost(latestMax), latestMax) + onValueChange(snapped, latestMax) } else { val snapped = newValue.coerceAtLeast(latestMin) if (snapped != lastMaxSnapped) { view.performHapticFeedback(HapticFeedbackConstants.CLOCK_TICK) lastMaxSnapped = snapped } - onValueChange(latestMin, newValue.coerceAtLeast(latestMin)) + onValueChange(latestMin, snapped) } },Also applies to: 118-123
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/src/main/java/com/into/websoso/ui/detailExplore/component/RatingRangeSlider.kt` around lines 111 - 116, Avoid computing the snapped value twice: compute snapped = newValue.coerceAtMost(latestMax) once, reuse that variable for the haptic check (compare with lastMinSnapped and call view.performHapticFeedback) and pass the same snapped to onValueChange instead of recomputing; update lastMinSnapped when needed. Apply the same change to the analogous block that references lastMaxSnapped/onValueChange for lines 118-123.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@app/src/main/java/com/into/websoso/ui/detailExplore/component/RatingRangeSlider.kt`:
- Around line 68-70: The haptic false-positive occurs because
lastMinSnapped/lastMaxSnapped retain previous values across external prop
updates; update onDragStart in RatingRangeSlider to reset lastMinSnapped = min
and lastMaxSnapped = max (use the current min/max props) so the first onDrag
compares against the current positions and only triggers haptics when a real
snap crossing occurs.
---
Nitpick comments:
In
`@app/src/main/java/com/into/websoso/ui/detailExplore/component/RatingRangeSlider.kt`:
- Around line 111-116: Avoid computing the snapped value twice: compute snapped
= newValue.coerceAtMost(latestMax) once, reuse that variable for the haptic
check (compare with lastMinSnapped and call view.performHapticFeedback) and pass
the same snapped to onValueChange instead of recomputing; update lastMinSnapped
when needed. Apply the same change to the analogous block that references
lastMaxSnapped/onValueChange for lines 118-123.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c26e2b85-42d1-45f7-999b-4be9bfdfdb5c
📒 Files selected for processing (1)
app/src/main/java/com/into/websoso/ui/detailExplore/component/RatingRangeSlider.kt
| val view = LocalView.current | ||
| var lastMinSnapped by remember { mutableFloatStateOf(min) } | ||
| var lastMaxSnapped by remember { mutableFloatStateOf(max) } |
There was a problem hiding this comment.
onDragStart에서 마지막 스냅 상태를 초기화해야 합니다.
드래그 시작 시 lastMinSnapped/lastMaxSnapped를 초기화하지 않아 다음 시나리오에서 잘못된 햅틱이 트리거됩니다:
- 사용자가 min thumb을 3.0으로 드래그 후 릴리스 (
lastMinSnapped = 3.0) - 외부 상태 변경으로
minprop이 1.0으로 업데이트 (lastMinSnapped는 여전히 3.0) - 사용자가 1.0 위치에서 새 드래그 시작
- 첫 번째
onDrag이벤트에서snapped = 1.0이고1.0 != 3.0이므로 햅틱 트리거 - 문제: 실제로 스냅 포인트를 넘지 않았는데도 햅틱이 발생
햅틱은 드래그 중 스냅 포인트를 실제로 넘을 때만 트리거되어야 합니다.
🔧 수정 제안
onDragStart에서 현재 위치로 상태를 초기화하세요:
onDragStart = { offset ->
val touchX = offset.x
activeThumb =
if ((touchX - latestStartCenter).absoluteValue <=
(touchX - latestEndCenter).absoluteValue
) {
1
} else {
2
}
val newValue = valueAtX(touchX)
if (activeThumb == 1) {
- onValueChange(newValue.coerceAtMost(latestMax), latestMax)
+ val snapped = newValue.coerceAtMost(latestMax)
+ lastMinSnapped = snapped
+ onValueChange(snapped, latestMax)
} else {
- onValueChange(latestMin, newValue.coerceAtLeast(latestMin))
+ val snapped = newValue.coerceAtLeast(latestMin)
+ lastMaxSnapped = snapped
+ onValueChange(latestMin, snapped)
}
},🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@app/src/main/java/com/into/websoso/ui/detailExplore/component/RatingRangeSlider.kt`
around lines 68 - 70, The haptic false-positive occurs because
lastMinSnapped/lastMaxSnapped retain previous values across external prop
updates; update onDragStart in RatingRangeSlider to reset lastMinSnapped = min
and lastMaxSnapped = max (use the current min/max props) so the first onDrag
compares against the current positions and only triggers haptics when a real
snap crossing occurs.
📌𝘐𝘴𝘴𝘶𝘦𝘴
📎𝘞𝘰𝘳𝘬 𝘋𝘦𝘴𝘤𝘳𝘪𝘱𝘵𝘪𝘰𝘯
📷𝘚𝘤𝘳𝘦𝘦𝘯𝘴𝘩𝘰𝘵
💬𝘛𝘰 𝘙𝘦𝘷𝘪𝘦𝘸𝘦𝘳𝘴
별점 슬라이더에 햅틱 추가했습니다. 딱히 강도에 대한 이야기는 없어서 가장 대중적으로 사용되는 거 같은 햅틱으로 넣었습니다.
Summary by CodeRabbit