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;

  factory FabledSwordTheme.dark() => const FabledSwordTheme(
        accent: FabledSwordFlatTokens.accent,
        obsidian: FabledSwordDarkTokens.obsidian,
        iron: FabledSwordDarkTokens.iron,
        slate: FabledSwordDarkTokens.slate,
        pewter: FabledSwordDarkTokens.pewter,
        parchment: FabledSwordDarkTokens.parchment,
        vellum: FabledSwordDarkTokens.vellum,
        ash: FabledSwordDarkTokens.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),
      );

  factory FabledSwordTheme.light() => const 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
  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;
}
