forked from osdio/noder-react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.js
More file actions
92 lines (73 loc) · 2.45 KB
/
Message.js
File metadata and controls
92 lines (73 loc) · 2.45 KB
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
// Require module
var React = require('react-native')
var ScrollableTabView = require('react-native-scrollable-tab-view')
var MessagePage = require('../components/MessagePage')
var TabBar = require('../components/TabBar')
var Return = require('../components/overlay/Return')
var MarkAsReadOverlay = require('../components/overlay/MarkAsReadOverlay')
var window = require('../util/window')
var { width, height } = window.get()
var {
View,
Text,
Component,
StyleSheet
} = React
class Message extends Component {
constructor(props) {
super(props)
this.state = {
didFocus: false
}
}
componentDidMount() {
this.props.actions.getMessages(this.props.state.user.token)
}
componentDidFocus() {
this.setState({
didFocus: true
})
}
render() {
let message = this.props.state.message
let didFocus = this.state.didFocus
let hasNotReadCount = message.hasNotRead.length
let hasReadCount = message.hasRead.length
return (
<View style={styles.container}>
<ScrollableTabView
edgeHitWidth={(width/3)*2}
renderTabBar={()=>TabBar}>
<MessagePage
router={this.props.router}
didFocus={didFocus}
isLoading={message.isLoading}
data={message.hasNotRead}
style={styles.userTopicPage}
tabLabel={"未读消息 " + hasNotReadCount}/>
<MessagePage
router={this.props.router}
didFocus={didFocus}
isLoading={message.isLoading}
data={message.hasRead}
style={styles.userTopicPage}
tabLabel={"已读消息 " + hasReadCount}/>
</ScrollableTabView>
<Return router={this.props.router}/>
<MarkAsReadOverlay
isLoading={message.isMarkAsReadLoading}
markAsRead={this.props.actions.markAsRead}
message={message}
token={this.props.state.user.token}
/>
</View>
)
}
}
var styles = StyleSheet.create({
container: {
backgroundColor: 'white',
height: height
}
})
module.exports = Message