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 'theme_extension.dart';
|
||||||
import 'tokens.dart';
|
import 'tokens.dart';
|
||||||
|
|
||||||
ThemeData buildThemeData() {
|
ThemeData buildDarkTheme() {
|
||||||
final fs = FabledSwordTheme.fromTokens();
|
final fs = FabledSwordTheme.dark();
|
||||||
final colorScheme = ColorScheme.dark(
|
final colorScheme = ColorScheme.dark(
|
||||||
surface: fs.iron,
|
surface: fs.iron,
|
||||||
onSurface: fs.parchment,
|
onSurface: fs.parchment,
|
||||||
@@ -14,16 +14,45 @@ ThemeData buildThemeData() {
|
|||||||
secondary: fs.moss,
|
secondary: fs.moss,
|
||||||
error: fs.error,
|
error: fs.error,
|
||||||
);
|
);
|
||||||
|
|
||||||
return ThemeData(
|
return ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
|
brightness: Brightness.dark,
|
||||||
colorScheme: colorScheme,
|
colorScheme: colorScheme,
|
||||||
scaffoldBackgroundColor: fs.obsidian,
|
scaffoldBackgroundColor: fs.obsidian,
|
||||||
textTheme: GoogleFonts.interTextTheme().apply(
|
textTheme: GoogleFonts.interTextTheme().apply(
|
||||||
bodyColor: fs.parchment,
|
bodyColor: fs.parchment,
|
||||||
displayColor: fs.parchment,
|
displayColor: fs.parchment,
|
||||||
),
|
),
|
||||||
fontFamily: FabledSwordTokens.fontBody,
|
fontFamily: FabledSwordFlatTokens.fontBody,
|
||||||
extensions: <ThemeExtension<dynamic>>[fs],
|
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