feat(flutter/theme): buildDarkTheme + buildLightTheme
Both builders construct a ThemeData with the matching brightness + ColorScheme.dark/.light + the corresponding FabledSwordTheme extension. buildThemeData() stays as a back-compat alias returning the dark theme so the existing widget-test suite keeps using it without churn. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,8 +4,8 @@ import 'package:google_fonts/google_fonts.dart';
|
||||
import 'theme_extension.dart';
|
||||
import 'tokens.dart';
|
||||
|
||||
ThemeData buildThemeData() {
|
||||
final fs = FabledSwordTheme.fromTokens();
|
||||
ThemeData buildDarkTheme() {
|
||||
final fs = FabledSwordTheme.dark();
|
||||
final colorScheme = ColorScheme.dark(
|
||||
surface: fs.iron,
|
||||
onSurface: fs.parchment,
|
||||
@@ -14,16 +14,45 @@ ThemeData buildThemeData() {
|
||||
secondary: fs.moss,
|
||||
error: fs.error,
|
||||
);
|
||||
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.dark,
|
||||
colorScheme: colorScheme,
|
||||
scaffoldBackgroundColor: fs.obsidian,
|
||||
textTheme: GoogleFonts.interTextTheme().apply(
|
||||
bodyColor: fs.parchment,
|
||||
displayColor: fs.parchment,
|
||||
),
|
||||
fontFamily: FabledSwordTokens.fontBody,
|
||||
fontFamily: FabledSwordFlatTokens.fontBody,
|
||||
extensions: <ThemeExtension<dynamic>>[fs],
|
||||
);
|
||||
}
|
||||
|
||||
ThemeData buildLightTheme() {
|
||||
final fs = FabledSwordTheme.light();
|
||||
final colorScheme = ColorScheme.light(
|
||||
surface: fs.iron,
|
||||
onSurface: fs.parchment, // semantic — light's "parchment" is dark text
|
||||
primary: fs.accent,
|
||||
onPrimary: FabledSwordFlatTokens.onAction,
|
||||
secondary: fs.moss,
|
||||
error: fs.error,
|
||||
);
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
brightness: Brightness.light,
|
||||
colorScheme: colorScheme,
|
||||
scaffoldBackgroundColor: fs.obsidian, // semantic — light's obsidian is the bg
|
||||
textTheme: GoogleFonts.interTextTheme().apply(
|
||||
bodyColor: fs.parchment,
|
||||
displayColor: fs.parchment,
|
||||
),
|
||||
fontFamily: FabledSwordFlatTokens.fontBody,
|
||||
extensions: <ThemeExtension<dynamic>>[fs],
|
||||
);
|
||||
}
|
||||
|
||||
/// Back-compat alias. Existing tests + code call buildThemeData(); it
|
||||
/// returns the dark theme to preserve current behaviour. New code
|
||||
/// should prefer buildDarkTheme()/buildLightTheme() explicitly.
|
||||
ThemeData buildThemeData() => buildDarkTheme();
|
||||
|
||||
Reference in New Issue
Block a user