// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

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 TextInputTheme extends TextInputThemeExtension {
  const TextInputTheme({
    super.normalStyle,
    super.focusedStyle,
    super.disableStyle,
    super.errorStyle,
  });

  factory TextInputTheme.light() => TextInputTheme(
        normalStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(221, 224, 227, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(55, 65, 81, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(55, 65, 81, 1),
          ),
        ),
        focusedStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(60, 125, 251, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(55, 65, 81, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(55, 65, 81, 1),
          ),
        ),
        errorStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(244, 68, 100, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(244, 68, 100, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(55, 65, 81, 1),
          ),
        ),
        disableStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(229, 231, 235, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(156, 163, 175, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(156, 163, 175, 1),
          ),
        ),
      );

  factory TextInputTheme.dark() => TextInputTheme(
        normalStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(96, 101, 106, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(204, 204, 204, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(255, 255, 255, 1),
          ),
        ),
        focusedStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(60, 125, 251, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(204, 204, 204, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(255, 255, 255, 1),
          ),
        ),
        errorStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(244, 68, 100, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(244, 68, 100, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(255, 255, 255, 1),
          ),
        ),
        disableStyle: TextInputStyle(
          radius: BorderRadius.circular(12),
          borderColors: const Color.fromRGBO(96, 101, 106, 1),
          labelStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(96, 101, 106, 1),
          ),
          inputStyle: GoogleFonts.montserrat(
            fontWeight: FontWeight.w300,
            color: const Color.fromRGBO(255, 255, 255, 1),
          ),
        ),
      );

  @override
  ThemeExtension<TextInputThemeExtension> lerp(
    covariant ThemeExtension<TextInputThemeExtension>? other,
    double t,
  ) {
    if (other is! TextInputTheme) {
      return this;
    }
    return TextInputTheme(
      normalStyle: TextInputStyle.lerp(normalStyle, other.normalStyle, t),
      focusedStyle: TextInputStyle.lerp(focusedStyle, other.focusedStyle, t),
      disableStyle: TextInputStyle.lerp(disableStyle, other.disableStyle, t),
      errorStyle: TextInputStyle.lerp(errorStyle, other.errorStyle, t),
    );
  }

  @override
  ThemeExtension<TextInputThemeExtension> copyWith({
    TextInputStyle? normalStyle,
    TextInputStyle? focusedStyle,
    TextInputStyle? disableStyle,
    TextInputStyle? errorStyle,
  }) =>
      TextInputTheme(
        normalStyle: normalStyle ?? this.normalStyle,
        focusedStyle: focusedStyle ?? this.focusedStyle,
        disableStyle: disableStyle ?? this.disableStyle,
        errorStyle: errorStyle ?? this.errorStyle,
      );
}
