-
Notifications
You must be signed in to change notification settings - Fork 427
/
Copy pathNotifyPage.js
130 lines (114 loc) · 4.18 KB
/
NotifyPage.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
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
/**
* Created by guoshuyu on 2017/11/10.
*/
import React, {Component, PureComponent} from 'react';
import {
View, InteractionManager, StatusBar, Dimensions, StyleSheet, DeviceEventEmitter,
} from 'react-native';
import {Actions, Tabs} from 'react-native-router-flux';
import styles from "../style"
import * as Constant from "../style/constant"
import I18n from '../style/i18n'
import userActions from '../store/actions/user'
import ListPage from "./ListPage";
import ScrollableTabView, {DefaultTabBar} from 'react-native-scrollable-tab-view-fix-guo';
import {launchUrl} from "../utils/htmlUtils";
/**
* 通知页面
*/
class NotifyPage extends Component {
constructor(props) {
super(props);
this.page = 2;
this._refresh = this._refresh.bind(this);
this._asRead = this._asRead.bind(this);
this.index = 0;
}
componentDidMount() {
this.subscription = DeviceEventEmitter.addListener(
`NotifyPage`,
(params) => {
if (params && params.type === "allRead") {
params.type = "";
this._refresh();
}
});
}
componentWillUnmount() {
this.subscription.remove();
this.props.backNotifyCall && this.props.backNotifyCall()
}
_refresh() {
if (this.unReadList)
this.unReadList._refresh();
if (this.partList)
this.partList._refresh();
if (this.allList)
this.allList._refresh();
}
_handleIndexChange = index => this.setState({index});
_asRead(id) {
userActions.setNotificationAsRead(id).then(() => {
this._refresh();
})
}
render() {
return (
<View style={styles.mainBox}>
<StatusBar hidden={false} backgroundColor={'transparent'} translucent barStyle={'light-content'}/>
<ScrollableTabView
onChangeTab={(params) => {
this.index = params.i;
}}
tabBarUnderlineStyle={{
backgroundColor: Constant.white,
height: 3
}}
renderTabBar={(props) => {
return <DefaultTabBar {...props} style={{paddingTop: 5}}/>;
}}
tabBarBackgroundColor={Constant.primaryColor}
tabBarActiveTextColor={Constant.white}
tabBarInactiveTextColor={Constant.subTextColor}
tabBarTextStyle={{fontSize: 16}}>
<ListPage
tabLabel={I18n('notifyUnread')}
ref={(ref) => {
this.unReadList = ref;
}}
dataType={'notify'}
showType={'notify'}
onItemClickEx={this._asRead}
currentUser={this.props.ownerName}
currentRepository={this.props.repositoryName}
/>
<ListPage
tabLabel={I18n('notifyParticipating')}
ref={(ref) => {
this.unReadList = ref;
}}
dataType={'notify'}
showType={'notify'}
onItemClickEx={this._asRead}
currentUser={this.props.ownerName}
currentRepository={this.props.repositoryName}
/>
<ListPage
tabLabel={I18n('notifyAll')}
ref={(ref) => {
this.allList = ref;
}}
dataType={'notify'}
showType={'notify'}
onItemClickEx={this._asRead}
all={true}
currentUser={this.props.ownerName}
currentRepository={this.props.repositoryName}
/>
</ScrollableTabView>
</View>
)
}
}
NotifyPage.defaultProps = {};
export default NotifyPage