63 lines
1.7 KiB
Dart
63 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../core/theme/app_typography.dart';
|
|
import '../../../../shared/models/grn_model.dart';
|
|
import '../../../../shared/widgets/app_status_chip.dart';
|
|
|
|
class GrnStatusChip extends StatelessWidget {
|
|
const GrnStatusChip({
|
|
super.key,
|
|
required this.status,
|
|
this.compact = false,
|
|
this.forTable = false,
|
|
});
|
|
|
|
final String status;
|
|
final bool compact;
|
|
final bool forTable;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final secondary = Theme.of(context).colorScheme.secondary;
|
|
final (color, label) = _resolveStatus(status, secondary);
|
|
if (forTable) {
|
|
return TableStatusBadge(
|
|
label: label,
|
|
color: color,
|
|
compact: compact,
|
|
fixedWidth: kTableStatusChipWidth,
|
|
);
|
|
}
|
|
|
|
return Chip(
|
|
label: Text(
|
|
label,
|
|
style: compact
|
|
? AppTypography.caption1(
|
|
weight: AppTypography.semiBold,
|
|
color: color,
|
|
)
|
|
: AppTypography.label3(
|
|
weight: AppTypography.semiBold,
|
|
color: color,
|
|
),
|
|
),
|
|
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, Color secondary) {
|
|
switch (raw.toUpperCase()) {
|
|
case 'POSTED':
|
|
return (secondary, grnStatusLabel(raw));
|
|
case 'CANCELLED':
|
|
return (Colors.grey.shade700, grnStatusLabel(raw));
|
|
default:
|
|
return (secondary, grnStatusLabel(raw));
|
|
}
|
|
}
|
|
}
|