import 'package:fikoyt_ui/ui/themes/fikoyt_button_theme.dart'; import 'package:fikoyt_ui/ui/themes/table_theme.dart'; import 'package:flutter/material.dart'; extension ThemeDataExtension on ThemeData { TableTheme get tableTheme => extension() ?? TableTheme(); FikoYTButtonTheme get fikoButtonTheme => extension() ?? FikoYTButtonTheme(); } class FikoTheme extends ThemeExtension { final Color? backgroundColor; final Color? cardBackgroundColor; final Color? inputBackgroundColor; final Color? textColor; final Color? secondaryTextColor; final Color? tertiaryTextColor; final Color? textShadowColor; final Color? successTextColor; final Color? errorTextColor; final Color? warningTextColor; final Color? infoTextColor; final Color? shadowColor; final Color? appBarColor; final Color? splashColor; final Color? borderColor; final List? textShadow; final FikoYTButtonTheme? fikoYTButtonTheme; FikoTheme({ this.backgroundColor, this.cardBackgroundColor, this.inputBackgroundColor, this.textColor, this.secondaryTextColor, this.tertiaryTextColor, this.successTextColor, this.errorTextColor, this.warningTextColor, this.infoTextColor, this.shadowColor, this.textShadow, this.textShadowColor, this.appBarColor, this.splashColor, this.borderColor, this.fikoYTButtonTheme, }); @override ThemeExtension copyWith({ Color? backgroundColor, Color? cardBackgroundColor, Color? inputBackgroundColor, Color? textColor, Color? secondaryTextColor, Color? tertiaryTextColor, Color? successTextColor, Color? errorTextColor, Color? warningTextColor, Color? infoTextColor, Color? shadowColor, Color? appBarColor, Color? splashColor, Color? borderColor, List? textShadow, Color? textShadowColor, TableTheme? tableTheme, FikoYTButtonTheme? fikoYTButtonTheme, }) { return FikoTheme( backgroundColor: backgroundColor ?? this.backgroundColor, cardBackgroundColor: cardBackgroundColor ?? this.cardBackgroundColor, inputBackgroundColor: inputBackgroundColor ?? this.inputBackgroundColor, textColor: textColor ?? this.textColor, secondaryTextColor: secondaryTextColor ?? this.secondaryTextColor, tertiaryTextColor: tertiaryTextColor ?? this.tertiaryTextColor, successTextColor: successTextColor ?? this.successTextColor, errorTextColor: errorTextColor ?? this.errorTextColor, warningTextColor: warningTextColor ?? this.warningTextColor, infoTextColor: infoTextColor ?? this.infoTextColor, shadowColor: shadowColor ?? this.shadowColor, textShadowColor: textShadowColor ?? this.textShadowColor, appBarColor: appBarColor ?? this.appBarColor, textShadow: textShadow ?? this.textShadow, fikoYTButtonTheme: fikoYTButtonTheme ?? this.fikoYTButtonTheme, splashColor: splashColor ?? this.splashColor, borderColor: borderColor ?? this.borderColor, ); } @override ThemeExtension lerp(covariant ThemeExtension? other, double t) { if (other is! FikoTheme) { return this; } return FikoTheme( backgroundColor: Color.lerp(backgroundColor, other.backgroundColor, t), cardBackgroundColor: Color.lerp(cardBackgroundColor, other.cardBackgroundColor, t), inputBackgroundColor: Color.lerp(inputBackgroundColor, other.inputBackgroundColor, t), textColor: Color.lerp(textColor, other.textColor, t), secondaryTextColor: Color.lerp(secondaryTextColor, other.secondaryTextColor, t), tertiaryTextColor: Color.lerp(tertiaryTextColor, other.tertiaryTextColor, t), successTextColor: Color.lerp(successTextColor, other.successTextColor, t), errorTextColor: Color.lerp(errorTextColor, other.errorTextColor, t), shadowColor: Color.lerp(shadowColor, other.shadowColor, t), textShadow: Shadow.lerpList(textShadow, other.textShadow, t), textShadowColor: Color.lerp(textShadowColor, other.textShadowColor, t), warningTextColor: Color.lerp(warningTextColor, other.warningTextColor, t), infoTextColor: Color.lerp(infoTextColor, other.infoTextColor, t), appBarColor: Color.lerp(appBarColor, other.appBarColor, t), fikoYTButtonTheme: fikoYTButtonTheme?.lerp(other.fikoYTButtonTheme ?? FikoYTButtonTheme(), t), splashColor: Color.lerp(splashColor, other.splashColor, t), borderColor: Color.lerp(borderColor, other.borderColor, t), ); } } class HexColor extends Color { HexColor(final String hexColor) : super(_getColorFromHex(hexColor)); static int _getColorFromHex(String hexColor) { hexColor = hexColor.toUpperCase().replaceAll('#', ''); if (hexColor.length == 6) { hexColor = 'FF$hexColor'; } return int.parse(hexColor, radix: 16); } }