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:
@@ -30,26 +30,51 @@ class FabledSwordTheme extends ThemeExtension<FabledSwordTheme> {
|
|||||||
final Color warning, error, info;
|
final Color warning, error, info;
|
||||||
final TextStyle display, body, mono;
|
final TextStyle display, body, mono;
|
||||||
|
|
||||||
static FabledSwordTheme fromTokens() => const FabledSwordTheme(
|
factory FabledSwordTheme.dark() => FabledSwordTheme(
|
||||||
accent: FabledSwordTokens.accent,
|
accent: FabledSwordFlatTokens.accent,
|
||||||
obsidian: FabledSwordTokens.obsidian,
|
obsidian: FabledSwordDarkTokens.obsidian,
|
||||||
iron: FabledSwordTokens.iron,
|
iron: FabledSwordDarkTokens.iron,
|
||||||
slate: FabledSwordTokens.slate,
|
slate: FabledSwordDarkTokens.slate,
|
||||||
pewter: FabledSwordTokens.pewter,
|
pewter: FabledSwordDarkTokens.pewter,
|
||||||
parchment: FabledSwordTokens.parchment,
|
parchment: FabledSwordDarkTokens.parchment,
|
||||||
vellum: FabledSwordTokens.vellum,
|
vellum: FabledSwordDarkTokens.vellum,
|
||||||
ash: FabledSwordTokens.ash,
|
ash: FabledSwordDarkTokens.ash,
|
||||||
moss: FabledSwordTokens.moss,
|
moss: FabledSwordFlatTokens.moss,
|
||||||
bronze: FabledSwordTokens.bronze,
|
bronze: FabledSwordFlatTokens.bronze,
|
||||||
oxblood: FabledSwordTokens.oxblood,
|
oxblood: FabledSwordFlatTokens.oxblood,
|
||||||
warning: FabledSwordTokens.warning,
|
warning: FabledSwordFlatTokens.warning,
|
||||||
error: FabledSwordTokens.error,
|
error: FabledSwordFlatTokens.error,
|
||||||
info: FabledSwordTokens.info,
|
info: FabledSwordFlatTokens.info,
|
||||||
display: TextStyle(fontFamily: FabledSwordTokens.fontDisplay),
|
display: TextStyle(fontFamily: FabledSwordFlatTokens.fontDisplay),
|
||||||
body: TextStyle(fontFamily: FabledSwordTokens.fontBody),
|
body: TextStyle(fontFamily: FabledSwordFlatTokens.fontBody),
|
||||||
mono: TextStyle(fontFamily: FabledSwordTokens.fontMono),
|
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
|
@override
|
||||||
FabledSwordTheme copyWith({
|
FabledSwordTheme copyWith({
|
||||||
Color? accent,
|
Color? accent,
|
||||||
|
|||||||
Reference in New Issue
Block a user