caa19f2d91
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>
59 lines
1.7 KiB
Dart
59 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
import 'theme_extension.dart';
|
|
import 'tokens.dart';
|
|
|
|
ThemeData buildDarkTheme() {
|
|
final fs = FabledSwordTheme.dark();
|
|
final colorScheme = ColorScheme.dark(
|
|
surface: fs.iron,
|
|
onSurface: fs.parchment,
|
|
primary: fs.accent,
|
|
onPrimary: fs.parchment,
|
|
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: 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();
|