Skip to content

feat(DotsIndicator): per-dot color API for classic View indicator - #227

Open
tbuonomo-agnt wants to merge 4 commits into
masterfrom
feat/per-dot-colors-193
Open

feat(DotsIndicator): per-dot color API for classic View indicator#227
tbuonomo-agnt wants to merge 4 commits into
masterfrom
feat/per-dot-colors-193

Conversation

@tbuonomo-agnt

Copy link
Copy Markdown
Collaborator

Summary

Adds first-class per-dot color support to the classic View-based DotsIndicator, addressing the long-standing request in #193.

What's new

// Each dot selected in its own accent color
dotsIndicator.selectedDotColors = intArrayOf(
    Color.parseColor("#FF5252"), // dot 0
    Color.parseColor("#FF6D00"), // dot 1
    Color.parseColor("#FFD600"), // dot 2
    Color.parseColor("#69F0AE"), // dot 3
    Color.parseColor("#40C4FF"), // dot 4
)

// Optional: custom unselected colors per dot
dotsIndicator.dotColors = intArrayOf(...)

Java-friendly setters:

dotsIndicator.setSelectedDotColors(new int[]{Color.RED, Color.GREEN, Color.BLUE});
dotsIndicator.setDotColors(new int[]{Color.LTGRAY, Color.LTGRAY, Color.LTGRAY});

API design

  • selectedDotColors: IntArray? — per-index selected colors, falls back to global selectedDotColor for out-of-range or null
  • dotColors: IntArray? — per-index unselected colors, falls back to global dotsColor
  • resolveColor(colors, index, fallback) static helper (@JvmStatic, pure, no Android context required)
  • Wired into addDot, refreshDotColor and the onPageScrolled color-interpolation path (per-index endpoints)
  • 100% backward-compatible: null (default) restores current behaviour

Scope

Classic DotsIndicator (View-based) only. SpringDotsIndicator, WormDotsIndicator and Compose indicators are intentionally unchanged.

Tests

  • 18 pure-JVM unit tests (DotsIndicatorColorTest) — resolveColor boundary cases, partial arrays, selected/unselected independence
  • 12 Robolectric view tests (DotsIndicatorViewRenderTest) — assert actual GradientDrawable colors set on dots; covers global, per-index, partial, runtime refresh scenarios
  • 4 screenshot golden scenarios for visual pin

All tests pass locally (./gradlew :viewpagerdotsindicator:testDebugUnitTest — BUILD SUCCESSFUL).

Follow-up (separate PR)

  • Stabilise Roborazzi screenshot pipeline for View-based indicator goldens (dots_view_*.png)
  • Consider Spring/Worm/Compose parity if demand grows

Closes #193

Closes #193

## What changed
- Add `selectedDotColors: IntArray?` — per-index selected color, falls
  back to global `selectedDotColor` for out-of-range indices
- Add `dotColors: IntArray?` — per-index unselected color, falls back
  to global `dotsColor` for out-of-range indices
- Add `resolveColor(colors, index, fallback)` static helper (pure,
  JVM-safe, Java-callable via @JvmStatic)
- Wire per-index resolution into addDot, refreshDotColor and the
  onPageScrolled color-interpolation path

## Scope
Classic `DotsIndicator` (View-based) only. Spring, Worm and Compose
indicators are intentionally unchanged in this PR.

## Tests
- DotsIndicatorColorTest — 18 pure-JVM unit tests for resolveColor
  fallback, partial arrays, independence of selected/unselected paths
- DotsIndicatorViewRenderTest — 12 Robolectric tests verifying color
  values on GradientDrawable + 4 screenshot golden scenarios

## Docs & sample
- README: Kotlin + Java usage examples
- Sample app: per-dot rainbow demo on the classic ViewPager fragment
The per-dot color feature doesn't touch Spring/Worm/Compose rendering
paths, but Roborazzi regenerated all goldens when running
recordRoborazziDebug (minor PNG re-encoding differences).

Commit updated goldens so verifyRoborazziDebug stays green on CI.

Note: goldens for the new DotsIndicatorViewRenderTest screenshot tests
(dots_view_*.png) will be committed in the follow-up PR that stabilises
the Roborazzi pipeline for View-based indicator screenshots.
…issue_comments

- .claude/settings.json grants Read/Edit/Write/Bash permissions needed
  for agent-driven development in this repo
- .gitignore: add .tmp_issue_comments/ to ignored paths
…iew-goldens

chore: stabilise Roborazzi screenshot pipeline for View-based indicator goldens
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.

Changing dots color individually

2 participants