chore: Clean-up for status cards

This commit is contained in:
PartyDonut 2025-10-26 19:18:26 +01:00
parent c9ce5b9b90
commit ed5598fc66
12 changed files with 69 additions and 81 deletions

View file

@ -2,38 +2,40 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:fladder/theme.dart';
class StatusCard extends ConsumerWidget {
final Color? color;
final bool useFittedBox;
final Widget child;
const StatusCard({this.color, this.useFittedBox = false, required this.child, super.key});
const StatusCard({this.color, required this.child, super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return Padding(
padding: const EdgeInsets.all(2),
child: SizedBox.square(
dimension: 33,
child: Card(
elevation: 10,
surfaceTintColor: color,
shadowColor: color != null ? Colors.transparent : null,
child: IconTheme(
data: IconThemeData(
color: color,
),
child: Center(
child: useFittedBox
? FittedBox(
fit: BoxFit.scaleDown,
child: child,
)
: child,
),
padding: const EdgeInsets.all(2.5),
child: Container(
constraints: const BoxConstraints(minWidth: 32, minHeight: 32),
decoration: BoxDecoration(
color: blendColors(
Theme.of(context).colorScheme.surfaceContainer,
blend: color,
),
borderRadius: FladderTheme.smallShape.borderRadius,
),
child: IconTheme(
data: IconThemeData(
color: color,
),
child: child,
),
),
);
}
}
Color blendColors(Color base, {Color? blend, double amount = 0.25}) {
if (blend == null) return base;
return Color.lerp(base, blend, amount) ?? base;
}