-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSidebar.js
87 lines (76 loc) · 1.65 KB
/
Sidebar.js
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
'use strict';
const React = require('react-native');
const {
StyleSheet,
View,
Text,
TouchableOpacity,
TouchableHighlight,
TouchableNativeFeedback,
ListView,
Platform
} = React;
const content = require('./services/content');
const Sidebar = React.createClass({
getInitialState() {
return {
channels: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2
}),
loading: true
}
},
handlePressChannel(channel) {
this.props.onPressChannel && this.props.onPressChannel(channel);
},
componentDidMount() {
content.loadOnlyChannelsList().then(channels => {
this.setState({
channels: this.state.channels.cloneWithRows(channels),
loading: false
});
return channels[0].id
});
},
renderItem(channel) {
let { title, id } = channel;
return (
<TouchableOpacity
activeOpacity={0.5}
onPress={this.handlePressChannel.bind(this, channel)}
style={styles.channel}
>
<Text style={styles.title}>{title}</Text>
</TouchableOpacity>
);
},
render() {
return (
<ListView
style={styles.container}
dataSource={this.state.channels}
renderRow={this.renderItem}
/>
)
}
});
module.exports = Sidebar;
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: Platform.OS === 'ios' ? 64 : 0,
backgroundColor: '#fff'
},
channel: {
flex: 1,
flexDirection: 'row',
padding: 10,
borderBottomColor: 'lightgray',
borderBottomWidth: 1
},
title: {
fontSize: 16,
textAlign: 'left',
color: 'rgba(0,0,0,0.9)'
}
});