import 'package:flutter/material.dart';

class CustomColors extends ThemeExtension<CustomColors> {
  final MaterialColor primarySwatch;
  final MaterialColor secondrySwatch;
  final Color primaryLightSurface;
  final Color baseColor;
  final Color highlightColor;

  CustomColors({
    required this.primarySwatch,
    required this.secondrySwatch,
    required this.primaryLightSurface,
    required this.baseColor,
    required this.highlightColor,
  });

  @override
  CustomColors copyWith({
    MaterialColor? primarySwatch,
    MaterialColor? secondrySwatch,
    Color? primaryLightSurface,
    Color? baseColor,
    Color? highlightColor,
  }) {
    return CustomColors(
      primarySwatch: primarySwatch ?? this.primarySwatch,
      secondrySwatch: secondrySwatch ?? this.secondrySwatch,
      primaryLightSurface: primaryLightSurface ?? this.primaryLightSurface,
      baseColor: baseColor ?? this.baseColor,
      highlightColor: highlightColor ?? this.highlightColor,
    );
  }

  @override
  CustomColors lerp(ThemeExtension<CustomColors>? other, double t) {
    if (other is! CustomColors) {
      return this;
    }
    return CustomColors(
      primarySwatch: other.primarySwatch,
      secondrySwatch: other.secondrySwatch,
      primaryLightSurface:
          Color.lerp(primaryLightSurface, other.primaryLightSurface, t)!,
      baseColor: Color.lerp(baseColor, other.baseColor, t)!,
      highlightColor: Color.lerp(highlightColor, other.highlightColor, t)!,
    );
  }
}

extension AppColorsTheme on ThemeData {
  CustomColors? get customColors => extension<CustomColors>();
}
