mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 23:18:16 -07:00
chore: Clean-up for status cards
This commit is contained in:
parent
c9ce5b9b90
commit
ed5598fc66
12 changed files with 69 additions and 81 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue