home.js
8.2 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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/**
* Created by Cassie on 2018/05/14
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
Image,
ScrollView,
Text,
TextInput,
TouchableOpacity,
InteractionManager
} from 'react-native';
import {StackNavigator} from 'react-navigation';
import {width,height,zoomW,zoomH} from '../utils/getSize';
import {xnToast} from '../utils/utils';
import AppService from '../service/AppService'
const back = require('../img/returnB.png');
const search = require('../img/search.png');
const allDel = require('../img/allDel.png');
const bread = require('../img/bread.png');
const avatar = require('../img/avatar.png');
const addTarget = require('../img/addTarget.png');
const withdraw = require('../img/withdraw.png');
export default class Home extends Component {
static navigationOptions = ({ navigation, screenProps }) => ({
title: "公告通知",
headerLeft:(<View style={{display:'flex',flexDirection:'row'}}>
<TouchableOpacity style={styles.topIcon} >
<Image source={back} style={{width:(16/zoomH),height:(16/zoomH)}} resizeMode="contain" />
</TouchableOpacity>
</View>),
headerRight:(
<View style={{display:'flex',flexDirection:'row',paddingRight:(5/zoomW)}}>
<TouchableOpacity style={styles.topIcon} onPress = {navigation.state.params?navigation.state.params.addNotice:null} >
<Image source={addTarget} style={{width:(26/zoomH),height:(26/zoomH)}} resizeMode="contain" />
</TouchableOpacity>
</View>)
});
constructor(props) {
super(props);
let that = this;
let param = {};
param.relatedUserId = global.userId;
this.state = {
sheetList:[]
};
AppService.findAnnouncement(param).then((data) => {
console.log(data);
this.setState({
loading:false
});
if(data.message){
xnToast(data.message);
return;
}
if(data.errors.length > 0){
xnToast(data.errors[0].message);
}else{
that.setState( {
sheetList: data.result
}
);
}
}).catch((error) => {
this.setState({
loading:false
});
xnToast(error)
})
}
componentDidMount(){
this.props.navigation.setParams({
addNotice:() => {
InteractionManager.runAfterInteractions(() => {this.props.navigation.navigate('AddNotice');})
}
});
};
_addNotice =()=>{
this.props.navigation.navigate('AddNotice');
};
/*我发布的通知*/
_toMyPublish (){
this.props.navigation.navigate('MyPublish');
// this.props.navigation.navigate('Notifications');
};
//渲染item
renderItem(item,index){
return(
<View key = {index} style={styles.listItem}>
<View style = {{flex:1,flexDirection:'row',display:'flex',alignItems:'center',width:'100%'}}>
<Image source={avatar} style={{width:(52/zoomH),height:(52/zoomH),borderRadius:(26/zoomH)}} resizeMode="contain" />
<View style = {{flex:1,paddingLeft:(10/zoomW)}} >
<Text style = {{fontSize:18,color:'#000000'}}>{item.title}</Text>
<View style = {{flex:1,display:'flex',flexDirection:'row',justifyContent:'space-between'}}>
<Text style = {{fontSize :12,color:'#999999'}}>Alice 4月23日 13:45</Text>
<Text style ={{fontSize :12,color:'#999999'}}>3人未确认 </Text>
</View>
</View>
</View>
<View style = {{flex:1}}>
<Text style = {{fontSize :14,color:'#666666',marginLeft :(62/zoomH),paddingTop:(17/zoomH), minHeight:70/zoomH}} numberOfLines={3} >{item.content}</Text>
{item.isRevoke && <Image source={withdraw} style={{width:(70/zoomH),height:(70/zoomH),borderRadius:(26/zoomH),position:'absolute',right:10,alignItems:'center'}} resizeMode="contain" />}
</View>
</View>
);
}
render(){
return(
<View style={styles.background}>
<ScrollView style={{width:'100%'}}>
<View style = {{width:'100%',backgroundColor:'#ffffff',alignItems:'center'}}>
<View style={styles.searchBox}>
<Image source={search} style={{width:(13/zoomH),height:(13/zoomH)}} resizeMode="contain" />
<TextInput returnKeyType="search" placeholder='搜索' placeholderTextColor='#8e8e93' style={styles.searchText}
underlineColorAndroid="transparent" clearButtonMode="while-editing"/>
<TouchableOpacity style={{height:'100%',position:'absolute',right:0,display:'flex',justifyContent:'center'}}>
<Image source={allDel} style={{width:(16/zoomH),height:(48/zoomH),marginLeft:(10/zoomW),marginRight:(10/zoomW)}} resizeMode="center" />
</TouchableOpacity>
</View>
</View>
<TouchableOpacity activeOpacity={1} style = {styles.myPublish} onPress = {()=>this._toMyPublish()}>
<Text style = {{fontSize:17,color:'#000000'}}>我发布的通知</Text>
<View style = {{alignItems :'center',display:'flex',flexDirection:'row'}}>
<Text style = {{fontSize: 17,color:'#666666',marginRight:(5/zoomW)}}>12</Text>
<Image source = {bread} style={{width:(13/zoomH),height:(13/zoomH)}} resizeMode="contain"/>
</View>
</TouchableOpacity>
<Text style = {{height:(28/zoomH),includeFontPadding:false, textAlignVertical:'center',paddingLeft:(15/zoomW),textAlign:'left',fontSize :12,color:'#999999',backgroundColor:'#ECECF1'}}>全部通知</Text>
{this.state.sheetList && this.state.sheetList.map((item,index) => this.renderItem(item,index))}
</ScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
topIcon:{
paddingLeft:(10/zoomW),
paddingRight:(10/zoomW),
height:'100%',
display:'flex',
alignItems:'center'
},
background:{
flex:1,
backgroundColor:'#ececf1',
display:'flex',
alignItems:'center'
},
itemBackground:{
flex:1,
backgroundColor:'#ffffff',
display:'flex',
alignItems:'center'
},
targetItem:{
flex:1,
display:'flex',
flexDirection:'row',
alignItems:'center',
borderStyle:'solid',
borderBottomColor:'#eee',
paddingLeft:(15/zoomW),
paddingRight:(15/zoomW),
paddingTop:(10/zoomH),
paddingBottom:(10/zoomH),
backgroundColor:'#fff'
},
searchBox:{
width:(345/zoomW),
height:(34/zoomH),
backgroundColor:'#eeeff3',
borderRadius:3,
display:'flex',
flexDirection:'row',
alignItems:'center',
paddingLeft:(12.5/zoomW),
paddingRight:(12.5/zoomW),
marginBottom:(12.5/zoomW)
},
searchText:{
flex:1,
fontSize:14,
color:'#000',
padding:0,
paddingLeft:(8/zoomW)
},
myPublish:{
width :'100%',
backgroundColor:'#ffffff',
paddingLeft:(15/zoomW),
paddingRight:(15/zoomW),
paddingTop:(6.5/zoomW),
paddingBottom:(19/zoomW),
justifyContent:'space-between',
flex :1,
display:'flex',
flexDirection: 'row'
},
listItem:{
flex:1,
display:'flex',
borderStyle:'solid',
backgroundColor:'#ffffff',
borderBottomColor:'#eee',
borderBottomWidth:StyleSheet.hairlineWidth,
paddingTop:(10/zoomH),
paddingLeft:(15/zoomW),
paddingRight:(15/zoomW),
paddingBottom:(10/zoomH)
}
})