@dhiraj0720/report1chart 3.0.0 → 3.0.1
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ScrollView, StyleSheet, Text, View } from 'react-native';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { ScrollView, StyleSheet, Text, View, useWindowDimensions } from 'react-native';
|
|
3
3
|
import { formatNumber } from '../utils/formatNumber';
|
|
4
4
|
|
|
5
5
|
const TAB_TABLE_CONFIG = {
|
|
@@ -123,8 +123,8 @@ const formatRatio = (value) => {
|
|
|
123
123
|
return `%${value}`;
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
-
const DataCell = ({ children,
|
|
127
|
-
<View style={[styles.dataCell,
|
|
126
|
+
const DataCell = ({ children, rowStyle, cellStyle }) => (
|
|
127
|
+
<View style={[styles.dataCell, rowStyle, cellStyle]}>
|
|
128
128
|
{children}
|
|
129
129
|
</View>
|
|
130
130
|
);
|
|
@@ -178,32 +178,68 @@ const rowTypeStyle = (row, index) => {
|
|
|
178
178
|
return index % 2 === 0 ? styles.evenRow : styles.oddRow;
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
const FrozenTableReport4A = ({ rows = [], tabKey = 'kumule' }) => {
|
|
181
|
+
const FrozenTableReport4A = ({ rows = [], tabKey = 'kumule', isFullscreen = false }) => {
|
|
182
|
+
const { width: screenWidth } = useWindowDimensions();
|
|
182
183
|
const config = TAB_TABLE_CONFIG[tabKey] || TAB_TABLE_CONFIG.kumule;
|
|
183
184
|
|
|
185
|
+
const layout = useMemo(() => {
|
|
186
|
+
const safeWidth = Math.max(280, screenWidth - (isFullscreen ? 32 : 24));
|
|
187
|
+
|
|
188
|
+
const frozenColumnWidth = isFullscreen
|
|
189
|
+
? Math.max(160, Math.min(220, safeWidth * 0.3))
|
|
190
|
+
: Math.max(128, Math.min(156, safeWidth * 0.38));
|
|
191
|
+
|
|
192
|
+
const dataColumnWidth = isFullscreen
|
|
193
|
+
? Math.max(96, Math.min(142, safeWidth * 0.18))
|
|
194
|
+
: Math.max(92, Math.min(116, (safeWidth - frozenColumnWidth) / 2));
|
|
195
|
+
|
|
196
|
+
return {
|
|
197
|
+
frozenColumnWidth,
|
|
198
|
+
dataColumnWidth,
|
|
199
|
+
rowHeight: isFullscreen ? 42 : 38,
|
|
200
|
+
headerHeight: isFullscreen ? 54 : 46,
|
|
201
|
+
};
|
|
202
|
+
}, [isFullscreen, screenWidth]);
|
|
203
|
+
|
|
184
204
|
if (!rows.length) {
|
|
185
205
|
return <Text style={styles.noData}>No data available</Text>;
|
|
186
206
|
}
|
|
187
207
|
|
|
188
208
|
return (
|
|
189
|
-
<View style={styles.wrapper}>
|
|
209
|
+
<View style={[styles.wrapper, isFullscreen && styles.wrapperFullscreen]}>
|
|
190
210
|
<Text style={styles.tableTitle}>{config.title}</Text>
|
|
191
211
|
|
|
192
212
|
<View style={styles.tableContainer}>
|
|
193
|
-
<View style={styles.frozenColumn}>
|
|
194
|
-
<View
|
|
213
|
+
<View style={[styles.frozenColumn, { width: layout.frozenColumnWidth }]}>
|
|
214
|
+
<View
|
|
215
|
+
style={[
|
|
216
|
+
styles.nameCell,
|
|
217
|
+
styles.headerCell,
|
|
218
|
+
{ height: layout.headerHeight },
|
|
219
|
+
]}
|
|
220
|
+
>
|
|
195
221
|
<Text style={styles.headerText}>ŞİRKET / İŞTİPİ</Text>
|
|
196
222
|
</View>
|
|
223
|
+
|
|
197
224
|
{rows.map((row, index) => {
|
|
198
225
|
const isTotal = row.rowType === 1 || row.rowType === 3;
|
|
199
226
|
return (
|
|
200
227
|
<View
|
|
201
228
|
key={`name-${row.sortOrder || index}`}
|
|
202
|
-
style={[
|
|
229
|
+
style={[
|
|
230
|
+
styles.nameCell,
|
|
231
|
+
rowTypeStyle(row, index),
|
|
232
|
+
{ height: layout.rowHeight },
|
|
233
|
+
]}
|
|
203
234
|
>
|
|
204
235
|
<View style={styles.nameCellContent}>
|
|
205
|
-
<Text style={styles.star}>{isTotal ? '★' : '
|
|
206
|
-
<Text
|
|
236
|
+
<Text style={styles.star}>{isTotal ? '★' : ''}</Text>
|
|
237
|
+
<Text
|
|
238
|
+
numberOfLines={1}
|
|
239
|
+
adjustsFontSizeToFit
|
|
240
|
+
minimumFontScale={0.78}
|
|
241
|
+
style={styles.nameText}
|
|
242
|
+
>
|
|
207
243
|
{row.name}
|
|
208
244
|
</Text>
|
|
209
245
|
</View>
|
|
@@ -216,7 +252,17 @@ const FrozenTableReport4A = ({ rows = [], tabKey = 'kumule' }) => {
|
|
|
216
252
|
<View>
|
|
217
253
|
<View style={styles.row}>
|
|
218
254
|
{config.columns.map((column) => (
|
|
219
|
-
<View
|
|
255
|
+
<View
|
|
256
|
+
key={column.key}
|
|
257
|
+
style={[
|
|
258
|
+
styles.dataCell,
|
|
259
|
+
styles.headerCell,
|
|
260
|
+
{
|
|
261
|
+
width: layout.dataColumnWidth,
|
|
262
|
+
height: layout.headerHeight,
|
|
263
|
+
},
|
|
264
|
+
]}
|
|
265
|
+
>
|
|
220
266
|
<Text numberOfLines={2} style={styles.headerText}>
|
|
221
267
|
{column.label}
|
|
222
268
|
</Text>
|
|
@@ -224,18 +270,26 @@ const FrozenTableReport4A = ({ rows = [], tabKey = 'kumule' }) => {
|
|
|
224
270
|
))}
|
|
225
271
|
</View>
|
|
226
272
|
|
|
227
|
-
{rows.map((row, index) =>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
273
|
+
{rows.map((row, index) => {
|
|
274
|
+
const rowStyle = rowTypeStyle(row, index);
|
|
275
|
+
|
|
276
|
+
return (
|
|
277
|
+
<View key={`row-${row.sortOrder || index}`} style={styles.row}>
|
|
278
|
+
{config.columns.map((column) => (
|
|
279
|
+
<DataCell
|
|
280
|
+
key={`${row.sortOrder || index}-${column.key}`}
|
|
281
|
+
rowStyle={rowStyle}
|
|
282
|
+
cellStyle={{
|
|
283
|
+
width: layout.dataColumnWidth,
|
|
284
|
+
height: layout.rowHeight,
|
|
285
|
+
}}
|
|
286
|
+
>
|
|
287
|
+
{renderCellValue(row, column)}
|
|
288
|
+
</DataCell>
|
|
289
|
+
))}
|
|
290
|
+
</View>
|
|
291
|
+
);
|
|
292
|
+
})}
|
|
239
293
|
</View>
|
|
240
294
|
</ScrollView>
|
|
241
295
|
</View>
|
|
@@ -247,39 +301,42 @@ export default FrozenTableReport4A;
|
|
|
247
301
|
|
|
248
302
|
const styles = StyleSheet.create({
|
|
249
303
|
wrapper: {
|
|
250
|
-
backgroundColor: '#
|
|
251
|
-
borderRadius:
|
|
304
|
+
backgroundColor: '#f4f7fb',
|
|
305
|
+
borderRadius: 10,
|
|
252
306
|
borderWidth: 1,
|
|
253
|
-
borderColor: '#
|
|
307
|
+
borderColor: '#ccd8e4',
|
|
308
|
+
padding: 6,
|
|
309
|
+
},
|
|
310
|
+
wrapperFullscreen: {
|
|
254
311
|
padding: 8,
|
|
255
312
|
},
|
|
256
313
|
tableTitle: {
|
|
257
314
|
textAlign: 'center',
|
|
258
|
-
fontSize:
|
|
315
|
+
fontSize: 14,
|
|
259
316
|
fontWeight: '700',
|
|
260
|
-
color: '#
|
|
261
|
-
marginBottom:
|
|
317
|
+
color: '#223648',
|
|
318
|
+
marginBottom: 6,
|
|
262
319
|
},
|
|
263
320
|
tableContainer: {
|
|
264
321
|
flexDirection: 'row',
|
|
265
322
|
borderWidth: 1,
|
|
266
|
-
borderColor: '#
|
|
267
|
-
|
|
323
|
+
borderColor: '#b8c6d4',
|
|
324
|
+
borderRadius: 8,
|
|
325
|
+
overflow: 'hidden',
|
|
326
|
+
backgroundColor: '#e7edf3',
|
|
268
327
|
},
|
|
269
328
|
frozenColumn: {
|
|
270
|
-
width: 290,
|
|
271
329
|
borderRightWidth: 1,
|
|
272
|
-
borderRightColor: '#
|
|
330
|
+
borderRightColor: '#ecf1f6',
|
|
273
331
|
},
|
|
274
332
|
row: {
|
|
275
333
|
flexDirection: 'row',
|
|
276
334
|
},
|
|
277
335
|
nameCell: {
|
|
278
|
-
height: 46,
|
|
279
336
|
justifyContent: 'center',
|
|
280
337
|
borderBottomWidth: 1,
|
|
281
|
-
borderBottomColor: '#
|
|
282
|
-
paddingHorizontal:
|
|
338
|
+
borderBottomColor: '#edf2f7',
|
|
339
|
+
paddingHorizontal: 6,
|
|
283
340
|
},
|
|
284
341
|
nameCellContent: {
|
|
285
342
|
flexDirection: 'row',
|
|
@@ -287,48 +344,45 @@ const styles = StyleSheet.create({
|
|
|
287
344
|
},
|
|
288
345
|
nameText: {
|
|
289
346
|
flex: 1,
|
|
290
|
-
fontSize:
|
|
291
|
-
color: '#
|
|
347
|
+
fontSize: 11.5,
|
|
348
|
+
color: '#203040',
|
|
292
349
|
},
|
|
293
350
|
star: {
|
|
294
|
-
width:
|
|
351
|
+
width: 14,
|
|
295
352
|
textAlign: 'center',
|
|
296
|
-
color: '#
|
|
297
|
-
fontSize:
|
|
298
|
-
marginRight:
|
|
353
|
+
color: '#b7791f',
|
|
354
|
+
fontSize: 13,
|
|
355
|
+
marginRight: 2,
|
|
299
356
|
},
|
|
300
357
|
dataCell: {
|
|
301
|
-
width: 120,
|
|
302
|
-
height: 46,
|
|
303
358
|
justifyContent: 'center',
|
|
304
359
|
alignItems: 'center',
|
|
305
|
-
paddingHorizontal:
|
|
360
|
+
paddingHorizontal: 4,
|
|
306
361
|
borderBottomWidth: 1,
|
|
307
|
-
borderBottomColor: '#
|
|
362
|
+
borderBottomColor: '#edf2f7',
|
|
308
363
|
},
|
|
309
364
|
dataCellText: {
|
|
310
|
-
fontSize:
|
|
311
|
-
color: '#
|
|
365
|
+
fontSize: 11.5,
|
|
366
|
+
color: '#2b3d4e',
|
|
312
367
|
textAlign: 'center',
|
|
313
368
|
},
|
|
314
369
|
headerCell: {
|
|
315
370
|
backgroundColor: '#5f7f9f',
|
|
316
|
-
height: 58,
|
|
317
371
|
},
|
|
318
372
|
headerText: {
|
|
319
373
|
color: '#ffffff',
|
|
320
374
|
fontWeight: '700',
|
|
321
375
|
textAlign: 'center',
|
|
322
|
-
fontSize:
|
|
376
|
+
fontSize: 11,
|
|
323
377
|
},
|
|
324
378
|
evenRow: {
|
|
325
|
-
backgroundColor: '#
|
|
379
|
+
backgroundColor: '#e6eaef',
|
|
326
380
|
},
|
|
327
381
|
oddRow: {
|
|
328
|
-
backgroundColor: '#
|
|
382
|
+
backgroundColor: '#dde3e9',
|
|
329
383
|
},
|
|
330
384
|
totalRow: {
|
|
331
|
-
backgroundColor: '#
|
|
385
|
+
backgroundColor: '#a7bdd2',
|
|
332
386
|
},
|
|
333
387
|
trendWrapper: {
|
|
334
388
|
flexDirection: 'row',
|
|
@@ -336,9 +390,9 @@ const styles = StyleSheet.create({
|
|
|
336
390
|
justifyContent: 'center',
|
|
337
391
|
},
|
|
338
392
|
trendIcon: {
|
|
339
|
-
fontSize:
|
|
393
|
+
fontSize: 13,
|
|
340
394
|
fontWeight: '700',
|
|
341
|
-
marginRight:
|
|
395
|
+
marginRight: 3,
|
|
342
396
|
marginTop: -1,
|
|
343
397
|
},
|
|
344
398
|
noData: {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
ActivityIndicator,
|
|
4
|
+
Modal,
|
|
4
5
|
ScrollView,
|
|
5
6
|
StyleSheet,
|
|
6
7
|
Text,
|
|
7
8
|
TouchableOpacity,
|
|
8
9
|
View,
|
|
10
|
+
useWindowDimensions,
|
|
9
11
|
} from 'react-native';
|
|
10
12
|
import fetchReport4 from '../api/report4Fetcher';
|
|
11
13
|
import FrozenTableReport4A from '../components/FrozenTableReport4A';
|
|
@@ -17,11 +19,15 @@ const TABS = [
|
|
|
17
19
|
];
|
|
18
20
|
|
|
19
21
|
const Report4AScreen = ({ api, token, onBack }) => {
|
|
22
|
+
const { width, height } = useWindowDimensions();
|
|
20
23
|
const [activeTab, setActiveTab] = useState('kumule');
|
|
21
24
|
const [rowsByTab, setRowsByTab] = useState({});
|
|
22
25
|
const [loadedByTab, setLoadedByTab] = useState({});
|
|
23
26
|
const [errorByTab, setErrorByTab] = useState({});
|
|
24
27
|
const [loading, setLoading] = useState(false);
|
|
28
|
+
const [fullscreen, setFullscreen] = useState(false);
|
|
29
|
+
|
|
30
|
+
const isLandscape = width > height;
|
|
25
31
|
|
|
26
32
|
const endpointByTab = useMemo(() => ({
|
|
27
33
|
kumule: api?.kumule,
|
|
@@ -122,10 +128,55 @@ const Report4AScreen = ({ api, token, onBack }) => {
|
|
|
122
128
|
|
|
123
129
|
{activeRows.length ? (
|
|
124
130
|
<ScrollView style={styles.tableScroll} contentContainerStyle={styles.tableContent}>
|
|
131
|
+
<View style={styles.tableToolbar}>
|
|
132
|
+
<TouchableOpacity
|
|
133
|
+
onPress={() => setFullscreen(true)}
|
|
134
|
+
style={styles.fullViewButton}
|
|
135
|
+
>
|
|
136
|
+
<Text style={styles.fullViewButtonText}>⤢ Full View</Text>
|
|
137
|
+
</TouchableOpacity>
|
|
138
|
+
</View>
|
|
139
|
+
|
|
125
140
|
<FrozenTableReport4A rows={activeRows} tabKey={activeTab} />
|
|
126
141
|
</ScrollView>
|
|
127
142
|
) : null}
|
|
128
143
|
</View>
|
|
144
|
+
|
|
145
|
+
<Modal
|
|
146
|
+
visible={fullscreen}
|
|
147
|
+
animationType="fade"
|
|
148
|
+
onRequestClose={() => setFullscreen(false)}
|
|
149
|
+
supportedOrientations={['portrait', 'landscape-left', 'landscape-right']}
|
|
150
|
+
>
|
|
151
|
+
<View style={styles.fullModal}>
|
|
152
|
+
<View style={styles.fullHeader}>
|
|
153
|
+
<Text style={styles.fullHintText}>
|
|
154
|
+
Full View • Auto fit • Pinch to zoom
|
|
155
|
+
</Text>
|
|
156
|
+
<TouchableOpacity onPress={() => setFullscreen(false)}>
|
|
157
|
+
<Text style={styles.closeBtn}>✕</Text>
|
|
158
|
+
</TouchableOpacity>
|
|
159
|
+
</View>
|
|
160
|
+
|
|
161
|
+
<ScrollView
|
|
162
|
+
maximumZoomScale={3.5}
|
|
163
|
+
minimumZoomScale={0.45}
|
|
164
|
+
showsHorizontalScrollIndicator={false}
|
|
165
|
+
showsVerticalScrollIndicator={false}
|
|
166
|
+
contentContainerStyle={styles.zoomContent}
|
|
167
|
+
pinchGestureEnabled
|
|
168
|
+
bouncesZoom
|
|
169
|
+
>
|
|
170
|
+
<View style={[styles.tableWrapper, isLandscape && styles.tableWrapperLandscape]}>
|
|
171
|
+
<FrozenTableReport4A
|
|
172
|
+
rows={activeRows}
|
|
173
|
+
tabKey={activeTab}
|
|
174
|
+
isFullscreen
|
|
175
|
+
/>
|
|
176
|
+
</View>
|
|
177
|
+
</ScrollView>
|
|
178
|
+
</View>
|
|
179
|
+
</Modal>
|
|
129
180
|
</View>
|
|
130
181
|
);
|
|
131
182
|
};
|
|
@@ -220,7 +271,60 @@ const styles = StyleSheet.create({
|
|
|
220
271
|
flex: 1,
|
|
221
272
|
},
|
|
222
273
|
tableContent: {
|
|
223
|
-
|
|
274
|
+
paddingHorizontal: 10,
|
|
224
275
|
paddingBottom: 16,
|
|
225
276
|
},
|
|
277
|
+
tableToolbar: {
|
|
278
|
+
alignItems: 'flex-end',
|
|
279
|
+
marginTop: 8,
|
|
280
|
+
marginBottom: 6,
|
|
281
|
+
},
|
|
282
|
+
fullViewButton: {
|
|
283
|
+
backgroundColor: '#4E79A7',
|
|
284
|
+
borderRadius: 7,
|
|
285
|
+
paddingHorizontal: 12,
|
|
286
|
+
paddingVertical: 7,
|
|
287
|
+
},
|
|
288
|
+
fullViewButtonText: {
|
|
289
|
+
color: '#fff',
|
|
290
|
+
fontWeight: '700',
|
|
291
|
+
fontSize: 12,
|
|
292
|
+
},
|
|
293
|
+
fullModal: {
|
|
294
|
+
flex: 1,
|
|
295
|
+
backgroundColor: '#f3f6fa',
|
|
296
|
+
},
|
|
297
|
+
fullHeader: {
|
|
298
|
+
flexDirection: 'row',
|
|
299
|
+
alignItems: 'center',
|
|
300
|
+
paddingVertical: 14,
|
|
301
|
+
paddingHorizontal: 14,
|
|
302
|
+
borderBottomWidth: 1,
|
|
303
|
+
borderBottomColor: '#d3dde7',
|
|
304
|
+
backgroundColor: '#fff',
|
|
305
|
+
},
|
|
306
|
+
fullHintText: {
|
|
307
|
+
flex: 1,
|
|
308
|
+
fontSize: 14,
|
|
309
|
+
fontWeight: '600',
|
|
310
|
+
color: '#23384a',
|
|
311
|
+
textAlign: 'center',
|
|
312
|
+
},
|
|
313
|
+
closeBtn: {
|
|
314
|
+
fontSize: 24,
|
|
315
|
+
color: '#1f2d3a',
|
|
316
|
+
paddingHorizontal: 8,
|
|
317
|
+
},
|
|
318
|
+
zoomContent: {
|
|
319
|
+
flexGrow: 1,
|
|
320
|
+
justifyContent: 'center',
|
|
321
|
+
alignItems: 'center',
|
|
322
|
+
padding: 12,
|
|
323
|
+
},
|
|
324
|
+
tableWrapper: {
|
|
325
|
+
width: '100%',
|
|
326
|
+
},
|
|
327
|
+
tableWrapperLandscape: {
|
|
328
|
+
maxWidth: '96%',
|
|
329
|
+
},
|
|
226
330
|
});
|