Files
minstrel/flutter_client/lib/theme/theme_extension.dart
T
bvandeusen 2729ab897f feat(flutter): FabledSwordTheme ThemeExtension + Material 3 ThemeData
Widgets read tokens via Theme.of(ctx).extension<FabledSwordTheme>().
Material 3 ColorScheme bound to FabledSword tokens. Body text uses
GoogleFonts.interTextTheme() so the fonts work without bundling .ttf
files (offline-from-cold-launch is a separate question once #357 lands).
2026-05-02 16:56:38 -04:00

69 lines
2.2 KiB
Dart

import 'package:flutter/material.dart';
import 'tokens.dart';
class FabledSwordTheme extends ThemeExtension<FabledSwordTheme> {
const FabledSwordTheme({
required this.accent,
required this.obsidian,
required this.iron,
required this.slate,
required this.pewter,
required this.parchment,
required this.vellum,
required this.ash,
required this.moss,
required this.bronze,
required this.oxblood,
required this.warning,
required this.error,
required this.info,
required this.display,
required this.body,
required this.mono,
});
final Color accent;
final Color obsidian, iron, slate, pewter;
final Color parchment, vellum, ash;
final Color moss, bronze, oxblood;
final Color warning, error, info;
final TextStyle display, body, mono;
static FabledSwordTheme fromTokens() => 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: const TextStyle(fontFamily: FabledSwordTokens.fontDisplay),
body: const TextStyle(fontFamily: FabledSwordTokens.fontBody),
mono: const TextStyle(fontFamily: FabledSwordTokens.fontMono),
);
@override
FabledSwordTheme copyWith({
Color? accent,
}) =>
FabledSwordTheme(
accent: accent ?? this.accent,
obsidian: obsidian, iron: iron, slate: slate, pewter: pewter,
parchment: parchment, vellum: vellum, ash: ash,
moss: moss, bronze: bronze, oxblood: oxblood,
warning: warning, error: error, info: info,
display: display, body: body, mono: mono,
);
@override
FabledSwordTheme lerp(ThemeExtension<FabledSwordTheme>? other, double t) => this;
}