48 lines
1.1 KiB
Dart
48 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../api/models.dart';
|
|
|
|
class RunStatusBadge extends StatelessWidget {
|
|
final RunStatus status;
|
|
|
|
const RunStatusBadge({super.key, required this.status});
|
|
|
|
Color _color(BuildContext context) {
|
|
switch (status) {
|
|
case RunStatus.pending:
|
|
return Colors.amber;
|
|
case RunStatus.running:
|
|
return Colors.blue;
|
|
case RunStatus.completed:
|
|
return Colors.green;
|
|
case RunStatus.error:
|
|
return Colors.red;
|
|
}
|
|
}
|
|
|
|
IconData _icon() {
|
|
switch (status) {
|
|
case RunStatus.pending:
|
|
return Icons.schedule;
|
|
case RunStatus.running:
|
|
return Icons.play_circle_outline;
|
|
case RunStatus.completed:
|
|
return Icons.check_circle;
|
|
case RunStatus.error:
|
|
return Icons.error;
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final c = _color(context);
|
|
return Chip(
|
|
avatar: Icon(_icon(), size: 16, color: c),
|
|
label: Text(
|
|
status.name.toUpperCase(),
|
|
style: TextStyle(color: c, fontWeight: FontWeight.bold, fontSize: 12),
|
|
),
|
|
backgroundColor: c.withValues(alpha: 0.1),
|
|
);
|
|
}
|
|
}
|