import 'dart:ui';
import 'package:digiplug/bat_theme/bat_theme.dart';
import 'package:flutter/material.dart';

@immutable
class BatButtonStyle extends ThemeExtension<BatButtonStyle> {
  final double? height;
  final EdgeInsets? padding;
  final Color? color;
  final Color? childColor;
  final ShapeBorder? shape;

  const BatButtonStyle({
    this.height,
    this.padding,
    this.color,
    this.childColor,
    this.shape,
  });

  const BatButtonStyle.light()
      : this(
          shape: const RoundedRectangleBorder(),
          childColor: BatPalette.white,
          color: BatPalette.primary,
          height: 53,
          padding: const EdgeInsets.symmetric(vertical: 16),
        );

  const BatButtonStyle.dark()
      : this(
          shape: const RoundedRectangleBorder(),
          childColor: BatPalette.primary,
          color: BatPalette.white,
          height: 53,
          padding: const EdgeInsets.symmetric(vertical: 16),
        );

  @override
  BatButtonStyle copyWith({
    ShapeBorder? shape,
    Color? childColor,
    Color? color,
    double? height,
    EdgeInsets? padding,
  }) {
    return BatButtonStyle(
      shape: shape ?? this.shape,
      childColor: childColor ?? this.childColor,
      color: color ?? this.color,
      height: height ?? this.height,
      padding: padding ?? this.padding,
    );
  }

  @override
  BatButtonStyle lerp(ThemeExtension<BatButtonStyle>? other, double t) {
    if (other is! BatButtonStyle) {
      return this;
    }
    return copyWith(
      shape: ShapeBorder.lerp(shape, other.shape, t),
      childColor: Color.lerp(childColor, other.childColor, t),
      color: Color.lerp(color, other.color, t),
      height: lerpDouble(height, other.height, t),
      padding: EdgeInsets.lerp(padding, other.padding, t),
    );
  }
}
