targetProgress.js
16.3 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/**
* Created by Cassie on 2018/05/14
*/
import React, { Component } from 'react';
import {
StyleSheet,
View,
Text,
TouchableOpacity,
Image,
TextInput,
ScrollView,
Platform,
InteractionManager,
KeyboardAvoidingView,
Keyboard,
FlatList
} from 'react-native';
import PercentageCircle from 'react-native-percentage-circle';
import {width,zoomW,zoomH} from '../../utils/getSize';
const back = require('../../img/returnB.png');
const avatar = require('../../img/avatar.png');
const bread = require('../../img/bread.png');
const rar = require('../../img/rar.png');
const discuss = require('../../img/discuss.png');
const toTop = require('../../img/toTop.png');
const videoPlayer = require('../../img/videoPlayer.png');
const sendMore = require('../../img/sendMore.png');
const upPic = require('../../img/upPic.png');
const upFile = require('../../img/upFile.png');
const upVoice = require('../../img/upVoice.png');
export default class TargetProgress extends Component {
static navigationOptions = ({ navigation, screenProps }) => ({
title:'任务进度',
headerLeft:(<View style={{display:'flex',flexDirection:'row'}}>
<TouchableOpacity style={styles.topIcon} onPress={navigation.state.params?navigation.state.params.back:null}>
<Image source={back} style={{width:(16/zoomH),height:(16/zoomH)}} resizeMode="contain" />
</TouchableOpacity>
</View>),
headerRight:(<View style={{display:'flex',flexDirection:'row'}} />)
});
constructor(props){
super(props);
this.state = {
percent:25,
attachmentList:['0','0','0','0','0','0','0','0','0','0','0','0','0'],
progressList:['0','0'],
bottom:0,
moreShow:false,
currentList:[],
content:''
};
};
componentWillMount(){
this.keyboardDidShowListener = Keyboard.addListener('keyboardDidShow',this.keyboardDidShow.bind(this));
this.keyboardDidHideListener = Keyboard.addListener('keyboardDidHide',this.keyboardDidHide.bind(this));
};
componentDidMount(){
this.props.navigation.setParams({
back:()=>{
InteractionManager.runAfterInteractions(() => {this.props.navigation.goBack();})
}
});
};
/*键盘弹出*/
keyboardDidShow(e){
this.setState({
moreShow:false
});
if(Platform.OS == 'android'){
this.setState({
bottom:(12/zoomH)
})
}else if(Platform.OS == 'ios'){
this.setState({
bottom:(7/zoomH)
})
}
};
/*键盘收起*/
keyboardDidHide(){
this.setState({
bottom:0
})
};
/* 渲染进度列表*/
keyExtractor = (item,index) => index;
renderProgressItem = ({item,index}) => (
<View>
<View style={styles.progressItem}>
<Text style={{fontSize:16,color:'#333'}}>今天</Text>
<View style={{display:'flex',flexDirection:'row',marginTop:(15/zoomH),marginBottom:(10/zoomH)}}>
<View style={{width:(34/zoomH),height:(34/zoomH),borderRadius:4,borderWidth:StyleSheet.hairlineWidth,borderColor:'#ddd'}}>
<Image source={avatar} style={{width:(34/zoomH),height:(34/zoomH),borderRadius:4}} resizeMode="contain" />
</View>
<View style={{paddingLeft:(12.5/zoomW),justifyContent:'center'}}>
<Text style={{fontSize:16,color:'#576B95'}}>Olivia</Text>
<Text style={{fontSize:16,color:'#333'}}>设计稿已完成</Text>
</View>
</View>
<View style={[styles.attachList,{height:(50/zoomH)}]}>
<TouchableOpacity activeOpacity={0.8} style={{width:'100%',height:'100%',display:'flex',flexDirection:'row',alignItems:'center'}}>
<Image source={rar} style={{width:(30/zoomH),height:(30/zoomH),borderRadius:4}} resizeMode="contain" />
<Text style={{fontSize:16,color:'#333',marginLeft:(10/zoomW)}}>设计稿.ZIP</Text>
</TouchableOpacity>
<FlatList showsHorizontalScrollIndicator={false} horizontal={true} keyExtractor={this.keyExtractor} data={this.state.attachmentList} renderItem={this.renderItem} />
</View>
<View style={[styles.attachList,{backgroundColor:'#fff',height:(20/zoomH),flexDirection:'row',alignItems:'center',justifyContent:'space-between',padding:0}]}>
<Text style={{fontSize:12,color:'#999',paddingTop:(10/zoomH)}}>09:00</Text>
<TouchableOpacity style={{width:(48/zoomW),paddingLeft:(30/zoomW),paddingTop:(10/zoomH)}} activeOpacity={0.8} onPress={() => this.refs.input.focus()}>
<Image source={discuss} style={{width:(18/zoomW),height:(12.5/zoomH)}} resizeMode="contain" />
</TouchableOpacity>
</View>
<View>
<Image source={toTop} style={{width:(10/zoomW),height:(6/zoomH),marginLeft:(55/zoomW),marginTop:(7.5/zoomH)}} resizeMode="contain" />
<View style={[styles.attachList,{backgroundColor:'#f3f3f3',padding:(15/zoomH)}]}>
<Text style={{fontSize:14,color:'#576b95'}}>James<Text style={{color:'#151515'}}>:周三开会对稿子!</Text></Text>
<Text style={{fontSize:14,color:'#576b95'}}>Olivia<Text style={{color:'#151515'}}>回复</Text>James<Text style={{color:'#151515'}}>:好的好的好的好的好的好的好的好的好的好的好的好的好的好的好的</Text></Text>
<Text style={{fontSize:14,color:'#576b95'}}>James<Text style={{color:'#151515'}}>:周三开会对稿子!</Text></Text>
</View>
</View>
</View>
<View style={styles.progressItem}>
<Text style={{fontSize:16,color:'#333'}}>今天</Text>
<View style={{display:'flex',flexDirection:'row',marginTop:(15/zoomH),marginBottom:(10/zoomH)}}>
<View style={{width:(34/zoomH),height:(34/zoomH),borderRadius:4,borderWidth:StyleSheet.hairlineWidth,borderColor:'#ddd'}}>
<Image source={avatar} style={{width:(34/zoomH),height:(34/zoomH),borderRadius:4}} resizeMode="contain" />
</View>
<View style={{paddingLeft:(12.5/zoomW),justifyContent:'center'}}>
<Text style={{fontSize:16,color:'#576B95'}}>Olivia</Text>
</View>
</View>
<TouchableOpacity activeOpacity={0.8} style={{width:'100%',display:'flex',flexDirection:'row',alignItems:'center',backgroundColor:'rgba(0,0,0,0)',marginTop:-(10/zoomH)}}>
<Image source={videoPlayer} style={{width:(169/zoomW),height:(40/zoomH),marginLeft:(45/zoomW)}} resizeMode="stretch" />
</TouchableOpacity>
<View style={[styles.attachList,{backgroundColor:'#fff',height:(20/zoomH),flexDirection:'row',alignItems:'center',justifyContent:'space-between',padding:0,marginTop:(2/zoomH)}]}>
<Text style={{fontSize:12,color:'#999',paddingTop:(10/zoomH)}}>09:00</Text>
<TouchableOpacity style={{width:(48/zoomW),paddingLeft:(30/zoomW),paddingTop:(10/zoomH)}} activeOpacity={0.8}>
<Image source={discuss} style={{width:(18/zoomW),height:(12.5/zoomH)}} resizeMode="contain" />
</TouchableOpacity>
</View>
</View>
</View>
);
/* 渲染附件列表*/
renderItem = ({item,index}) => (
<TouchableOpacity activeOpacity={0.8} style={{display:'flex',flexDirection:'row',alignItems:'center',marginRight:(7.5/zoomW)}}>
<Image source={rar} style={{width:(30/zoomH),height:(30/zoomH),borderRadius:2}} resizeMode="contain" />
</TouchableOpacity>
);
/*打开更多*/
showMore(){
Keyboard.dismiss();
this.setState({
moreShow:true
})
};
/*判断是否@*/
atOrNot(){
setTimeout(() => {
if(this.state.content.substring(this.state.content.length-1) == '@'){
InteractionManager.runAfterInteractions(() => {this.props.navigation.navigate('AddEmployee',{from:'@',callback:this.updateEmployee});})
}
},10)
};
/*回调刷新*/
updateEmployee = (employee) =>{
let currentList = this.state.currentList;
currentList.push({name:'@'+employee.name,id:employee.id});
this.setState({
currentList:currentList,
content:this.state.content + employee.name
});
};
/*发布信息*/
sendMsg(){
let resultName = [];
for(let i=0;i<this.state.currentList.length;i++){
if(this.state.content.indexOf(this.state.currentList[i].name) != -1){
resultName.push(this.state.currentList[i]);
}
}
}
render(){
return(
<View style={styles.background}>
<TouchableOpacity activeOpacity={0.8} style={styles.taskContent}>
<View style={styles.taskTop}>
<PercentageCircle collapsable={false} radius={(28/zoomH)} percent={this.state.percent} color={'#28c35a'} borderWidth={(2/zoomH)}>
<Image source={avatar} style={{width:(50/zoomH),height:(50/zoomH),borderRadius:(25/zoomH)}} resizeMode="contain" />
<View style={{width:(50/zoomH),height:(50/zoomH),borderRadius:(25/zoomH),position:'absolute',display:'flex',justifyContent:'center',alignItems:'center',backgroundColor:'rgba(0,0,0,.2)'}}>
<Text style={{fontSize:14,color:'#fff'}}>{this.state.percent}%</Text>
</View>
</PercentageCircle>
<View style={{flex:1,marginLeft:(15/zoomW)}}>
<View style={{flex:1,height:(25/zoomH),display:'flex',flexDirection:'row',justifyContent:'space-between',alignItems:'flex-end'}}>
<Text style={{fontSize:18,color:'#000'}} numberOfLines={1}>企信2.0设计</Text>
<Image source={bread} style={{width:(6/zoomW),height:(11/zoomH)}} resizeMode="contain" />
</View>
<View style={{flex:1,height:(25/zoomH),display:'flex',justifyContent:'flex-start'}}>
<Text style={{fontSize:14,color:'#999'}} numberOfLines={1}>还剩下17天</Text>
</View>
</View>
</View>
<View style={{width:'100%',paddingLeft:(63/zoomW),paddingRight:(15/zoomW),paddingBottom:(15/zoomH)}}>
<Text style={{fontSize:16,color:'#666'}} numberOfLines={3}>
不少设计师开始利用诸如斑点和小气泡这样的装饰性元素,分散在网页的各个角落。这些装饰性的元素大多以小不少设计师开始利用诸如斑点和小气泡这样的装饰性元素,分散在网页的各个角落。这些装饰性的元素大多以小不少设计师开始利用诸如斑点和小气泡这样的装饰性元素,分散在网页的各个角落。这些装饰性的元素大多以小不少设计师开始利用诸如斑点和小气泡这样的装饰性元素,分散在网页的各个角落。这些装饰性的元素大多以小不少设计师开始利用诸如斑点和小气泡这样的装饰性元素,分散在网页的各个角落。这些装饰性的元素大多以小
</Text>
</View>
</TouchableOpacity>
<FlatList style={{marginBottom:(58/zoomH)}} showsVerticalScrollIndicator={false} keyExtractor={this.keyExtractor} data={this.state.progressList} renderItem={this.renderProgressItem} />
<View style={[styles.inputBox,{bottom:this.state.bottom}]}>
<View style={{display:'flex',flexDirection:'row',alignItems:'center',paddingLeft:(15/zoomH),marginBottom:(7/zoomH)}}>
<TextInput ref="input" placeholder='发布任务进度' placeholderTextColor='#999' returnKeyType="send" underlineColorAndroid="transparent" style={styles.inputText} onChangeText={(value) => {this.setState({content:value},this.atOrNot())}} defaultValue={this.state.content} onSubmitEditing={() => this.sendMsg()} />
<TouchableOpacity activeOpacity={0.8} style={{paddingLeft:(12/zoomW),paddingRight:(12/zoomW)}} onPress={() => this.showMore()}>
<Image source={sendMore} style={{width:(28/zoomH),height:(28/zoomH)}} resizeMode="contain" />
</TouchableOpacity>
</View>
{this.state.moreShow && <View style={styles.progressMore}>
<TouchableOpacity activeOpacity={0.8} style={styles.moreItem}>
<View style={{width:'100%',height:(60/zoomH),borderRadius:8,display:'flex',justifyContent:'center',alignItems:'center',backgroundColor:'#fff'}}>
<Image source={upPic} resizeMode="contain" />
</View>
<Text style={{fontSize:12,color:'#909090',marginTop:(9/zoomH)}}>照片</Text>
</TouchableOpacity>
<TouchableOpacity activeOpacity={0.8} style={styles.moreItem}>
<View style={{width:'100%',height:(60/zoomH),borderRadius:8,display:'flex',justifyContent:'center',alignItems:'center',backgroundColor:'#fff'}}>
<Image source={upFile} resizeMode="contain" />
</View>
<Text style={{fontSize:12,color:'#909090',marginTop:(9/zoomH)}}>文件</Text>
</TouchableOpacity>
<TouchableOpacity activeOpacity={0.8} style={styles.moreItem}>
<View style={{width:'100%',height:(60/zoomH),borderRadius:8,display:'flex',justifyContent:'center',alignItems:'center',backgroundColor:'#fff'}}>
<Image source={upVoice} resizeMode="contain" />
</View>
<Text style={{fontSize:12,color:'#909090',marginTop:(9/zoomH)}}>语音</Text>
</TouchableOpacity>
</View>}
</View>
</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'
},
taskContent:{
width:'100%',
marginTop:StyleSheet.hairlineWidth,
paddingLeft:(15/zoomW),
paddingRight:(15/zoomW),
backgroundColor:'#fff',
display:'flex',
justifyContent:'center',
marginBottom:(10/zoomH)
},
taskTop:{
width:'100%',
display:'flex',
flexDirection:'row',
alignItems:'center',
paddingTop:(15/zoomH)
},
progressItem:{
width:'100%',
padding:(17/zoomH),
backgroundColor:'#fff'
},
attachList:{
width:(292/zoomW),
marginLeft:(45/zoomW),
backgroundColor:'#f3f3f3',
padding:(10/zoomH),
display:'flex'
},
inputBox:{
width:'100%',
backgroundColor:'#f5f5f5',
paddingTop:(7/zoomH),
position:'absolute',
bottom:0
},
inputText:{
flex:1,
height:(36/zoomH),
borderRadius:4,
padding:0,
paddingLeft:(10/zoomW),
paddingRight:(10/zoomW),
backgroundColor:'#fff',
fontSize:16,
color:'#333'
},
progressMore:{
width:'100%',
height:(115/zoomH),
paddingLeft:(30/zoomW),
paddingRight:(30/zoomW),
paddingTop:(15/zoomH),
display:'flex',
flexDirection:'row',
flexWrap:'wrap'
},
moreItem:{
width:(60/zoomH),
display:'flex',
alignItems:'center',
marginRight:(25/zoomW)
}
});