Skip to content

feat: Add clickable functionality to Picker items and set visibleItem…#19

Merged
kez-lab merged 3 commits intomainfrom
feature/picker_click_animation
Nov 12, 2025
Merged

feat: Add clickable functionality to Picker items and set visibleItem…#19
kez-lab merged 3 commits intomainfrom
feature/picker_click_animation

Conversation

@kez-lab
Copy link
Copy Markdown
Owner

@kez-lab kez-lab commented Nov 12, 2025

close #18

This pull request enhances the Picker component in the datetimepicker module by making picker items clickable, allowing users to jump directly to a selected item. It also updates the sample screen to display more visible items in the time picker. The most important changes are grouped below:

Picker component improvements:

  • Added a Modifier.clickable to each picker item in Picker.kt, enabling users to click on an item to animate-scroll it into the selected position. This uses a coroutine scope to perform the scroll and improves accessibility by setting the role to Button.
  • Introduced rememberCoroutineScope to manage the coroutine for animated scrolling when an item is clicked.
  • Added necessary imports for click handling, interaction source, coroutine launching, and accessibility roles. [1] [2] [3]

Sample screen update:

  • Updated the TimePickerSampleScreen to set visibleItemsCount = 5, making the picker show five items at a time for improved usability and demonstration.

Code cleanup:

  • Removed unused navigation imports from the sample screen for tidiness.…sCount in TimePicker

ScreenShot

Screen_recording_20251112_212042.mp4

Summary by CodeRabbit

  • New Features
    • Picker items are now interactive and clickable, letting users tap items to navigate directly with smooth animated scrolling.
    • Enhanced accessibility with button role designation and visual feedback during interactions.
    • Sample 24-hour TimePicker now displays more items at once (visible items increased) for improved scanning.

@kez-lab kez-lab requested a review from Copilot November 12, 2025 12:32
@kez-lab kez-lab self-assigned this Nov 12, 2025
@kez-lab kez-lab added the enhancement New feature or request label Nov 12, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 12, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Picker items are now clickable: clicking a visible item computes its target index and, if not centered, launches a coroutine to animate scrolling the list to center that item. The sample screen call to TimePicker adds visibleItemsCount = 5 and removes unused nav imports.

Changes

Cohort / File(s) Summary
Picker click interaction
datetimepicker/src/commonMain/kotlin/com/kez/picker/Picker.kt
Adds clickable modifier to item containers, uses MutableInteractionSource and Role.Button, captures rememberCoroutineScope, and on click computes center index and calls listState.animateScrollToItem(targetIndex) in a launched coroutine when the clicked item is not centered. Adds required imports.
Sample usage update
sample/src/commonMain/kotlin/com/kez/picker/sample/ui/screen/TimePickerSampleScreen.kt
Removes unused NavController/rememberNavController imports and sets visibleItemsCount = 5 for the 24-hour TimePicker call.

Sequence Diagram

sequenceDiagram
    actor User
    participant Item as Picker Item
    participant Picker as Picker Composable
    participant Coroutine as CoroutineScope
    participant ListState as LazyListState

    User->>Item: Click
    Item->>Picker: onClick(targetIndex)
    Picker->>Picker: compute centerIndex
    alt targetIndex != centerIndex
        Picker->>Coroutine: launch { animateScrollToItem(targetIndex) }
        Coroutine->>ListState: animateScrollToItem(targetIndex)
        ListState-->>Coroutine: animation progress
        Coroutine-->>User: item reaches center
    else targetIndex == centerIndex
        Picker-->>User: no-op
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

  • Check coroutine scope usage and cancellation behavior.
  • Verify correctness of center-index computation and boundary cases.
  • Confirm accessibility role and interactionSource behave correctly across input methods.
  • Validate animation interplay with existing fling/scroll gestures.

Poem

🐰 A hop, a click, a gentle glide,
I nudge the list and watch it slide.
Center found with bunny cheer,
Smooth and ready — jump in here! ✨

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding clickable functionality to Picker items and setting visibleItemsCount, which matches the primary objectives.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from issue #18: clickable item handling with animateScrollToItem animation [#18], preserved scroll/fling compatibility, and accessibility support via Button role.
Out of Scope Changes check ✅ Passed All changes are directly related to the linked issue objectives. The Picker clickable implementation, visibleItemsCount parameter addition, and unused import cleanup are all within scope.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/picker_click_animation

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

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances the Picker component by adding clickable functionality to individual picker items, allowing users to tap on any visible item to animate-scroll it to the selected position. The changes also update the sample screen to demonstrate 5 visible items in the time picker.

Key Changes:

  • Added click handling to Picker items with animated scrolling using coroutines
  • Implemented proper accessibility with Role.Button and interaction sources
  • Updated sample screen to display 5 visible items in the 24-hour time picker
  • Removed unused navigation imports from the sample screen

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
datetimepicker/src/commonMain/kotlin/com/kez/picker/Picker.kt Added clickable modifier to picker items with coroutine-based animated scrolling, accessibility role, and necessary imports
sample/src/commonMain/kotlin/com/kez/picker/sample/ui/screen/TimePickerSampleScreen.kt Removed unused navigation imports and set visibleItemsCount = 5 for the 24-hour time picker

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI commented Nov 12, 2025

@kez-lab I've opened a new pull request, #20, to work on those changes. Once the pull request is ready, I'll request review from you.

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: 0

🧹 Nitpick comments (1)
datetimepicker/src/commonMain/kotlin/com/kez/picker/Picker.kt (1)

214-229: Well-implemented click-to-select feature!

The clickable implementation correctly addresses the previous review concern by disabling clicks on null padding items with enabled = getItem(index) != null. The index calculation logic is sound:

  • Calculates the target scroll position to center the clicked item
  • Properly coerces bounds for both infinite and bounded modes
  • Skips animation when clicking the already-centered item

The accessibility role and coroutine usage are appropriate.

Optional: Consider adding visual click feedback.

The code sets indication = null, which removes the default ripple effect. While the scroll animation itself provides feedback, adding a subtle indication could improve the user experience, especially on devices where the animation might be quick or subtle:

 .clickable(
     enabled = getItem(index) != null,
     role = Role.Button,
-    indication = null,
+    indication = rememberRipple(),
     interactionSource = remember { MutableInteractionSource() },
     onClick = { ... }
 )

If the current design intentionally avoids visual feedback, this can be ignored.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8134170 and 5f0fb4f.

📒 Files selected for processing (1)
  • datetimepicker/src/commonMain/kotlin/com/kez/picker/Picker.kt (5 hunks)
🔇 Additional comments (2)
datetimepicker/src/commonMain/kotlin/com/kez/picker/Picker.kt (2)

4-4: LGTM! Necessary imports for clickable functionality.

All imports are appropriate for implementing the click-to-select feature. Each import serves a clear purpose in the implementation.

Also applies to: 6-6, 25-25, 30-30, 49-49


101-101: LGTM! Correct coroutine scope pattern.

Using rememberCoroutineScope() is the appropriate way to launch coroutines from a composable function. The scope will be automatically cancelled when the composition leaves the tree.

@kez-lab kez-lab merged commit 33afdc4 into main Nov 12, 2025
@kez-lab kez-lab review requested due to automatic review settings March 23, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Picker 에서 클릭으로 아이템 선택 기능 추가

3 participants