1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import { TaskStatusColors } from '../constants/Colors';
import type { TaskStatus } from '../lib/api';
interface TaskStatusBadgeProps {
status: TaskStatus;
showLabel?: boolean;
size?: 'small' | 'medium' | 'large';
}
const statusLabels: Record<TaskStatus, string> = {
pending: 'Pending',
initializing: 'Initializing',
starting: 'Starting',
running: 'Running',
paused: 'Paused',
blocked: 'Blocked',
done: 'Done',
failed: 'Failed',
merged: 'Merged',
};
export function TaskStatusBadge({
status,
showLabel = false,
size = 'medium',
}: TaskStatusBadgeProps) {
const colors = TaskStatusColors[status] || TaskStatusColors.pending;
const dotSize = {
small: 8,
medium: 10,
large: 12,
}[size];
const fontSize = {
small: 10,
medium: 12,
large: 14,
}[size];
const paddingHorizontal = {
small: 6,
medium: 8,
large: 10,
}[size];
const paddingVertical = {
small: 2,
medium: 4,
large: 6,
}[size];
if (showLabel) {
return (
<View
style={[
styles.badge,
{
backgroundColor: colors.bg,
paddingHorizontal,
paddingVertical,
},
]}
>
<View
style={[
styles.dot,
{
backgroundColor: colors.dot,
width: dotSize,
height: dotSize,
},
]}
/>
<Text style={[styles.label, { color: colors.text, fontSize }]}>
{statusLabels[status]}
</Text>
</View>
);
}
return (
<View
style={[
styles.dot,
{
backgroundColor: colors.dot,
width: dotSize,
height: dotSize,
},
]}
/>
);
}
const styles = StyleSheet.create({
badge: {
flexDirection: 'row',
alignItems: 'center',
borderRadius: 999,
gap: 6,
},
dot: {
borderRadius: 999,
},
label: {
fontWeight: '500',
},
});
|