import 'dart:ui'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; class FikoYTCard extends StatelessWidget { const FikoYTCard({super.key, children, this.theme}) : children = children ?? const []; final List children; final FikoYTCardTheme? theme; @override Widget build(BuildContext context) { return Container( margin: Theme.of(context).extension()?.margin ?? const EdgeInsets.all(5.0), padding: Theme.of(context).extension()?.padding ?? const EdgeInsets.all(5.0), alignment: Alignment.topLeft, constraints: theme?.boxConstraints ?? Theme.of(context).extension()?.boxConstraints, decoration: BoxDecoration( color: theme?.backgroundColor ?? Theme.of(context).extension()?.backgroundColor ?? Colors.white, borderRadius: theme?.borderRadius ?? Theme.of(context).extension()?.borderRadius ?? BorderRadius.all( Radius.circular(theme?.radius ?? 5), ), boxShadow: // theme?.boxShadow ?? // Theme.of(context).extension()?.boxShadow ?? [ BoxShadow( color: Theme.of(context).extension()?.shadowColor ?? Colors.black26, offset: const Offset(0, 0), spreadRadius: -1, blurRadius: theme?.elevation ?? Theme.of(context).extension()?.elevation ?? 5.0, blurStyle: BlurStyle.outer, ), ], // border: Border.all( // color: Theme.of(context).extension()!.cardBackgroundColor!.withAlpha(255), // ), ), child: Column( crossAxisAlignment: theme?.crossAxisAlignment ?? Theme.of(context).extension()?.crossAxisAlignment ?? CrossAxisAlignment.start, mainAxisAlignment: theme?.mainAxisAlignment ?? Theme.of(context).extension()?.mainAxisAlignment ?? MainAxisAlignment.start, spacing: theme?.spacing ?? Theme.of(context).extension()?.spacing ?? 3, children: children, ), ); } } class FikoYTCardTheme extends ThemeExtension { FikoYTCardTheme({ this.backgroundColor, this.borderColor, this.shadowColor, this.radius, this.spacing, this.elevation, this.boxConstraints, BorderRadiusGeometry? borderRadius, this.padding, this.margin, Duration? animationDuration, this.boxShadow, this.mainAxisAlignment, this.crossAxisAlignment, }); Color? backgroundColor; Color? borderColor; Color? shadowColor; double? radius; double? spacing; double? elevation; BoxConstraints? boxConstraints; Duration? animationDuration; BorderRadiusGeometry? borderRadius; EdgeInsetsGeometry? padding; EdgeInsetsGeometry? margin; List? boxShadow; MainAxisAlignment? mainAxisAlignment; CrossAxisAlignment? crossAxisAlignment; @override FikoYTCardTheme copyWith({ Color? backgroundColor, Color? borderColor, Color? shadowColor, double? radius, double? spacing, double? elevation, BoxConstraints? boxConstraints, Duration? animationDuration, BorderRadiusGeometry? borderRadius, EdgeInsetsGeometry? padding, EdgeInsetsGeometry? margin, List? boxShadow, MainAxisAlignment? mainAxisAlignment, CrossAxisAlignment? crossAxisAlignment, }) { return FikoYTCardTheme( backgroundColor: backgroundColor ?? this.backgroundColor, animationDuration: animationDuration ?? this.animationDuration, borderRadius: borderRadius ?? this.borderRadius, padding: padding ?? this.padding, margin: margin ?? this.margin, radius: radius ?? this.radius, spacing: spacing ?? this.spacing, elevation: elevation ?? this.elevation, boxConstraints: boxConstraints ?? this.boxConstraints, borderColor: borderColor ?? this.borderColor, shadowColor: shadowColor ?? this.shadowColor, boxShadow: boxShadow ?? this.boxShadow, mainAxisAlignment: mainAxisAlignment ?? this.mainAxisAlignment, crossAxisAlignment: crossAxisAlignment ?? this.crossAxisAlignment, ); } @override FikoYTCardTheme lerp(ThemeExtension other, double t) { if (other is! FikoYTCardTheme) { return this; } return FikoYTCardTheme( backgroundColor: Color.lerp(backgroundColor, other.backgroundColor, t), animationDuration: lerpDuration(animationDuration ?? Duration.zero, other.animationDuration ?? Duration.zero, t), borderRadius: BorderRadius.lerp(borderRadius?.resolve(TextDirection.ltr), other.borderRadius?.resolve(TextDirection.ltr), t), padding: EdgeInsets.lerp(padding?.resolve(TextDirection.ltr), other.padding?.resolve(TextDirection.ltr), t), margin: EdgeInsets.lerp(margin?.resolve(TextDirection.ltr), other.margin?.resolve(TextDirection.ltr), t), radius: lerpDouble(radius, other.radius, t), spacing: lerpDouble(spacing, other.spacing, t), elevation: lerpDouble(elevation, other.elevation, t), boxConstraints: BoxConstraints.lerp(boxConstraints, other.boxConstraints, t), borderColor: Color.lerp(borderColor, other.borderColor, t), shadowColor: Color.lerp(shadowColor, other.shadowColor, t), boxShadow: boxShadow, mainAxisAlignment: mainAxisAlignment, crossAxisAlignment: crossAxisAlignment); } }