import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart';
import 'package:wyatt_ui_kit/wyatt_ui_kit.dart';

class TopAppBarTheme extends TopBarThemeExtension {
  const TopAppBarTheme({
    super.iconTheme,
    super.backgroundColors,
    super.secondaryColor,
    super.titleStyle,
    super.subTitleStyle,
  });

  factory TopAppBarTheme.light() => TopAppBarTheme(
        backgroundColors: const MultiColor.single(
          Color.fromRGBO(246, 246, 246, 1),
        ),
        secondaryColor: const Color.fromRGBO(36, 38, 42, 1),
        titleStyle: GoogleFonts.montserrat(
          fontWeight: FontWeight.bold,
          color: const Color.fromRGBO(36, 38, 42, 1),
          fontSize: 18,
        ),
        subTitleStyle: GoogleFonts.montserrat(
          fontWeight: FontWeight.w400,
          color: const Color.fromRGBO(36, 38, 42, 1),
          fontSize: 18,
        ),
        iconTheme: const IconThemeData(color: Color.fromRGBO(36, 38, 42, 1)),
      );

  factory TopAppBarTheme.dark() => TopAppBarTheme(
        backgroundColors: const MultiColor([
          Color.fromRGBO(44, 50, 56, 1),
          Color.fromRGBO(39, 47, 61, 1),
          Color.fromRGBO(44, 50, 56, 1),
        ]),
        secondaryColor: Colors.white,
        titleStyle: GoogleFonts.montserrat(
          fontWeight: FontWeight.bold,
          fontSize: 18,
        ),
        subTitleStyle: GoogleFonts.montserrat(
          fontWeight: FontWeight.w400,
          fontSize: 18,
        ),
        iconTheme: const IconThemeData(color: Colors.white),
      );

  @override
  ThemeExtension<TopBarThemeExtension> copyWith({
    IconThemeData? iconTheme,
    MultiColor? backgroundColors,
    Color? secondaryColor,
    TextStyle? titleStyle,
  }) =>
      TopAppBarTheme(
        iconTheme: iconTheme ?? this.iconTheme,
        backgroundColors: backgroundColors ?? this.backgroundColors,
        secondaryColor: secondaryColor ?? this.secondaryColor,
        titleStyle: titleStyle ?? this.titleStyle,
      );

  @override
  ThemeExtension<TopBarThemeExtension> lerp(
    covariant ThemeExtension<TopBarThemeExtension>? other,
    double t,
  ) {
    if (other is! TopAppBarTheme) {
      return this;
    }
    return TopAppBarTheme(
      iconTheme: IconThemeData.lerp(iconTheme, other.iconTheme, t),
      backgroundColors:
          MultiColor.lerp(backgroundColors, other.backgroundColors, t),
      secondaryColor: Color.lerp(secondaryColor, other.secondaryColor, t),
      titleStyle: TextStyle.lerp(titleStyle, other.titleStyle, t),
    );
  }
}
