TopicBoard.js
5.25 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
import React, {Component} from "react";
import {
ActivityIndicator,
DeviceEventEmitter,
Image,
ImageBackground,
StyleSheet,
Text,
TouchableOpacity,
View
} from "react-native";
import {zoomH, zoomW} from '../../utils/getSize';
import TopicInfoUtil from '../component/topicInfo';
import HomeList from "../../pages/home/HomeList";
import {NoDoublePress} from "../../utils/utils";
var InfoBg = ImageBackground;
var deEmitter = DeviceEventEmitter;
//图片资源
const backArrow = require('../../img/backWhite.png');
// 变量定义
{
let parm_topicId = 0
}
export default class TopicBoard extends Component {
static navigationOptions = ({ navigation, screenProps }) => ({
header:null,
});
constructor(props){
super(props);
parm_topicId = this.props.navigation.state.params.id;
TopicInfoUtil.parm_topicId = parm_topicId;
this.state = {
// 信息区域的背景图
imgUrl:'',
infoLoading:true,
listLoading:true
};
};
componentWillMount(){
};
componentDidMount(){
//设置头部
this.props.navigation.setParams({
back:()=>{
this.props.navigation.goBack();
},
});
let _this = this;
this.deEmitter = DeviceEventEmitter.addListener('getTopicInfo', (url) => {
console.log('getTopicInfo' + url);
_this.setState({
imgUrl:url,
infoLoading:false
})
});
this.deEmitter = DeviceEventEmitter.addListener('getTopicList', () => {
console.log('收到通知getTopicList:');
_this.setState({
listLoading:false
})
});
}
componentWillUnmount(){
this.deEmitter.remove();
}
onBackPress(){
this.props.navigation.goBack();
}
render() {
return(
<View style = {styles.background}>
{/*话题信息区域背景图*/}
<InfoBg style = {styles.infoBg} source = {{uri:this.state.imgUrl}}>
<View style = {{position:'absolute',width:'100%',height:'100%',backgroundColor:'rgba(0,0,0,0.25)'}}></View>
{/*假的导航区域*/}
<View style = {styles.navi}>
{/*导航返回按钮*/}
<TouchableOpacity style={styles.backStyle} onPress={() => {
NoDoublePress.onPress(()=>{
this.onBackPress();
});
}}>
<Image style={{width:9/zoomW,height:16/zoomH}} source={backArrow} resizeMode="cover" />
</TouchableOpacity>
</View>
{/*话题信息*/}
<View style = {styles.info}>
{/*话题信息自定义UI*/}
<TopicInfoUtil id={parm_topicId}/>
</View>
</InfoBg>
{/*/!*使用话题的帖子列表*!/*/}
<HomeList arr_keyValue = {[{'topicId':parm_topicId}]} navigation={this.props.navigation}/>
{(this.state.infoLoading || this.state.listLoading) && (
<View style={styles.loadingBg}>
<View style={styles.loadingBox}>
<ActivityIndicator size="large" color="#fff" />
<Text
style={{ fontSize: 16, color: "#fff", marginTop: 6 / zoomH }}
>
加载中...
</Text>
</View>
</View>
)}
</View>
);
}
}
const styles = StyleSheet.create({
background:{
flex: 1,
backgroundColor: 'white',
display: 'flex',
},
loadingBg: {
position: "absolute",
top: 0,
width: "100%",
height: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center"
},
loadingBox: {
width: 100 / zoomW,
height: 120 / zoomH,
backgroundColor: "rgba(0,0,0,.5)",
borderRadius: 8,
display: "flex",
alignItems: "center",
justifyContent: "center"
},
navi:{
display: 'flex',
alignItems: 'flex-start',
justifyContent:'flex-start',
flexDirection:'row',
width:'100%',
height:89/zoomH
},
backStyle:{
display: 'flex',
alignItems: 'flex-start',
justifyContent:'flex-start',
flexDirection:'row',
width:9/zoomW,
height:16/zoomH,
marginTop:34/zoomH,
marginLeft:15/zoomW
},
infoBg:{
height:195/zoomH,
width:'100%',
backgroundColor:'#000',
display: 'flex',
flexDirection:'column',
justifyContent:'flex-start',
alignItems:'flex-start'
},
info:{
backgroundColor:'rgba(0,0,0,0)',
display: 'flex',
flexDirection:'row',
justifyContent:'flex-start',
alignItems:'flex-start',
position:'absolute',
left:15/zoomW,
right:23/zoomW,
bottom:20/zoomH
},
});