import 'package:flutter/material.dart';

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

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

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

  @override
  ThemeExtension<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)!,
    );
  }
}

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