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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
import React, { Component } from 'react';
import {
FlatList,
StyleSheet,
Text,
TouchableOpacity,
View,
ScrollView,
} from 'react-native';
import ScrollableContainer from '../components/scrollableContainer'
import Modal from '../components/modal'
import Container from '../components/container'
import ClearText from '../components/text'
import TimelineEvent from './timelineEvent'
import TimelineFull from './timelineFull'
import TimelineHeader from './timelineHeader'
import TimelineFilter from './timelineFilter'
import TickMarks from './tickMarks'
export default class Timeline extends Component {
constructor(props) {
super()
this.state = {
events: props.events,
tag: props.tag,
introVisible: props.firstTime,
modalVisible: false,
filterVisible: false,
item: null,
introVisible: false,
// modalVisible: true,
// item: props.events[2],
}
this.onPress = this.onPress.bind(this)
this.onFilter = this.onFilter.bind(this)
this.scrollToIndex = this.scrollToIndex.bind(this)
this.items = []
}
onPress(item) {
this.setState({
modalVisible: true,
item: item,
})
}
onFilter(tag) {
let events;
if (!! tag && tag !== this.state.tag) {
events = this.props.events.filter((e) => e && e.keywords.includes(tag))
}
else {
events = this.props.events
}
this.setState({ events, tag, modalVisible: false, filterVisible: false })
}
scrollToIndex(index) {
// this.flatList._listRef.scrollToIndex(index)
// this.scrollable.scrollToIndex({index: index})
const offset = this.items[index].ref.parentNode.offsetTop
this.scrollable.scrollView.scrollTo({
y: offset,
x: 0,
animated: true,
})
}
render() {
const heading = this.state.tag || 'History of Surveillance'
const items = this.state.events.map((item, i) => (
<TimelineEvent ref={(ref) => this.items[i] = ref} key={item.id} onPress={this.onPress} item={item} />
))
return (
<View>
<ScrollableContainer ref={(ref) => this.scrollable = ref} heading={heading} headingOnPress={() => this.onFilter("")}>
{items}
</ScrollableContainer>
<TickMarks events={this.state.events} scrollToIndex={this.scrollToIndex} />
<Modal isVisible={this.state.introVisible} style={[styles.modal, styles.headerModal]}>
<TimelineHeader
content={this.props.content}
onLinkPress={this.props.onLinkPress}
onClose={() => this.setState({ introVisible: false })}
/>
</Modal>
<Modal isVisible={this.state.modalVisible} style={styles.modal}>
<TimelineFull
item={this.state.item}
onLinkPress={this.props.onLinkPress}
onFilter={this.onFilter}
onClose={() => this.setState({ modalVisible: false })}
/>
</Modal>
</View>
)
}
}
// <View style={styles.body}>
// <View style={styles.sidebar}>
// <TouchableOpacity onPress={() => this.setState({ filterVisible: true })}>
// <ClearText style={[styles.filterText, !! this.state.tag ? styles.filterActive : styles.filterInactive ]}>
// { !! this.state.tag ? 'FILTER' : '' }
// </ClearText>
// </TouchableOpacity>
// </View>
// </View>
// <Modal isVisible={this.state.filterVisible} style={styles.modal}>
// <TimelineFilter
// events={this.props.events}
// tag={this.state.tag}
// onFilter={this.onFilter}
// onClose={() => this.setState({ filterVisible: false })}
// />
// </Modal>
const styles = StyleSheet.create({
wrapper: {
},
modal: {
margin: 0,
padding: 0,
},
headerModal: {
justifyContent: 'flex-start',
alignItems: 'center',
backgroundColor: 'rgb(0,0,0)',
margin: 0,
padding: 0,
},
body: {
flexDirection: 'row',
height: 840,
},
flatList: {
},
container: {
flex: 1,
justifyContent: 'flex-start',
alignItems: 'center',
},
sidebar: {
flex: 0,
},
filterText: {
color: '#bbb',
textAlign: 'left',
fontSize: 12,
marginLeft: 4,
},
filterActive: {
color: '#fff',
textDecorationLine: 'underline',
},
filterInactive: {
color: '#bbb',
},
tickMarks: {
flex: 0,
},
})
|