Skip to content

onStart/onFinish gesture callbacks, gesture type, new Sliders#159

Closed
Azerlag wants to merge 13 commits intoskydoves:mainfrom
Azerlag:clean-up-before-PR
Closed

onStart/onFinish gesture callbacks, gesture type, new Sliders#159
Azerlag wants to merge 13 commits intoskydoves:mainfrom
Azerlag:clean-up-before-PR

Conversation

@Azerlag
Copy link
Copy Markdown

@Azerlag Azerlag commented Apr 26, 2026

Hi! For my project I needed to add new callbacks to the UI elements, so I forked the repo and made my own changes. Increase lib version please, I did not do that.

Compose components build successfully (only tested for AndroidRelease), artifacts are on jitpack: https://jitpack.io/#azerlag/colorpicker-compose

Thanks.

🎯 Goal

Add onStart/onFinish gesture callbacks to all interactive components,
introduce ColorChangeSource to ColorEnvelope, and add two new slider
components: HueSlider and SaturationSlider.

🛠 Implementation details

ColorChangeSource enum added to ColorEnvelope with three values:

  • Tap — color changed via tap gesture
  • Drag — color changed via drag gesture
  • Programmatic — fallback for programmatic changes (e.g. initial setup)

The source is passed through the entire chain: gesture → controller →
notifyColorChangedColorEnvelope.

onStart / onFinish lambdas added to HsvColorPicker, AlphaSlider, BrightnessSlider and other. Implemented via detectTapGestures(onPress) and detectDragGestures(onDragStart, onDragEnd, onDragCancel).

HueSlider and SaturationSlider follow the same architecture as
AlphaSlider and BrightnessSlider. Controller gains hue, saturation
state fields, setHue/setSaturation methods, and isAttachedHueSlider/
isAttachedSaturationSlider flags. applyHSVFactors is updated accordingly.

✍️ Explain examples

HsvColorPicker(
    modifier = Modifier.size(200.dp),
    controller = controller,
    onColorChanged = { envelope ->
        when (envelope.source) {
            ColorChangeSource.Tap -> onTimeSendColor(envelope.color)
            ColorChangeSource.Drag -> sendingColor(envelope.color)
            ColorChangeSource.Programmatic -> Unit
        }
    },
    onStart = { /* user touched the picker */ },
    onFinish = { /* user lifted finger */ },
)

HueSlider(
    modifier = Modifier.fillMaxWidth().height(32.dp),
    controller = controller,
)

SaturationSlider(
    modifier = Modifier.fillMaxWidth().height(32.dp),
    controller = controller,
)
Screenshot_20260426_015723

@Azerlag Azerlag requested a review from skydoves as a code owner April 26, 2026 00:05
@Azerlag Azerlag changed the title Clean up before pr onStart/onFinish gesture callbacks, gesture source, new Sliders Apr 26, 2026
@Azerlag Azerlag changed the title onStart/onFinish gesture callbacks, gesture source, new Sliders onStart/onFinish gesture callbacks, gesture type, new Sliders Apr 26, 2026
@Azerlag Azerlag closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant