|
@@ -2,9 +2,9 @@
|
2
|
2
|
|
3
|
3
|
import * as React from 'react';
|
4
|
4
|
import WebDataManager from "../utils/WebDataManager";
|
5
|
|
-import {Container, Content, H2} from "native-base";
|
|
5
|
+import {Container, Content, Tab, TabHeading, Tabs, Text} from "native-base";
|
6
|
6
|
import CustomHeader from "./CustomHeader";
|
7
|
|
-import {SectionList, RefreshControl, View} from "react-native";
|
|
7
|
+import {RefreshControl, SectionList, View} from "react-native";
|
8
|
8
|
|
9
|
9
|
type Props = {
|
10
|
10
|
navigation: Object,
|
|
@@ -14,12 +14,12 @@ type State = {
|
14
|
14
|
refreshing: boolean,
|
15
|
15
|
firstLoading: boolean,
|
16
|
16
|
fetchedData: Object,
|
17
|
|
- machinesWatched : Array<Object>
|
|
17
|
+ machinesWatched: Array<Object>
|
18
|
18
|
};
|
19
|
19
|
|
20
|
20
|
export default class FetchedDataSectionList extends React.Component<Props, State> {
|
21
|
21
|
|
22
|
|
- webDataManager : WebDataManager;
|
|
22
|
+ webDataManager: WebDataManager;
|
23
|
23
|
|
24
|
24
|
constructor() {
|
25
|
25
|
super();
|
|
@@ -30,7 +30,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
30
|
30
|
refreshing: false,
|
31
|
31
|
firstLoading: true,
|
32
|
32
|
fetchedData: {},
|
33
|
|
- machinesWatched : [],
|
|
33
|
+ machinesWatched: [],
|
34
|
34
|
};
|
35
|
35
|
|
36
|
36
|
getFetchUrl() {
|
|
@@ -41,7 +41,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
41
|
41
|
return "Header";
|
42
|
42
|
}
|
43
|
43
|
|
44
|
|
- getUpdateToastTranslations () {
|
|
44
|
+ getUpdateToastTranslations() {
|
45
|
45
|
return ["whoa", "nah"];
|
46
|
46
|
}
|
47
|
47
|
|
|
@@ -64,12 +64,12 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
64
|
64
|
});
|
65
|
65
|
};
|
66
|
66
|
|
67
|
|
- getRenderItem(item: Object, section : Object, data : Object) {
|
68
|
|
- return <View />;
|
|
67
|
+ getRenderItem(item: Object, section: Object, data: Object) {
|
|
68
|
+ return <View/>;
|
69
|
69
|
}
|
70
|
70
|
|
71
|
71
|
getRenderSectionHeader(title: String) {
|
72
|
|
- return <View />;
|
|
72
|
+ return <View/>;
|
73
|
73
|
}
|
74
|
74
|
|
75
|
75
|
/**
|
|
@@ -77,7 +77,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
77
|
77
|
* @param fetchedData {Object}
|
78
|
78
|
* @return {Array}
|
79
|
79
|
*/
|
80
|
|
- createDataset(fetchedData : Object) : Array<Object> {
|
|
80
|
+ createDataset(fetchedData: Object): Array<Object> {
|
81
|
81
|
return [];
|
82
|
82
|
}
|
83
|
83
|
|
|
@@ -86,35 +86,72 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
86
|
86
|
* @param item {Object}
|
87
|
87
|
* @return {*}
|
88
|
88
|
*/
|
89
|
|
- getKeyExtractor(item : Object) {
|
|
89
|
+ getKeyExtractor(item: Object) {
|
90
|
90
|
return item.id;
|
91
|
91
|
}
|
92
|
92
|
|
|
93
|
+ hasTabs() {
|
|
94
|
+ return false;
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ getSectionList(dataset: Array<Object>) {
|
|
98
|
+ return (
|
|
99
|
+ <SectionList
|
|
100
|
+ sections={dataset}
|
|
101
|
+ keyExtractor={(item) => this.getKeyExtractor(item)}
|
|
102
|
+ refreshControl={
|
|
103
|
+ <RefreshControl
|
|
104
|
+ refreshing={this.state.refreshing}
|
|
105
|
+ onRefresh={this._onRefresh}
|
|
106
|
+ />
|
|
107
|
+ }
|
|
108
|
+ renderSectionHeader={({section: {title}}) =>
|
|
109
|
+ this.getRenderSectionHeader(title)
|
|
110
|
+ }
|
|
111
|
+ renderItem={({item, section}) =>
|
|
112
|
+ this.getRenderItem(item, section, dataset)
|
|
113
|
+ }
|
|
114
|
+ style={{minHeight: 300, width: '100%'}}
|
|
115
|
+ />
|
|
116
|
+ );
|
|
117
|
+ }
|
|
118
|
+
|
|
119
|
+ getTabbedView(dataset: Array<Object>) {
|
|
120
|
+ let tabbedView = [];
|
|
121
|
+ for (let i = 0; i < dataset.length; i++) {
|
|
122
|
+ tabbedView.push(
|
|
123
|
+ <Tab heading={<TabHeading><Text>{dataset[i].title}</Text></TabHeading>}>
|
|
124
|
+ <Content padder>
|
|
125
|
+ {this.getSectionList(
|
|
126
|
+ [
|
|
127
|
+ {
|
|
128
|
+ title: dataset[i].title,
|
|
129
|
+ data: dataset[i].data,
|
|
130
|
+ extraData: dataset[i].extraData,
|
|
131
|
+ }
|
|
132
|
+ ]
|
|
133
|
+ )}
|
|
134
|
+ </Content>
|
|
135
|
+ </Tab>);
|
|
136
|
+ }
|
|
137
|
+ return tabbedView;
|
|
138
|
+ }
|
|
139
|
+
|
93
|
140
|
render() {
|
94
|
141
|
const nav = this.props.navigation;
|
95
|
142
|
const dataset = this.createDataset(this.state.fetchedData);
|
96
|
143
|
return (
|
97
|
144
|
<Container>
|
98
|
145
|
<CustomHeader navigation={nav} title={this.getHeaderTranslation()}/>
|
99
|
|
- <Content padder>
|
100
|
|
- <SectionList
|
101
|
|
- sections={dataset}
|
102
|
|
- keyExtractor={(item) => this.getKeyExtractor(item)}
|
103
|
|
- refreshControl={
|
104
|
|
- <RefreshControl
|
105
|
|
- refreshing={this.state.refreshing}
|
106
|
|
- onRefresh={this._onRefresh}
|
107
|
|
- />
|
108
|
|
- }
|
109
|
|
- renderSectionHeader={({section: {title}}) =>
|
110
|
|
- this.getRenderSectionHeader(title)
|
111
|
|
- }
|
112
|
|
- renderItem={({item, section}) =>
|
113
|
|
- this.getRenderItem(item, section, dataset)
|
114
|
|
- }
|
115
|
|
- style={{minHeight: 300, width: '100%'}}
|
116
|
|
- />
|
117
|
|
- </Content>
|
|
146
|
+ {this.hasTabs() ?
|
|
147
|
+ <Tabs>
|
|
148
|
+ {this.getTabbedView(dataset)}
|
|
149
|
+ </Tabs>
|
|
150
|
+ :
|
|
151
|
+ <Content padder>
|
|
152
|
+ {this.getSectionList(dataset)}
|
|
153
|
+ </Content>
|
|
154
|
+ }
|
118
|
155
|
</Container>
|
119
|
156
|
);
|
120
|
157
|
}
|