Skip to content

[Feature/#5] Add CurveEffect for customizable TimePicker Styling#6

Merged
DongChyeon merged 7 commits intomainfrom
feat/#5-pickeritem-custom-transform
Jul 4, 2025
Merged

[Feature/#5] Add CurveEffect for customizable TimePicker Styling#6
DongChyeon merged 7 commits intomainfrom
feat/#5-pickeritem-custom-transform

Conversation

@DongChyeon
Copy link
Copy Markdown
Owner

@DongChyeon DongChyeon commented Jul 4, 2025

🎯 Related Issue


📝 Description

What does this PR do?

Introduces PickerStyle and CurveEffect classes to organize and simplify the growing number of TimePicker parameters, while enabling advanced customization of item styling and scroll effects.


✅ Changes

  • Define PickerStyle class for managing text style, color, and item spacing.
  • Define CurveEffect class to configure alpha fading and vertical scaling of picker items.
  • Add TimePickerDefaults.curveEffect() for convenient default configuration.
  • Refactor TimePicker and PickerItem to accept PickerStyle and CurveEffect.
  • Clean up parameter ordering in Composable functions to follow Compose conventions.

🔍 Screenshots / Test Results (if applicable)

image

👤 Reviewer Checklist

N/A

@DongChyeon DongChyeon requested a review from Copilot July 4, 2025 07:59
@DongChyeon DongChyeon self-assigned this Jul 4, 2025
@DongChyeon DongChyeon added the enhancement New feature or request label Jul 4, 2025
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 PR introduces structured styling and scroll effects for the TimePicker by extracting text style, spacing, and alpha/scale logic into PickerStyle and CurveEffect classes, and refactors existing pickers to use these new abstractions.

  • Added PickerStyle and CurveEffect data classes and default factories.
  • Refactored PickerItem to delegate alpha/scale calculations to CurveEffect.
  • Updated TimePicker composables to accept style and curveEffect parameters and cleaned up nested layouts.

Reviewed Changes

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

File Description
PickerItem.kt Replaced raw style parameters with PickerStyle and CurveEffect calls
TimePickerDefaults.kt Added pickerStyle() and curveEffect() defaults and new data classes
TimePicker.kt Updated composable signatures to include style and curveEffect; refactored nested layouts
Comments suppressed due to low confidence (1)

timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt:75

  • Add unit tests for calculateAlpha and calculateScaleY to ensure the interpolation logic produces expected values across the full range of inputs.
    fun calculateAlpha(distanceFromCenter: Float, maxDistance: Float): Float {

This comment was marked as outdated.

@DongChyeon DongChyeon requested a review from Copilot July 4, 2025 08:18

This comment was marked as outdated.

@DongChyeon DongChyeon force-pushed the feat/#5-pickeritem-custom-transform branch from 33c86a1 to 63684d0 Compare July 4, 2025 08:27
@DongChyeon DongChyeon requested a review from Copilot July 4, 2025 08:47
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 PR abstracts TimePicker styling into PickerStyle and scrolling effects into CurveEffect, refactors composables to consume these new types, and provides default factories.

  • Introduce PickerStyle for text style, color, and item spacing.
  • Introduce CurveEffect to encapsulate alpha & scale interpolation logic.
  • Refactor TimePicker, TimePicker12Hour, TimePicker24Hour, and PickerItem to use the new types and extract SelectorBackground.
  • Add default providers in TimePickerDefaults.

Reviewed Changes

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

File Description
timepicker/src/main/java/com/dongchyeon/timepicker/ui/PickerItem.kt Use style.itemSpacing and delegate alpha/scale to CurveEffect methods.
timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt Add pickerStyle & curveEffect factories; convert style/helper classes to data classes.
timepicker/src/main/java/com/dongchyeon/timepicker/TimePicker.kt Wire style & curveEffect through pickers; extract SelectorBackground.
Comments suppressed due to low confidence (4)

timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt:74

  • Consider adding unit tests for calculateAlpha (and calculateScaleY) to verify the interpolation formula across edge cases (e.g., distanceFromCenter == 0 and distanceFromCenter == maxDistance).
    fun calculateAlpha(distanceFromCenter: Float, maxDistance: Float): Float {

timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt:16

  • Missing import for MaterialTheme. Please add import androidx.compose.material3.MaterialTheme to resolve compilation errors in pickerStyle.
        textStyle: TextStyle = MaterialTheme.typography.titleMedium,

timepicker/src/main/java/com/dongchyeon/timepicker/TimePicker.kt:108

  • The root Box no longer calls fillMaxWidth(), which may shrink the picker layout when modifier is default. Consider restoring .fillMaxWidth() on this Box to maintain full-width layout.
        modifier = modifier,

timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt:61

  • Add @Immutable annotation to PickerStyle so Compose can optimize recompositions when style values are used as parameters.
data class PickerStyle(

@DongChyeon DongChyeon merged commit 8df16d3 into main Jul 4, 2025
2 checks passed
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 - Allow customizing PickerItem alpha and scaleY

2 participants