react-native-metrify 0.1.0-alpha.1 → 0.1.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -51
- package/package.json +1 -2
- package/src/core/animation/index.ts +0 -113
- package/src/core/animation/index.web.ts +0 -112
- package/src/core/hooks/index.ts +0 -66
- package/src/core/index.ts +0 -26
- package/src/core/layout/index.ts +0 -101
- package/src/core/math/index.ts +0 -72
- package/src/core/package.json +0 -13
- package/src/core/theme/ThemeProvider.tsx +0 -36
- package/src/core/theme/index.ts +0 -5
- package/src/core/theme/themes.ts +0 -132
- package/src/core/types/index.ts +0 -164
- package/src/core/utils/responsive.ts +0 -203
- package/src/core/utils/time.ts +0 -100
- package/src/index.ts +0 -13
- package/src/renderer-svg/adapters/index.ts +0 -84
- package/src/renderer-svg/index.ts +0 -8
- package/src/renderer-svg/package.json +0 -17
- package/src/renderer-svg/paths/arc.ts +0 -93
- package/src/renderer-svg/paths/index.ts +0 -6
- package/src/renderer-svg/paths/line.ts +0 -83
- package/src/renderer-svg/paths/rect.ts +0 -80
- package/src/renderer-svg/primitives/AnimatedCircle.tsx +0 -48
- package/src/renderer-svg/primitives/AnimatedPath.tsx +0 -48
- package/src/renderer-svg/primitives/Text.tsx +0 -73
- package/src/renderer-svg/primitives/index.ts +0 -6
- package/src/widgets/AreaChart/AreaChart.tsx +0 -213
- package/src/widgets/AreaChart/index.ts +0 -2
- package/src/widgets/AreaChart/types.ts +0 -34
- package/src/widgets/BarChart/BarChart.tsx +0 -249
- package/src/widgets/BarChart/index.ts +0 -10
- package/src/widgets/BarChart/types.ts +0 -27
- package/src/widgets/BoxPlot/BoxPlot.tsx +0 -252
- package/src/widgets/BoxPlot/index.ts +0 -2
- package/src/widgets/BoxPlot/types.ts +0 -27
- package/src/widgets/BubbleChart/BubbleChart.tsx +0 -175
- package/src/widgets/BubbleChart/index.ts +0 -2
- package/src/widgets/BubbleChart/types.ts +0 -33
- package/src/widgets/CandlestickChart/CandlestickChart.tsx +0 -204
- package/src/widgets/CandlestickChart/index.ts +0 -2
- package/src/widgets/CandlestickChart/types.ts +0 -29
- package/src/widgets/FunnelChart/FunnelChart.tsx +0 -172
- package/src/widgets/FunnelChart/index.ts +0 -2
- package/src/widgets/FunnelChart/types.ts +0 -22
- package/src/widgets/Gauge/Gauge.tsx +0 -235
- package/src/widgets/Gauge/index.ts +0 -5
- package/src/widgets/Gauge/types.ts +0 -19
- package/src/widgets/GroupedBarChart/GroupedBarChart.tsx +0 -190
- package/src/widgets/GroupedBarChart/index.ts +0 -2
- package/src/widgets/GroupedBarChart/types.ts +0 -30
- package/src/widgets/Heatmap/Heatmap.tsx +0 -216
- package/src/widgets/Heatmap/index.ts +0 -2
- package/src/widgets/Heatmap/types.ts +0 -27
- package/src/widgets/Histogram/Histogram.tsx +0 -173
- package/src/widgets/Histogram/index.ts +0 -2
- package/src/widgets/Histogram/types.ts +0 -18
- package/src/widgets/HorizontalBarChart/HorizontalBarChart.tsx +0 -125
- package/src/widgets/HorizontalBarChart/index.ts +0 -2
- package/src/widgets/HorizontalBarChart/types.ts +0 -23
- package/src/widgets/KPI/KPI.tsx +0 -222
- package/src/widgets/KPI/index.ts +0 -5
- package/src/widgets/KPI/types.ts +0 -19
- package/src/widgets/LineChart/LineChart.tsx +0 -364
- package/src/widgets/LineChart/index.ts +0 -10
- package/src/widgets/LineChart/types.ts +0 -34
- package/src/widgets/MultiLineSparkline/MultiLineSparkline.tsx +0 -234
- package/src/widgets/MultiLineSparkline/index.ts +0 -10
- package/src/widgets/MultiLineSparkline/types.ts +0 -25
- package/src/widgets/PieChart/PieChart.tsx +0 -275
- package/src/widgets/PieChart/index.ts +0 -10
- package/src/widgets/PieChart/types.ts +0 -26
- package/src/widgets/Progress/Progress.tsx +0 -201
- package/src/widgets/Progress/index.ts +0 -5
- package/src/widgets/Progress/types.ts +0 -19
- package/src/widgets/RadarChart/RadarChart.tsx +0 -213
- package/src/widgets/RadarChart/index.ts +0 -2
- package/src/widgets/RadarChart/types.ts +0 -29
- package/src/widgets/SankeyDiagram/SankeyDiagram.tsx +0 -272
- package/src/widgets/SankeyDiagram/index.ts +0 -2
- package/src/widgets/SankeyDiagram/types.ts +0 -29
- package/src/widgets/ScatterPlot/ScatterPlot.tsx +0 -167
- package/src/widgets/ScatterPlot/index.ts +0 -2
- package/src/widgets/ScatterPlot/types.ts +0 -32
- package/src/widgets/Sparkline/Sparkline.tsx +0 -203
- package/src/widgets/Sparkline/index.ts +0 -5
- package/src/widgets/Sparkline/types.ts +0 -18
- package/src/widgets/StackedBarChart/StackedBarChart.tsx +0 -181
- package/src/widgets/StackedBarChart/index.ts +0 -2
- package/src/widgets/StackedBarChart/types.ts +0 -29
- package/src/widgets/SunburstChart/SunburstChart.tsx +0 -176
- package/src/widgets/SunburstChart/index.ts +0 -2
- package/src/widgets/SunburstChart/types.ts +0 -22
- package/src/widgets/Treemap/Treemap.tsx +0 -191
- package/src/widgets/Treemap/index.ts +0 -2
- package/src/widgets/Treemap/types.ts +0 -23
- package/src/widgets/WaterfallChart/WaterfallChart.tsx +0 -226
- package/src/widgets/WaterfallChart/index.ts +0 -2
- package/src/widgets/WaterfallChart/types.ts +0 -26
- package/src/widgets/index.ts +0 -40
- package/src/widgets/package.json +0 -18
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PieChart Widget - Pie and Donut charts for proportions
|
|
3
|
-
*/
|
|
4
|
-
import React, { memo, useMemo } from 'react';
|
|
5
|
-
import { View, Text as RNText, StyleSheet } from 'react-native';
|
|
6
|
-
import Svg, { Path } from 'react-native-svg';
|
|
7
|
-
import {
|
|
8
|
-
useWidgetDimensions,
|
|
9
|
-
useWidgetTheme,
|
|
10
|
-
} from '../../core';
|
|
11
|
-
import { createDonutArcPath, createFilledArcPath } from '../../renderer-svg';
|
|
12
|
-
import { PieChartWidgetProps } from './types';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* PieChart Widget Component
|
|
16
|
-
*/
|
|
17
|
-
export const PieChart = memo<PieChartWidgetProps>(({
|
|
18
|
-
data: widgetData,
|
|
19
|
-
width,
|
|
20
|
-
height,
|
|
21
|
-
loading = false,
|
|
22
|
-
theme: themeOverride,
|
|
23
|
-
variant = 'pie',
|
|
24
|
-
innerRadius = 0.5,
|
|
25
|
-
showLabels = true,
|
|
26
|
-
showValues = false,
|
|
27
|
-
showPercentages = true,
|
|
28
|
-
size: customSize,
|
|
29
|
-
testID,
|
|
30
|
-
}) => {
|
|
31
|
-
const theme = useWidgetTheme(themeOverride);
|
|
32
|
-
const dimensions = useWidgetDimensions(width, height, 300, 300);
|
|
33
|
-
|
|
34
|
-
// Handle states
|
|
35
|
-
if (loading) {
|
|
36
|
-
return (
|
|
37
|
-
<View
|
|
38
|
-
style={[
|
|
39
|
-
styles.container,
|
|
40
|
-
{
|
|
41
|
-
width: dimensions.width,
|
|
42
|
-
height: dimensions.height,
|
|
43
|
-
backgroundColor: theme.colors.surface,
|
|
44
|
-
borderRadius: theme.radius.md,
|
|
45
|
-
},
|
|
46
|
-
]}
|
|
47
|
-
testID={`${testID}-loading`}
|
|
48
|
-
>
|
|
49
|
-
<RNText style={[styles.loadingText, { color: theme.colors.textSecondary }]}>
|
|
50
|
-
Loading...
|
|
51
|
-
</RNText>
|
|
52
|
-
</View>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!widgetData || !widgetData.segments || widgetData.segments.length === 0) {
|
|
57
|
-
return (
|
|
58
|
-
<View
|
|
59
|
-
style={[
|
|
60
|
-
styles.container,
|
|
61
|
-
{
|
|
62
|
-
width: dimensions.width,
|
|
63
|
-
height: dimensions.height,
|
|
64
|
-
backgroundColor: theme.colors.surface,
|
|
65
|
-
borderRadius: theme.radius.md,
|
|
66
|
-
},
|
|
67
|
-
]}
|
|
68
|
-
testID={`${testID}-empty`}
|
|
69
|
-
>
|
|
70
|
-
<RNText style={[styles.emptyText, { color: theme.colors.textSecondary }]}>
|
|
71
|
-
No data
|
|
72
|
-
</RNText>
|
|
73
|
-
</View>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const { segments, title } = widgetData;
|
|
78
|
-
|
|
79
|
-
// Calculate total
|
|
80
|
-
const total = useMemo(
|
|
81
|
-
() => segments.reduce((sum, seg) => sum + seg.value, 0),
|
|
82
|
-
[segments]
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// Calculate chart size
|
|
86
|
-
const padding = theme.spacing.md;
|
|
87
|
-
const titleHeight = title ? theme.fontScale.md + theme.spacing.sm : 0;
|
|
88
|
-
const legendHeight = showLabels ? segments.length * 24 + theme.spacing.md : 0;
|
|
89
|
-
|
|
90
|
-
const availableHeight = dimensions.height - padding * 2 - titleHeight - legendHeight;
|
|
91
|
-
const availableWidth = dimensions.width - padding * 2;
|
|
92
|
-
|
|
93
|
-
const chartSize = customSize || Math.min(availableHeight, availableWidth);
|
|
94
|
-
const center = chartSize / 2;
|
|
95
|
-
const radius = (chartSize - padding) / 2;
|
|
96
|
-
const innerR = variant === 'donut' ? radius * innerRadius : 0;
|
|
97
|
-
|
|
98
|
-
// Generate segments
|
|
99
|
-
const pieSegments = useMemo(() => {
|
|
100
|
-
let currentAngle = 0;
|
|
101
|
-
|
|
102
|
-
return segments.map(segment => {
|
|
103
|
-
const percentage = (segment.value / total) * 100;
|
|
104
|
-
const angle = (segment.value / total) * 360;
|
|
105
|
-
const startAngle = currentAngle;
|
|
106
|
-
const endAngle = currentAngle + angle;
|
|
107
|
-
|
|
108
|
-
currentAngle = endAngle;
|
|
109
|
-
|
|
110
|
-
const path = variant === 'donut'
|
|
111
|
-
? createDonutArcPath({
|
|
112
|
-
cx: center,
|
|
113
|
-
cy: center,
|
|
114
|
-
radius,
|
|
115
|
-
innerRadius: innerR,
|
|
116
|
-
startAngle,
|
|
117
|
-
endAngle,
|
|
118
|
-
})
|
|
119
|
-
: createFilledArcPath({
|
|
120
|
-
cx: center,
|
|
121
|
-
cy: center,
|
|
122
|
-
radius,
|
|
123
|
-
startAngle,
|
|
124
|
-
endAngle,
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
path,
|
|
129
|
-
color: segment.color,
|
|
130
|
-
label: segment.label,
|
|
131
|
-
value: segment.value,
|
|
132
|
-
percentage,
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
}, [segments, total, center, radius, innerR, variant]);
|
|
136
|
-
|
|
137
|
-
return (
|
|
138
|
-
<View
|
|
139
|
-
style={[
|
|
140
|
-
styles.wrapper,
|
|
141
|
-
{
|
|
142
|
-
width: dimensions.width,
|
|
143
|
-
height: dimensions.height,
|
|
144
|
-
backgroundColor: theme.colors.surface,
|
|
145
|
-
borderRadius: theme.radius.md,
|
|
146
|
-
padding,
|
|
147
|
-
},
|
|
148
|
-
]}
|
|
149
|
-
testID={testID}
|
|
150
|
-
>
|
|
151
|
-
{/* Title */}
|
|
152
|
-
{title && (
|
|
153
|
-
<RNText
|
|
154
|
-
style={[
|
|
155
|
-
styles.title,
|
|
156
|
-
{
|
|
157
|
-
color: theme.colors.text,
|
|
158
|
-
fontSize: theme.fontScale.md,
|
|
159
|
-
fontWeight: 'bold',
|
|
160
|
-
marginBottom: theme.spacing.sm,
|
|
161
|
-
},
|
|
162
|
-
]}
|
|
163
|
-
>
|
|
164
|
-
{title}
|
|
165
|
-
</RNText>
|
|
166
|
-
)}
|
|
167
|
-
|
|
168
|
-
{/* Chart */}
|
|
169
|
-
<View style={styles.chartContainer}>
|
|
170
|
-
<Svg width={chartSize} height={chartSize}>
|
|
171
|
-
{pieSegments.map((segment, index) => (
|
|
172
|
-
<Path
|
|
173
|
-
key={`segment-${index}`}
|
|
174
|
-
d={segment.path}
|
|
175
|
-
fill={segment.color}
|
|
176
|
-
/>
|
|
177
|
-
))}
|
|
178
|
-
</Svg>
|
|
179
|
-
</View>
|
|
180
|
-
|
|
181
|
-
{/* Legend */}
|
|
182
|
-
{showLabels && (
|
|
183
|
-
<View style={styles.legend}>
|
|
184
|
-
{pieSegments.map((segment, index) => (
|
|
185
|
-
<View key={`legend-${index}`} style={styles.legendItem}>
|
|
186
|
-
<View
|
|
187
|
-
style={[
|
|
188
|
-
styles.legendColor,
|
|
189
|
-
{ backgroundColor: segment.color },
|
|
190
|
-
]}
|
|
191
|
-
/>
|
|
192
|
-
<View style={styles.legendTextContainer}>
|
|
193
|
-
<RNText
|
|
194
|
-
style={[
|
|
195
|
-
styles.legendLabel,
|
|
196
|
-
{
|
|
197
|
-
color: theme.colors.text,
|
|
198
|
-
fontSize: theme.fontScale.sm,
|
|
199
|
-
},
|
|
200
|
-
]}
|
|
201
|
-
>
|
|
202
|
-
{segment.label}
|
|
203
|
-
</RNText>
|
|
204
|
-
<RNText
|
|
205
|
-
style={[
|
|
206
|
-
styles.legendValue,
|
|
207
|
-
{
|
|
208
|
-
color: theme.colors.textSecondary,
|
|
209
|
-
fontSize: theme.fontScale.xs,
|
|
210
|
-
},
|
|
211
|
-
]}
|
|
212
|
-
>
|
|
213
|
-
{showValues && `${segment.value} `}
|
|
214
|
-
{showPercentages && `(${segment.percentage.toFixed(1)}%)`}
|
|
215
|
-
</RNText>
|
|
216
|
-
</View>
|
|
217
|
-
</View>
|
|
218
|
-
))}
|
|
219
|
-
</View>
|
|
220
|
-
)}
|
|
221
|
-
</View>
|
|
222
|
-
);
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
PieChart.displayName = 'PieChart';
|
|
226
|
-
|
|
227
|
-
const styles = StyleSheet.create({
|
|
228
|
-
wrapper: {
|
|
229
|
-
justifyContent: 'flex-start',
|
|
230
|
-
alignItems: 'center',
|
|
231
|
-
},
|
|
232
|
-
container: {
|
|
233
|
-
justifyContent: 'center',
|
|
234
|
-
alignItems: 'center',
|
|
235
|
-
},
|
|
236
|
-
loadingText: {
|
|
237
|
-
fontSize: 16,
|
|
238
|
-
},
|
|
239
|
-
emptyText: {
|
|
240
|
-
fontSize: 16,
|
|
241
|
-
},
|
|
242
|
-
title: {
|
|
243
|
-
textAlign: 'center',
|
|
244
|
-
width: '100%',
|
|
245
|
-
},
|
|
246
|
-
chartContainer: {
|
|
247
|
-
alignItems: 'center',
|
|
248
|
-
justifyContent: 'center',
|
|
249
|
-
},
|
|
250
|
-
legend: {
|
|
251
|
-
width: '100%',
|
|
252
|
-
marginTop: 16,
|
|
253
|
-
},
|
|
254
|
-
legendItem: {
|
|
255
|
-
flexDirection: 'row',
|
|
256
|
-
alignItems: 'center',
|
|
257
|
-
marginBottom: 8,
|
|
258
|
-
},
|
|
259
|
-
legendColor: {
|
|
260
|
-
width: 16,
|
|
261
|
-
height: 16,
|
|
262
|
-
borderRadius: 4,
|
|
263
|
-
marginRight: 8,
|
|
264
|
-
},
|
|
265
|
-
legendTextContainer: {
|
|
266
|
-
flex: 1,
|
|
267
|
-
flexDirection: 'row',
|
|
268
|
-
justifyContent: 'space-between',
|
|
269
|
-
alignItems: 'center',
|
|
270
|
-
},
|
|
271
|
-
legendLabel: {
|
|
272
|
-
fontWeight: '600',
|
|
273
|
-
},
|
|
274
|
-
legendValue: {},
|
|
275
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PieChart Widget types
|
|
3
|
-
*/
|
|
4
|
-
import { BaseWidgetProps } from '../../core/types';
|
|
5
|
-
|
|
6
|
-
export interface PieSegment {
|
|
7
|
-
value: number;
|
|
8
|
-
label: string;
|
|
9
|
-
color: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface PieChartData {
|
|
13
|
-
segments: PieSegment[];
|
|
14
|
-
title?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type PieChartVariant = 'pie' | 'donut';
|
|
18
|
-
|
|
19
|
-
export interface PieChartWidgetProps extends BaseWidgetProps<PieChartData> {
|
|
20
|
-
variant?: PieChartVariant;
|
|
21
|
-
innerRadius?: number; // For donut chart (0-1, percentage of outer radius)
|
|
22
|
-
showLabels?: boolean;
|
|
23
|
-
showValues?: boolean;
|
|
24
|
-
showPercentages?: boolean;
|
|
25
|
-
size?: number;
|
|
26
|
-
}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Progress Widget - Simple linear progress with meaning
|
|
3
|
-
* SVG rects + animation
|
|
4
|
-
*/
|
|
5
|
-
import React, { memo, useMemo } from 'react';
|
|
6
|
-
import { View, Text as RNText, StyleSheet } from 'react-native';
|
|
7
|
-
import Svg, { Rect } from 'react-native-svg';
|
|
8
|
-
import {
|
|
9
|
-
useWidgetDimensions,
|
|
10
|
-
useWidgetTheme,
|
|
11
|
-
clamp,
|
|
12
|
-
normalize,
|
|
13
|
-
} from '../../core';
|
|
14
|
-
import { createRoundedRectPath, AnimatedPath } from '../../renderer-svg';
|
|
15
|
-
import { ProgressWidgetProps } from './types';
|
|
16
|
-
|
|
17
|
-
// AnimatedRect removed for Expo Go compatibility
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Progress Widget Component
|
|
21
|
-
*/
|
|
22
|
-
export const Progress = memo<ProgressWidgetProps>(({
|
|
23
|
-
data,
|
|
24
|
-
width,
|
|
25
|
-
height,
|
|
26
|
-
loading = false,
|
|
27
|
-
theme: themeOverride,
|
|
28
|
-
animated = true,
|
|
29
|
-
variant = 'bar',
|
|
30
|
-
barHeight = 12,
|
|
31
|
-
showValue = true,
|
|
32
|
-
testID,
|
|
33
|
-
}) => {
|
|
34
|
-
const theme = useWidgetTheme(themeOverride);
|
|
35
|
-
const dimensions = useWidgetDimensions(
|
|
36
|
-
width,
|
|
37
|
-
height,
|
|
38
|
-
300,
|
|
39
|
-
variant === 'bar' ? 80 : 200
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
// Handle states
|
|
43
|
-
if (loading) {
|
|
44
|
-
return (
|
|
45
|
-
<View
|
|
46
|
-
style={[
|
|
47
|
-
styles.container,
|
|
48
|
-
{
|
|
49
|
-
width: dimensions.width,
|
|
50
|
-
height: dimensions.height,
|
|
51
|
-
backgroundColor: theme.colors.surface,
|
|
52
|
-
borderRadius: theme.radius.md,
|
|
53
|
-
},
|
|
54
|
-
]}
|
|
55
|
-
testID={`${testID}-loading`}
|
|
56
|
-
>
|
|
57
|
-
<RNText style={[styles.loadingText, { color: theme.colors.textSecondary }]}>
|
|
58
|
-
Loading...
|
|
59
|
-
</RNText>
|
|
60
|
-
</View>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!data) {
|
|
65
|
-
return (
|
|
66
|
-
<View
|
|
67
|
-
style={[
|
|
68
|
-
styles.container,
|
|
69
|
-
{
|
|
70
|
-
width: dimensions.width,
|
|
71
|
-
height: dimensions.height,
|
|
72
|
-
backgroundColor: theme.colors.surface,
|
|
73
|
-
borderRadius: theme.radius.md,
|
|
74
|
-
},
|
|
75
|
-
]}
|
|
76
|
-
testID={`${testID}-empty`}
|
|
77
|
-
>
|
|
78
|
-
<RNText style={[styles.emptyText, { color: theme.colors.textSecondary }]}>
|
|
79
|
-
No data
|
|
80
|
-
</RNText>
|
|
81
|
-
</View>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const { value, max, label, showPercentage = true } = data;
|
|
86
|
-
const normalizedValue = clamp(value, 0, max);
|
|
87
|
-
const percentage = max > 0 ? (normalizedValue / max) * 100 : 0;
|
|
88
|
-
|
|
89
|
-
// Calculate progress (no animation for Expo Go)
|
|
90
|
-
const progressValue = normalize(normalizedValue, 0, max);
|
|
91
|
-
|
|
92
|
-
// Calculate bar dimensions
|
|
93
|
-
const barWidth = dimensions.width - theme.spacing.md * 2;
|
|
94
|
-
const barY = label
|
|
95
|
-
? theme.spacing.md + theme.fontScale.sm + theme.spacing.xs
|
|
96
|
-
: theme.spacing.md;
|
|
97
|
-
|
|
98
|
-
// Calculate bar width
|
|
99
|
-
const currentBarWidth = progressValue * barWidth;
|
|
100
|
-
|
|
101
|
-
// Display text
|
|
102
|
-
const displayValue = useMemo(() => {
|
|
103
|
-
if (!showValue) return null;
|
|
104
|
-
if (showPercentage) return `${percentage.toFixed(0)}%`;
|
|
105
|
-
return `${normalizedValue} / ${max}`;
|
|
106
|
-
}, [showValue, showPercentage, percentage, normalizedValue, max]);
|
|
107
|
-
|
|
108
|
-
return (
|
|
109
|
-
<View
|
|
110
|
-
style={[
|
|
111
|
-
styles.container,
|
|
112
|
-
{
|
|
113
|
-
width: dimensions.width,
|
|
114
|
-
height: dimensions.height,
|
|
115
|
-
backgroundColor: theme.colors.surface,
|
|
116
|
-
borderRadius: theme.radius.md,
|
|
117
|
-
padding: theme.spacing.md,
|
|
118
|
-
},
|
|
119
|
-
]}
|
|
120
|
-
testID={testID}
|
|
121
|
-
>
|
|
122
|
-
{/* Label */}
|
|
123
|
-
{label && (
|
|
124
|
-
<RNText
|
|
125
|
-
style={[
|
|
126
|
-
styles.label,
|
|
127
|
-
{
|
|
128
|
-
color: theme.colors.textSecondary,
|
|
129
|
-
fontSize: theme.fontScale.sm,
|
|
130
|
-
marginBottom: theme.spacing.xs,
|
|
131
|
-
},
|
|
132
|
-
]}
|
|
133
|
-
>
|
|
134
|
-
{label}
|
|
135
|
-
</RNText>
|
|
136
|
-
)}
|
|
137
|
-
|
|
138
|
-
{/* Progress Bar */}
|
|
139
|
-
<Svg width={barWidth} height={barHeight}>
|
|
140
|
-
{/* Background */}
|
|
141
|
-
<Rect
|
|
142
|
-
x={0}
|
|
143
|
-
y={0}
|
|
144
|
-
width={barWidth}
|
|
145
|
-
height={barHeight}
|
|
146
|
-
fill={theme.colors.borderLight}
|
|
147
|
-
rx={theme.radius.sm}
|
|
148
|
-
ry={theme.radius.sm}
|
|
149
|
-
/>
|
|
150
|
-
|
|
151
|
-
{/* Foreground */}
|
|
152
|
-
<Rect
|
|
153
|
-
x={0}
|
|
154
|
-
y={0}
|
|
155
|
-
width={currentBarWidth}
|
|
156
|
-
height={barHeight}
|
|
157
|
-
fill={theme.colors.chartPrimary}
|
|
158
|
-
rx={theme.radius.sm}
|
|
159
|
-
ry={theme.radius.sm}
|
|
160
|
-
/>
|
|
161
|
-
</Svg>
|
|
162
|
-
|
|
163
|
-
{/* Value Display */}
|
|
164
|
-
{displayValue && (
|
|
165
|
-
<RNText
|
|
166
|
-
style={[
|
|
167
|
-
styles.value,
|
|
168
|
-
{
|
|
169
|
-
color: theme.colors.text,
|
|
170
|
-
fontSize: theme.fontScale.md,
|
|
171
|
-
fontWeight: '600',
|
|
172
|
-
marginTop: theme.spacing.xs,
|
|
173
|
-
},
|
|
174
|
-
]}
|
|
175
|
-
>
|
|
176
|
-
{displayValue}
|
|
177
|
-
</RNText>
|
|
178
|
-
)}
|
|
179
|
-
</View>
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
Progress.displayName = 'Progress';
|
|
184
|
-
|
|
185
|
-
const styles = StyleSheet.create({
|
|
186
|
-
container: {
|
|
187
|
-
justifyContent: 'center',
|
|
188
|
-
alignItems: 'flex-start',
|
|
189
|
-
},
|
|
190
|
-
loadingText: {
|
|
191
|
-
fontSize: 16,
|
|
192
|
-
},
|
|
193
|
-
emptyText: {
|
|
194
|
-
fontSize: 16,
|
|
195
|
-
},
|
|
196
|
-
label: {
|
|
197
|
-
textTransform: 'uppercase',
|
|
198
|
-
letterSpacing: 0.5,
|
|
199
|
-
},
|
|
200
|
-
value: {},
|
|
201
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Progress Widget types
|
|
3
|
-
*/
|
|
4
|
-
import { BaseWidgetProps } from '../../core/types';
|
|
5
|
-
|
|
6
|
-
export interface ProgressData {
|
|
7
|
-
value: number;
|
|
8
|
-
max: number;
|
|
9
|
-
label?: string;
|
|
10
|
-
showPercentage?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type ProgressVariant = 'bar' | 'circle';
|
|
14
|
-
|
|
15
|
-
export interface ProgressWidgetProps extends BaseWidgetProps<ProgressData> {
|
|
16
|
-
variant?: ProgressVariant;
|
|
17
|
-
barHeight?: number;
|
|
18
|
-
showValue?: boolean;
|
|
19
|
-
}
|