Skip to content

Implement Compose graphics resolvers (Color, ColorStrategy, SolidColor) #81

Description

@MessiasLima

Description

Add ColorResolver and SolidColorResolver for androidx.compose.ui.graphics.Color and androidx.compose.ui.graphics.SolidColor, plus ColorStrategy to control color generation mode. All live in dev.appoutlet.some.android.

  • Scope and constraints

    • ColorStrategy is a sealed interface extending Strategy with variants: RandomArgb (default), RandomHsl, Palette (with a fixed color list). It lives in dev.appoutlet.some.android.strategy.
    • ColorResolver generates Color(red, green, blue, alpha) with randomized components when using RandomArgb; uses HSL conversion for RandomHsl; picks from the configured palette for Palette. Constructor receives strategyProvider: StrategyProvider and random: Random. It lives in dev.appoutlet.some.android.resolver.compose.
    • The resolver fetches the strategy once in init: strategyProvider.get<ColorStrategy>() ?: ColorStrategy.default.
    • SolidColorResolver creates SolidColor(color) by delegating to the chain to resolve a Color first. Constructor receives random: Random only. It lives in dev.appoutlet.some.android.resolver.compose.
    • Both canResolve() use exact type matching via typeOf<T>().
    • Each resolver has its own JVM unit test class. ColorResolver tests verify each strategy variant. SolidColorResolver tests verify it produces a SolidColor wrapping a non-null Color.
    • Depends on androidx.compose.ui:ui (transitively provides ui-graphics).
  • References

Scope

In scope: ColorStrategy sealed interface + variants, ColorResolver, SolidColorResolver, JVM unit tests.
Out of scope: registering resolvers in AndroidTypeResolverProvider (ticket #14).

Acceptance criteria

  • ColorResolver generates colors in default RandomArgb mode
  • ColorStrategy.RandomHsl produces valid HSL-converted colors
  • ColorStrategy.Palette only produces colors from the configured list
  • SolidColorResolver produces a SolidColor wrapping a non-null Color
  • Each resolver's canResolve returns true for its own type and false for others
  • Tests compile against android.jar with androidx.compose.ui:ui on classpath and run as JVM unit tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions