Files
AcWeb/ac_web/lib/Widgets/AgentStatusIndicator.dart
T

40 lines
1.1 KiB
Dart

import 'package:ac_web/Api/Dtos/EAgentStatus.dart';
import 'package:flutter/material.dart';
/// Small colored circle that visualizes the current [EAgentStatus] of an agent.
///
/// Green = available, blue = working, red = error, white = unavailable.
class AgentStatusIndicator extends StatelessWidget {
const AgentStatusIndicator({super.key, required this.status, this.size = 16});
final EAgentStatus status;
final double size;
static Color colorOf(EAgentStatus status) {
switch (status) {
case EAgentStatus.available:
return Colors.green;
case EAgentStatus.working:
return Colors.blue;
case EAgentStatus.error:
return Colors.red;
case EAgentStatus.offline:
case EAgentStatus.unknown:
return Colors.white;
}
}
@override
Widget build(BuildContext context) {
return Container(
width: size,
height: size,
decoration: BoxDecoration(
color: colorOf(status),
shape: BoxShape.circle,
border: Border.all(color: Colors.black26),
),
);
}
}