This commit is contained in:
Arseni
2026-03-04 17:43:18 +03:00
parent 80b25a8608
commit aff804ec58
46 changed files with 1090 additions and 345 deletions

View File

@@ -14,37 +14,34 @@ class OperationStatusBadge extends StatelessWidget {
const OperationStatusBadge({super.key, required this.status});
Color _badgeColor(BuildContext context) {
final l10n = AppLocalizations.of(context)!;
return operationStatusView(l10n, status).color;
}
Color _textColor(Color background) {
// computeLuminance returns 0 for black, 1 for white
return background.computeLuminance() > 0.5 ? Colors.black : Colors.white;
}
@override
Widget build(BuildContext context) {
final label = status.localized(context);
final bg = _badgeColor(context);
final fg = _textColor(bg);
final l10n = AppLocalizations.of(context)!;
final view = operationStatusView(
l10n,
Theme.of(context).colorScheme,
status,
);
final label = view.label;
final bg = view.backgroundColor;
final fg = view.foregroundColor;
return badges.Badge(
badgeStyle: badges.BadgeStyle(
shape: badges.BadgeShape.square,
badgeColor: bg,
borderRadius: BorderRadius.circular(12), // fully rounded
borderRadius: BorderRadius.circular(12), // fully rounded
padding: const EdgeInsets.symmetric(
horizontal: 6, vertical: 2 // tighter padding
horizontal: 6,
vertical: 2, // tighter padding
),
),
badgeContent: Text(
label.toUpperCase(), // or keep sentence case
label.toUpperCase(), // or keep sentence case
style: TextStyle(
color: fg,
fontSize: 11, // smaller text
fontWeight: FontWeight.w500, // medium weight
fontSize: 11, // smaller text
fontWeight: FontWeight.w500, // medium weight
),
),
);