Files
pad_scanner/lib/widgets/status_bar.dart
2026-05-18 14:54:07 +08:00

62 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
/// Status bar dot colors matching PRD requirements.
enum StatusDotColor {
blue, // idle / waiting
orange, // submitting
green, // success
red, // error (invalid code / submit failure / duplicate)
yellow, // network error
amber, // warning (duplicate box number)
}
/// Reusable bottom status bar with a colored dot and text.
class StatusBar extends StatelessWidget {
final StatusDotColor dotColor;
final String text;
const StatusBar({super.key, required this.dotColor, required this.text});
Color _resolveDotColor(BuildContext context) {
return switch (dotColor) {
StatusDotColor.blue => Colors.blue,
StatusDotColor.orange => Colors.orange,
StatusDotColor.green => Colors.green,
StatusDotColor.red => Colors.red,
StatusDotColor.yellow => Colors.yellow.shade700,
StatusDotColor.amber => Colors.amber,
};
}
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return Container(
width: double.infinity,
height: 28,
padding: const EdgeInsets.symmetric(horizontal: 12),
color: colorScheme.surfaceContainerHighest,
child: Row(
children: [
Container(
width: 6,
height: 6,
decoration: BoxDecoration(
color: _resolveDotColor(context),
shape: BoxShape.circle,
),
),
const SizedBox(width: 7),
Expanded(
child: Text(
text,
style: const TextStyle(fontSize: 11),
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
}