[Feature/#5] Add CurveEffect for customizable TimePicker Styling#6
[Feature/#5] Add CurveEffect for customizable TimePicker Styling#6DongChyeon merged 7 commits intomainfrom
Conversation
…or consistent styling
There was a problem hiding this comment.
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
PickerStyleandCurveEffectdata classes and default factories. - Refactored
PickerItemto delegate alpha/scale calculations toCurveEffect. - Updated
TimePickercomposables to acceptstyleandcurveEffectparameters 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
calculateAlphaandcalculateScaleYto ensure the interpolation logic produces expected values across the full range of inputs.
fun calculateAlpha(distanceFromCenter: Float, maxDistance: Float): Float {
timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt
Show resolved
Hide resolved
timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt
Show resolved
Hide resolved
timepicker/src/main/java/com/dongchyeon/timepicker/TimePickerDefaults.kt
Outdated
Show resolved
Hide resolved
…nd scale with hour/minute pickers
…or performance optimization
33c86a1 to
63684d0
Compare
There was a problem hiding this comment.
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
PickerStylefor text style, color, and item spacing. - Introduce
CurveEffectto encapsulate alpha & scale interpolation logic. - Refactor
TimePicker,TimePicker12Hour,TimePicker24Hour, andPickerItemto use the new types and extractSelectorBackground. - 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(andcalculateScaleY) to verify the interpolation formula across edge cases (e.g.,distanceFromCenter == 0anddistanceFromCenter == 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.MaterialThemeto resolve compilation errors inpickerStyle.
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 whenmodifieris 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
@Immutableannotation toPickerStyleso Compose can optimize recompositions when style values are used as parameters.
data class PickerStyle(
🎯 Related Issue
📝 Description
What does this PR do?
✅ Changes
PickerStyleclass for managing text style, color, and item spacing.CurveEffectclass to configure alpha fading and vertical scaling of picker items.TimePickerDefaults.curveEffect()for convenient default configuration.TimePickerandPickerItemto acceptPickerStyleandCurveEffect.🔍 Screenshots / Test Results (if applicable)
👤 Reviewer Checklist
N/A