feat(flutter/theme): FabledSwordTheme.dark() + .light() factories

Both factories produce the same field shape (semantic role-based
names like obsidian/iron/parchment) with palette values from the
new FabledSwordDarkTokens or FabledSwordLightTokens generated
classes. fromTokens() stays as a back-compat alias returning the
dark theme so existing call sites keep working.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-09 15:46:01 -04:00
parent b1f62a0733
commit 66ddd3c366
+43 -18
View File
@@ -30,26 +30,51 @@ class FabledSwordTheme extends ThemeExtension<FabledSwordTheme> {
final Color warning, error, info;
final TextStyle display, body, mono;
static FabledSwordTheme fromTokens() => const FabledSwordTheme(
accent: FabledSwordTokens.accent,
obsidian: FabledSwordTokens.obsidian,
iron: FabledSwordTokens.iron,
slate: FabledSwordTokens.slate,
pewter: FabledSwordTokens.pewter,
parchment: FabledSwordTokens.parchment,
vellum: FabledSwordTokens.vellum,
ash: FabledSwordTokens.ash,
moss: FabledSwordTokens.moss,
bronze: FabledSwordTokens.bronze,
oxblood: FabledSwordTokens.oxblood,
warning: FabledSwordTokens.warning,
error: FabledSwordTokens.error,
info: FabledSwordTokens.info,
display: TextStyle(fontFamily: FabledSwordTokens.fontDisplay),
body: TextStyle(fontFamily: FabledSwordTokens.fontBody),
mono: TextStyle(fontFamily: FabledSwordTokens.fontMono),
factory FabledSwordTheme.dark() => FabledSwordTheme(
accent: FabledSwordFlatTokens.accent,
obsidian: FabledSwordDarkTokens.obsidian,
iron: FabledSwordDarkTokens.iron,
slate: FabledSwordDarkTokens.slate,
pewter: FabledSwordDarkTokens.pewter,
parchment: FabledSwordDarkTokens.parchment,
vellum: FabledSwordDarkTokens.vellum,
ash: FabledSwordDarkTokens.ash,
moss: FabledSwordFlatTokens.moss,
bronze: FabledSwordFlatTokens.bronze,
oxblood: FabledSwordFlatTokens.oxblood,
warning: FabledSwordFlatTokens.warning,
error: FabledSwordFlatTokens.error,
info: FabledSwordFlatTokens.info,
display: TextStyle(fontFamily: FabledSwordFlatTokens.fontDisplay),
body: TextStyle(fontFamily: FabledSwordFlatTokens.fontBody),
mono: TextStyle(fontFamily: FabledSwordFlatTokens.fontMono),
);
factory FabledSwordTheme.light() => FabledSwordTheme(
accent: FabledSwordFlatTokens.accent,
obsidian: FabledSwordLightTokens.obsidian,
iron: FabledSwordLightTokens.iron,
slate: FabledSwordLightTokens.slate,
pewter: FabledSwordLightTokens.pewter,
parchment: FabledSwordLightTokens.parchment,
vellum: FabledSwordLightTokens.vellum,
ash: FabledSwordLightTokens.ash,
moss: FabledSwordFlatTokens.moss,
bronze: FabledSwordFlatTokens.bronze,
oxblood: FabledSwordFlatTokens.oxblood,
warning: FabledSwordFlatTokens.warning,
error: FabledSwordFlatTokens.error,
info: FabledSwordFlatTokens.info,
display: TextStyle(fontFamily: FabledSwordFlatTokens.fontDisplay),
body: TextStyle(fontFamily: FabledSwordFlatTokens.fontBody),
mono: TextStyle(fontFamily: FabledSwordFlatTokens.fontMono),
);
/// Back-compat alias for the original API. Returns the dark theme.
/// Existing call sites can keep using fromTokens() until they're
/// migrated to .dark() / .light() explicitly.
static FabledSwordTheme fromTokens() => FabledSwordTheme.dark();
@override
FabledSwordTheme copyWith({
Color? accent,