refactor: consolidate duplicated tokens and the monogram avatar#63
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 alocal
valplus ~10 more inline at call sites.1.2.spletter spacing declared ~19 times under six differentnames (
TrackedLetterSpacing,ActionLetterSpacing,ChipLetterSpacing,FooterLetterSpacing,LabelLetterSpacing,LetterSpacingTracked).0xFF0B0B12preview-background literal repeated in 24@Previewannotations.
All now point at one source: the shared
TabularNums/TrackedLetterSpacingin
ui.theme, a newPREVIEW_BACKGROUND_COLORconst, and a newMonogramAvatarcomposable.ui/theme/GameTokens.ktis renamed toTokens.ktsince the typography tokens are app-wide, not game-only (package unchanged, so no
imports move).
Not included (a clear follow-up if wanted): the
IconButtonChipsquareicon-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
byte-identical to before.
Related issues
Checklist
refactor/).