2026-07-10 07:10:15 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'app_icon.dart';
|
|
|
|
|
|
|
|
|
|
/// Small labeled pill (optionally with a leading icon): detail-screen stat
|
|
|
|
|
/// chips, request-sheet season status labels.
|
|
|
|
|
class StatChip extends StatelessWidget {
|
|
|
|
|
final IconData? icon;
|
|
|
|
|
final Color? iconColor;
|
|
|
|
|
final String label;
|
|
|
|
|
|
2026-07-29 19:30:15 +02:00
|
|
|
/// Leading artwork for chips whose source has a brand mark (rating badges).
|
|
|
|
|
/// Takes precedence over [icon].
|
|
|
|
|
final Widget? leading;
|
|
|
|
|
|
2026-07-29 05:18:56 +02:00
|
|
|
/// Overrides the default fill. Needed where the chip sits on a surface that
|
|
|
|
|
/// already uses `surfaceContainerHigh` — the mono theme collapses several
|
|
|
|
|
/// container roles onto one colour, so the default would be invisible.
|
|
|
|
|
final Color? backgroundColor;
|
|
|
|
|
|
2026-07-29 19:30:15 +02:00
|
|
|
const StatChip({super.key, this.icon, this.iconColor, required this.label, this.leading, this.backgroundColor});
|
2026-07-10 07:10:15 +02:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final theme = Theme.of(context);
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
|
|
|
|
decoration: BoxDecoration(
|
2026-07-29 05:18:56 +02:00
|
|
|
color: backgroundColor ?? theme.colorScheme.surfaceContainerHigh,
|
2026-07-10 07:10:15 +02:00
|
|
|
borderRadius: BorderRadius.circular(999),
|
|
|
|
|
),
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
2026-07-29 19:30:15 +02:00
|
|
|
if (leading case final leading?) ...[
|
|
|
|
|
leading,
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
] else if (icon != null) ...[
|
|
|
|
|
AppIcon(icon!, size: 14, fill: 1, color: iconColor),
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
],
|
2026-07-10 07:10:15 +02:00
|
|
|
Text(label, style: theme.textTheme.labelMedium),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|