Malo Léon 4b37175d17
Some checks failed
continuous-integration/drone/push Build is failing
feat(ui_kit): add card theme extension, fix bugs & update example (close #126)
2023-02-14 11:34:45 +01:00

55 lines
1.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:wyatt_ui_kit/wyatt_ui_kit.dart' as ui_kit;
class CustomCardColorExtension extends ui_kit.CardThemeExtension {
const CustomCardColorExtension({
super.backgroundColors,
super.secondaryBackgroundColors,
super.borderColor,
super.shadowColor,
super.body,
super.title,
super.subtitle,
});
@override
CustomCardColorExtension copyWith({
List<Color>? backgroundColors,
Color? secondaryBackgroundColors,
List<Color>? borderColor,
BoxShadow? shadowColor,
TextStyle? body,
TextStyle? title,
TextStyle? subtitle,
}) =>
CustomCardColorExtension(
backgroundColors: backgroundColors ?? this.backgroundColors,
secondaryBackgroundColors:
secondaryBackgroundColors ?? this.secondaryBackgroundColors,
borderColor: borderColor ?? this.borderColor,
body: body ?? this.body,
title: title ?? this.title,
subtitle: subtitle ?? this.subtitle,
);
@override
ThemeExtension<ui_kit.CardThemeExtension> lerp(
covariant ThemeExtension<ui_kit.CardThemeExtension>? other,
double t,
) {
if (other is! CustomCardColorExtension) {
return this;
}
return CustomCardColorExtension(
secondaryBackgroundColors: Color.lerp(
secondaryBackgroundColors,
other.secondaryBackgroundColors,
t,
),
body: TextStyle.lerp(body, other.body, t),
title: TextStyle.lerp(title, other.title, t),
subtitle: TextStyle.lerp(subtitle, other.subtitle, t),
);
}
}