83 lines
2.3 KiB
Dart
83 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../api/models.dart';
|
|
|
|
class StepProgress extends StatelessWidget {
|
|
final List<StepResult> steps;
|
|
final int totalSteps;
|
|
|
|
const StepProgress({
|
|
super.key,
|
|
required this.steps,
|
|
required this.totalSteps,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (totalSteps == 0) return const SizedBox.shrink();
|
|
|
|
return Column(
|
|
children: steps.map((step) {
|
|
IconData icon;
|
|
Color color;
|
|
switch (step.status) {
|
|
case RunStatus.pending:
|
|
icon = Icons.circle_outlined;
|
|
color = Colors.grey;
|
|
break;
|
|
case RunStatus.running:
|
|
icon = Icons.pending;
|
|
color = Colors.blue;
|
|
break;
|
|
case RunStatus.completed:
|
|
icon = Icons.check_circle;
|
|
color = Colors.green;
|
|
break;
|
|
case RunStatus.error:
|
|
icon = Icons.error;
|
|
color = Colors.red;
|
|
break;
|
|
}
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
|
child: Row(
|
|
children: [
|
|
Icon(icon, color: color, size: 24),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
step.title.isNotEmpty
|
|
? step.title
|
|
: 'Step ${step.stepIndex + 1}',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
color: step.status == RunStatus.running ? color : null,
|
|
),
|
|
),
|
|
if (step.status == RunStatus.error && step.error.isNotEmpty)
|
|
Text(
|
|
step.error,
|
|
style: const TextStyle(color: Colors.red, fontSize: 12),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Text(
|
|
step.status.name.toUpperCase(),
|
|
style: TextStyle(
|
|
fontSize: 11,
|
|
color: color,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}).toList(),
|
|
);
|
|
}
|
|
}
|