@dhiraj0720/report1chart 2.2.2 → 2.2.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.
@@ -1,222 +0,0 @@
1
- import React, { useState } from 'react';
2
- import {
3
- View,
4
- Text,
5
- StyleSheet,
6
- TouchableOpacity,
7
- ScrollView,
8
- } from 'react-native';
9
- import DefaultTable from '../components/tables/DefaultTable';
10
- import CompactTable from '../components/tables/CompactTable';
11
- import FreezeTable from '../components/tables/FreezeTable';
12
- import BarChart from '../components/charts/BarChart';
13
- import PieChart from '../components/charts/PieChart';
14
- import LineChart from '../components/charts/LineChart';
15
- import LoadingSpinner from '../components/common/LoadingSpinner';
16
- import ErrorDisplay from '../components/common/ErrorDisplay';
17
-
18
- const ReportDetail = ({ report, loading, error, onBack, onClose }) => {
19
- const [viewType, setViewType] = useState(report.subType || 'default');
20
-
21
- const renderContent = () => {
22
- if (loading) {
23
- return <LoadingSpinner message="Loading report data..." />;
24
- }
25
-
26
- if (error) {
27
- return <ErrorDisplay error={error} onRetry={() => onBack()} />;
28
- }
29
-
30
- if (!report.data || (Array.isArray(report.data) && report.data.length === 0)) {
31
- return (
32
- <View style={styles.noDataContainer}>
33
- <Text style={styles.noDataText}>No data available</Text>
34
- </View>
35
- );
36
- }
37
-
38
- switch (report.type) {
39
- case 'table':
40
- return renderTable();
41
- case 'bar':
42
- return <BarChart data={report.data} title={report.title} />;
43
- case 'pie':
44
- return <PieChart data={report.data} title={report.title} />;
45
- case 'line':
46
- return <LineChart data={report.data} title={report.title} />;
47
- default:
48
- return <BarChart data={report.data} title={report.title} />;
49
- }
50
- };
51
-
52
- const renderTable = () => {
53
- switch (viewType) {
54
- case 'compact':
55
- return <CompactTable data={report.data} />;
56
- case 'freeze':
57
- return <FreezeTable data={report.data} />;
58
- default:
59
- return <DefaultTable data={report.data} />;
60
- }
61
- };
62
-
63
- return (
64
- <View style={styles.container}>
65
- <View style={styles.header}>
66
- <TouchableOpacity
67
- style={styles.backButton}
68
- onPress={onBack}
69
- >
70
- <Text style={styles.backText}>‹</Text>
71
- <Text style={styles.backButtonText}>Back</Text>
72
- </TouchableOpacity>
73
- <Text style={styles.headerTitle} numberOfLines={1}>
74
- {report.title || report.name}
75
- </Text>
76
- <TouchableOpacity onPress={onClose} style={styles.closeButton}>
77
- <Text style={styles.closeText}>×</Text>
78
- </TouchableOpacity>
79
- </View>
80
-
81
- {report.type === 'table' && (
82
- <View style={styles.viewTypeSelector}>
83
- <TouchableOpacity
84
- style={[
85
- styles.viewTypeButton,
86
- viewType === 'default' && styles.activeViewType
87
- ]}
88
- onPress={() => setViewType('default')}
89
- >
90
- <Text style={[
91
- styles.viewTypeText,
92
- viewType === 'default' && styles.activeViewTypeText
93
- ]}>Default</Text>
94
- </TouchableOpacity>
95
-
96
- <TouchableOpacity
97
- style={[
98
- styles.viewTypeButton,
99
- viewType === 'compact' && styles.activeViewType
100
- ]}
101
- onPress={() => setViewType('compact')}
102
- >
103
- <Text style={[
104
- styles.viewTypeText,
105
- viewType === 'compact' && styles.activeViewTypeText
106
- ]}>Compact</Text>
107
- </TouchableOpacity>
108
-
109
- <TouchableOpacity
110
- style={[
111
- styles.viewTypeButton,
112
- viewType === 'freeze' && styles.activeViewType
113
- ]}
114
- onPress={() => setViewType('freeze')}
115
- >
116
- <Text style={[
117
- styles.viewTypeText,
118
- viewType === 'freeze' && styles.activeViewTypeText
119
- ]}>Freeze</Text>
120
- </TouchableOpacity>
121
- </View>
122
- )}
123
-
124
- <ScrollView style={styles.content}>
125
- {renderContent()}
126
- </ScrollView>
127
- </View>
128
- );
129
- };
130
-
131
- const styles = StyleSheet.create({
132
- container: {
133
- flex: 1,
134
- backgroundColor: '#f8f9fa',
135
- },
136
- header: {
137
- flexDirection: 'row',
138
- alignItems: 'center',
139
- justifyContent: 'space-between',
140
- backgroundColor: '#fff',
141
- paddingHorizontal: 16,
142
- paddingVertical: 12,
143
- borderBottomWidth: 1,
144
- borderBottomColor: '#e0e0e0',
145
- },
146
- headerTitle: {
147
- fontSize: 18,
148
- fontWeight: '700',
149
- color: '#000',
150
- flex: 1,
151
- textAlign: 'center',
152
- },
153
- backButton: {
154
- flexDirection: 'row',
155
- alignItems: 'center',
156
- padding: 8,
157
- },
158
- backText: {
159
- fontSize: 24,
160
- color: '#4CAF50',
161
- marginRight: 4,
162
- },
163
- backButtonText: {
164
- fontSize: 16,
165
- color: '#4CAF50',
166
- fontWeight: '600',
167
- },
168
- closeButton: {
169
- width: 32,
170
- height: 32,
171
- borderRadius: 16,
172
- backgroundColor: '#f0f0f0',
173
- justifyContent: 'center',
174
- alignItems: 'center',
175
- },
176
- closeText: {
177
- fontSize: 20,
178
- color: '#666',
179
- fontWeight: '300',
180
- },
181
- content: {
182
- flex: 1,
183
- padding: 16,
184
- },
185
- viewTypeSelector: {
186
- flexDirection: 'row',
187
- backgroundColor: '#f0f0f0',
188
- borderRadius: 8,
189
- padding: 4,
190
- margin: 16,
191
- alignSelf: 'center',
192
- },
193
- viewTypeButton: {
194
- paddingHorizontal: 16,
195
- paddingVertical: 8,
196
- borderRadius: 6,
197
- marginHorizontal: 2,
198
- },
199
- activeViewType: {
200
- backgroundColor: '#fff',
201
- },
202
- viewTypeText: {
203
- fontSize: 13,
204
- fontWeight: '500',
205
- color: '#666',
206
- },
207
- activeViewTypeText: {
208
- color: '#4CAF50',
209
- fontWeight: '600',
210
- },
211
- noDataContainer: {
212
- padding: 40,
213
- alignItems: 'center',
214
- },
215
- noDataText: {
216
- fontSize: 16,
217
- color: '#999',
218
- textAlign: 'center',
219
- },
220
- });
221
-
222
- export default ReportDetail;