Skip to content

refactor: consolidate duplicated tokens and the monogram avatar#63

Merged
netqo merged 1 commit into
devfrom
refactor/dedup-declarations
Jun 24, 2026
Merged

refactor: consolidate duplicated tokens and the monogram avatar#63
netqo merged 1 commit into
devfrom
refactor/dedup-declarations

Conversation

@netqo

@netqo netqo commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

Removes "same thing declared in many files" duplication. A few design tokens and
one widget were copy-pasted across the codebase; this collapses them onto single
shared definitions. Behavior-preserving: every value and render is identical.

Rationale

A scan for repeated declarations found:

  • TabularNums (TextStyle(fontFeatureSettings = "tnum")) declared ~9 times as a
    local val plus ~10 more inline at call sites.
  • The tracked 1.2.sp letter spacing declared ~19 times under six different
    names (TrackedLetterSpacing, ActionLetterSpacing, ChipLetterSpacing,
    FooterLetterSpacing, LabelLetterSpacing, LetterSpacingTracked).
  • The 0xFF0B0B12 preview-background literal repeated in 24 @Preview
    annotations.
  • The initials-on-accent square avatar copied in three screens.

All now point at one source: the shared TabularNums / TrackedLetterSpacing
in ui.theme, a new PREVIEW_BACKGROUND_COLOR const, and a new
MonogramAvatar composable. ui/theme/GameTokens.kt is renamed to Tokens.kt
since the typography tokens are app-wide, not game-only (package unchanged, so no
imports move).

Not included (a clear follow-up if wanted): the IconButtonChip square
icon-button is still duplicated ~6 times under different names; left for a
separate PR to keep this one focused on the declaration-level duplication.

Verification

  • ./gradlew :app:compileDebugKotlin (green)
  • ./gradlew :app:ktlintMainSourceSetCheck (green)
  • ./gradlew :app:detekt (green)
  • ./gradlew :app:testDebugUnitTest (green)

Test plan

  • Compile + ktlint + detekt + unit tests clean.
  • Change is mechanical (token references + one widget extraction); renders are
    byte-identical to before.

Related issues

Checklist

  • Commit messages follow Conventional Commits.
  • Branch name follows the naming convention (refactor/).
  • The change is scoped: token de-duplication + MonogramAvatar extraction.
  • No user-visible behavior changed, so CHANGELOG.md is intentionally untouched.
  • No new dependency was added.

Several design tokens and one widget were declared identically in many
files. Collapse them onto single shared definitions (behavior-preserving;
every value/render is unchanged):

- TabularNums: removed ~9 local `val`s plus ~10 inline
  `TextStyle(fontFeatureSettings = "tnum")` uses; all reference the one in
  ui.theme.
- Tracked 1.2.sp letter spacing: removed ~19 copies that lived under six
  different names (TrackedLetterSpacing / ActionLetterSpacing /
  ChipLetterSpacing / FooterLetterSpacing / LabelLetterSpacing /
  LetterSpacingTracked); all now use the shared TrackedLetterSpacing.
- Preview background: replaced the 0xFF0B0B12 literal in 24 @Preview
  annotations with a single PREVIEW_BACKGROUND_COLOR const.
- MonogramAvatar: extracted the initials-on-accent square that was copied
  in the lobby header, profile identity card and login "Continue as" card.

Renamed ui/theme/GameTokens.kt to Tokens.kt since the typography tokens
are app-wide, not game-only.
@netqo netqo merged commit 01990e9 into dev Jun 24, 2026
3 checks passed
@netqo netqo deleted the refactor/dedup-declarations branch June 24, 2026 18:26
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