Skip to content

Settle the Material components' 2.0 shape: scoped thumbs, dimensions and nullable parts - #356

Merged
smelfungus merged 4 commits into
masterfrom
material-reshape
Sep 26, 2026
Merged

smelfungus merged 4 commits into
masterfrom
material-reshape

Conversation

@smelfungus

Copy link
Copy Markdown
Member

Several of the Material components' signatures could not change after 2.0 without breaking callers: data classes for the theme, thumb slots that saw only an InteractionSource, one parameter per size, showAlpha beside a slot that could not be removed, and ImmutableList in a signature. This settles them over the Basic components from #355.

Theme

  • ColorPickerColors, ColorPickerShapes and ColorPickerDimensions are final @Immutable classes with copy, equals, hashCode and toString, so a field can be added later. copy keeps a color or size left Unspecified and a shape left null, and ColorPickerDefaults.colors(), shapes() and dimensions() build through it, so naming one value keeps the scheme's others.
  • LocalColorPickerColors, LocalColorPickerShapes and LocalColorPickerDimensions are internal; ColorPickerDefaults.currentColors(), currentShapes() and currentDimensions() read them.

Sliders and planes

  • thumb reads its component's scope: thumb = { MyThumb(interactionSource, thumbColor) }. The default is ColorPickerDefaults.SliderThumb or PlaneThumb, both public.
  • dimensions replaces thumbWidth, thumbTrackGap and ColorSlider's trackHeight.
  • ColorSlider takes trackColors: List<Color>, and kotlinx-collections-immutable is no longer a dependency.

Pickers and the dialog

  • plane = null and alphaSlider = null leave those parts out, replacing showPlane and showAlpha, and the plane slot is handed its axes.
  • Every picker takes orientation, where Orientation.Horizontal puts the plane beside the sliders, and dimensions.
  • The slots default to ColorPickerDefaults.plane(), channelSlider() and alphaSlider(), which a caller can wrap.

The README, the docs page, the CHANGELOG and the migration table follow. A new screenshot preview shows the horizontal picker; the 27 existing baselines validate unchanged.

Tests: colorpicker 365 JVM, 126 Android host, 126 wasm; color 216, 206, 206; color-compose 14, 14, 14. apiCheck, the iOS klib compile, the Android sample and the 28 screenshot previews pass.

As data classes, ColorPickerColors, ColorPickerShapes and ColorPickerDimensions could not gain a field after 2.0 without breaking componentN and copy for every caller compiled against them. They are final classes with a hand-written copy, which keeps a color or size left Unspecified and a shape left null, as Material's own classes do, and the defaults factories build through it so a call naming one value keeps the rest. The composition locals were public only to be read, which ColorPickerDefaults.current*() already does, so they leave the API.
A thumb handed only an InteractionSource could not see its slider's position, whether it was enabled or the color under it, so a custom thumb had to be fed them from outside, and a thumb over a translucent color had to make it opaque itself. Every slider and plane now passes its scope to its thumb, and its default is the library's own thumb, public as ColorPickerDefaults.SliderThumb and PlaneThumb. Sizes come in one dimensions parameter in place of thumbWidth, thumbTrackGap and ColorSlider's trackHeight, and ColorSlider takes a plain List of track colors, so kotlinx-collections-immutable leaves the dependencies.
showAlpha and a slot that could not be removed made two ways to say one thing, and left a picker's default slots built by internal functions its own default expressions called. The pickers and the dialog take null for a plane or alpha slider they should not draw, hand the plane its axes, and default their slots to ColorPickerDefaults.plane(), channelSlider() and alphaSlider(), which a caller can wrap. Every picker takes the orientation BasicColorPicker lays out and the dimensions its sliders and plane use; a new preview shows a horizontal picker, and the 27 existing baselines validate unchanged.
The README still showed showAlpha, thumb lambdas handed an InteractionSource and thumbWidth, none of which compile any more. It shows alphaSlider = null, the horizontal picker, a thumb reading its scope and dimensions copied from the theme, and the migration table maps each removed parameter to its replacement.
@smelfungus
smelfungus merged commit 2417f41 into master Sep 26, 2026
2 checks passed
@smelfungus
smelfungus deleted the material-reshape branch September 26, 2026 15:06
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