b37c46fb9c
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
61 lines
1.5 KiB
Dart
61 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../core/theme/context_tokens.dart';
|
|
|
|
enum OrderStatus { draft, pending, approved, rejected }
|
|
|
|
extension OrderStatusLabel on OrderStatus {
|
|
String get label {
|
|
switch (this) {
|
|
case OrderStatus.draft:
|
|
return '草稿';
|
|
case OrderStatus.pending:
|
|
return '待审核';
|
|
case OrderStatus.approved:
|
|
return '已审核';
|
|
case OrderStatus.rejected:
|
|
return '已拒绝';
|
|
}
|
|
}
|
|
}
|
|
|
|
class StatusBadge extends StatelessWidget {
|
|
final OrderStatus status;
|
|
const StatusBadge(this.status, {super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Color bg;
|
|
final Color fg;
|
|
switch (status) {
|
|
case OrderStatus.draft:
|
|
bg = const Color(0xFFF5F5F5);
|
|
fg = context.tokens.muted;
|
|
break;
|
|
case OrderStatus.pending:
|
|
bg = const Color(0xFFFFF3E0);
|
|
fg = context.tokens.accent;
|
|
break;
|
|
case OrderStatus.approved:
|
|
bg = const Color(0xFFE8F5E9);
|
|
fg = context.tokens.success;
|
|
break;
|
|
case OrderStatus.rejected:
|
|
bg = const Color(0xFFFFEBEE);
|
|
fg = context.tokens.danger;
|
|
break;
|
|
}
|
|
return Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
|
decoration: BoxDecoration(
|
|
color: bg,
|
|
borderRadius: BorderRadius.circular(3),
|
|
),
|
|
child: Text(
|
|
status.label,
|
|
style: TextStyle(
|
|
color: fg, fontSize: 12, fontWeight: FontWeight.w500),
|
|
),
|
|
);
|
|
}
|
|
}
|