Skip to content

Commit df27ccc

Browse files
committed
feat: job status icon
1 parent 0fc0d8e commit df27ccc

File tree

1 file changed

+42
-13
lines changed

1 file changed

+42
-13
lines changed

lib/ui/project/jobs/jobs_tab.dart

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,47 @@ class JobWidget extends StatelessWidget {
3030

3131
@override
3232
Widget build(BuildContext context) {
33-
return Card(
34-
child: Padding(
35-
padding: EdgeInsets.all(8),
36-
child: Column(
37-
crossAxisAlignment: CrossAxisAlignment.start,
38-
children: <Widget>[
39-
Text("#${job.id} ${job.ref} ${job.user.name}"),
40-
Text(job.status),
41-
Text(job.stage),
42-
Text(job.name),
43-
],
44-
),
45-
));
33+
return Card(child: Padding(padding: EdgeInsets.all(8), child: _item(job)));
4634
}
35+
36+
Widget _item(Jobs job) {
37+
return Column(
38+
crossAxisAlignment: CrossAxisAlignment.start,
39+
children: <Widget>[
40+
Text(job.commit.title, style: TextStyle(fontWeight: FontWeight.bold)),
41+
Row(
42+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
43+
children: <Widget>[
44+
Text("#${job.id} ${job.ref}"),
45+
Row(
46+
children: <Widget>[
47+
Padding(
48+
child: Text(job.status),
49+
padding: EdgeInsets.all(3),
50+
),
51+
statusIcons.containsKey(job.status)
52+
? statusIcons[job.status]
53+
: Icon(Icons.error, size: 18)
54+
],
55+
)
56+
],
57+
),
58+
Row(
59+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
60+
children: <Widget>[
61+
Text(job.stage),
62+
Text(job.name),
63+
],
64+
),
65+
],
66+
);
67+
}
68+
69+
static get statusIcons => {
70+
"success": Icon(Icons.check_circle, color: Colors.green, size: 18),
71+
"manual": Icon(Icons.build, size: 18),
72+
"failed": Icon(Icons.error_outline, color: Colors.redAccent, size: 18),
73+
"skipped": Icon(Icons.skip_next, size: 18),
74+
"canceled": Icon(Icons.cancel, size: 18)
75+
};
4776
}

0 commit comments

Comments
 (0)