import 'package:flutter/material.dart'; import '../theme/app_status_colors.dart'; import '../theme/app_surfaces.dart'; /// Cyber/IT status pill — a compact, uppercase, mono-friendly badge whose color /// carries meaning via [AppStatusColors]. /// /// Two constructors: /// * [StatusPill.kind] (preferred) — pass a semantic [StatusKind] and it pulls /// the correct tonal container/foreground from the theme, consistent in both /// light and dark. /// * The default constructor keeps the older `isEmphasized` behaviour for /// back-compat (primaryContainer vs. tertiaryContainer). class StatusPill extends StatelessWidget { const StatusPill({super.key, required this.label, this.isEmphasized = false}) : kind = null; /// Semantic variant — the recommended way to build a status pill. const StatusPill.kind( this.kind, { super.key, required this.label, }) : isEmphasized = false; final String label; final bool isEmphasized; final StatusKind? kind; @override Widget build(BuildContext context) { final scheme = Theme.of(context).colorScheme; final radius = AppSurfaces.of(context).chipRadius; late final Color background; late final Color foreground; if (kind != null) { final swatch = AppStatusColors.of(context).byKind(kind!); background = swatch.container; foreground = swatch.onContainer; } else { // Legacy path: emphasis maps to primary vs. tertiary containers. background = isEmphasized ? scheme.primaryContainer : scheme.tertiaryContainer; foreground = isEmphasized ? scheme.onPrimaryContainer : scheme.onTertiaryContainer; } return AnimatedContainer( duration: const Duration(milliseconds: 400), curve: Curves.easeOutCubic, padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6), decoration: BoxDecoration( color: background, borderRadius: BorderRadius.circular(radius), ), child: Text( label.toUpperCase(), style: Theme.of(context).textTheme.labelSmall?.copyWith( color: foreground, fontWeight: FontWeight.w700, letterSpacing: 0.5, ), ), ); } }