-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTableViewTest03Screen.tsx
87 lines (76 loc) · 2.34 KB
/
TableViewTest03Screen.tsx
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
import * as React from 'react';
import { StyleSheet, View } from 'react-native';
import { TableView } from 'react-native-ios-list-view';
import { CELL_HEIGHT, DUMMY_LIST_DATA, ListDataItem, ListReorderPresets } from './Constants';
import { CellContent } from './CellContent';
import { ListHeader } from './ListHeader';
export function TableViewTest03Screen() {
const [listData, setListData] = React.useState(DUMMY_LIST_DATA);
const tableViewRef = React.useRef<TableView>(null);
const [
reorderPresetCounter,
setReorderPresetCounter
] = React.useState(0);
const reorderPresetIndex =
reorderPresetCounter % ListReorderPresets.length;
const reorderPresetItem =
ListReorderPresets[reorderPresetIndex];
return (
<View style={styles.rootContainer}>
<TableView
{...reorderPresetItem.props}
ref={tableViewRef}
style={styles.tableView}
listData={listData}
minimumListCellHeight={CELL_HEIGHT}
listDataKeyExtractor={(
item: Record<string, ListDataItem>,
index: number
) => {
return `${item.indexID}`;
}}
renderListHeader={() => {
return (
<ListHeader
listDataCount={listData.length}
reorderPresetItem={reorderPresetItem}
reorderPresetIndex={reorderPresetIndex}
onPressNextReorderPresetButton={() => {
setReorderPresetCounter(prevValue => prevValue + 1);
}}
/>
);
}}
renderCellContent={(
listDataItem,
renderRequestData,
orderedListItemIndex,
reactListItemIndex,
nativeListItem,
) => {
return (
<CellContent
tableViewRef={tableViewRef}
listDataCount={DUMMY_LIST_DATA.length}
reuseIdentifier={renderRequestData.renderRequestKey}
listDataItem={listDataItem}
orderedListItemIndex={orderedListItemIndex}
reactListItemIndex={reactListItemIndex}
nativeListItem={nativeListItem}
reorderPresetItem={reorderPresetItem}
/>
);
}}
/>
</View>
);
};
const styles = StyleSheet.create({
rootContainer: {
flex: 1,
backgroundColor: '#fff',
},
tableView: {
flex: 1,
},
});