47 lines
1.2 KiB
Dart
47 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../core/constants/enums.dart';
|
|
|
|
class AppStatusChip extends StatelessWidget {
|
|
const AppStatusChip({
|
|
super.key,
|
|
required this.status,
|
|
this.compact = false,
|
|
});
|
|
|
|
final String status;
|
|
final bool compact;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final (color, label) = _resolveStatus(status);
|
|
return Chip(
|
|
label: Text(
|
|
label,
|
|
style: TextStyle(
|
|
color: color,
|
|
fontSize: compact ? 11 : 12,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
backgroundColor: color.withValues(alpha: 0.12),
|
|
side: BorderSide(color: color.withValues(alpha: 0.3)),
|
|
visualDensity: compact ? VisualDensity.compact : VisualDensity.standard,
|
|
padding: compact ? EdgeInsets.zero : null,
|
|
);
|
|
}
|
|
|
|
(Color, String) _resolveStatus(String raw) {
|
|
switch (raw.toLowerCase()) {
|
|
case 'active':
|
|
return (Colors.green.shade700, EntityStatus.active.label);
|
|
case 'inactive':
|
|
return (Colors.grey.shade700, EntityStatus.inactive.label);
|
|
case 'locked':
|
|
return (Colors.orange.shade800, 'Locked');
|
|
default:
|
|
return (Colors.blueGrey, raw);
|
|
}
|
|
}
|
|
}
|