Skip to content

chore: make android icon res access runtime safe#36

Merged
jaidensiu merged 2 commits into
mainfrom
jaiden/safe-icon-res-access
Jun 10, 2026
Merged

chore: make android icon res access runtime safe#36
jaidensiu merged 2 commits into
mainfrom
jaiden/safe-icon-res-access

Conversation

@jaidensiu

Copy link
Copy Markdown
Collaborator

Summary

variant availability is currently a runtime concern on Android. every icon exposed all three variants as nullable res IDs (even for variants it doesn't ship) so a wrong variant compiled fine but failed at runtime

// AntennaSignal ships no solid variant, but the type system doesn't know that
// IllegalArgumentException at runtime
val resId = requireNotNull(NucleusIcon.AntennaSignal.solidRes)

variant availability is now encoded in the hierarchical type system where each icon implements HasOutline / HasRegular / HasSolid exactly for the variants it has, so res IDs are non-null and the same mistake no longer compiles

// compiler throws error since AntennaSignal has no solidRes variant
NucleusIcon.AntennaSignal.solidRes

@jaidensiu jaidensiu merged commit f4473ef into main Jun 10, 2026
10 checks passed
@jaidensiu jaidensiu deleted the jaiden/safe-icon-res-access branch June 10, 2026 23:31
@github-actions github-actions Bot mentioned this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants