1
1
var React = require ( 'react-native' )
2
+ var { Icon } = require ( 'react-native-icons' )
3
+ var Modal = require ( 'react-native-modal' )
4
+
2
5
3
6
var Nav = require ( '../components/Nav' )
4
7
5
8
var window = require ( '../util/window' )
6
9
var { width, height } = window . get ( )
10
+ var config = require ( '../configs/config' )
7
11
8
12
9
13
var {
10
14
Component,
11
15
View,
12
16
Text,
13
- StyleSheet
17
+ StyleSheet,
18
+ PickerIOS,
19
+ TouchableOpacity,
20
+ TextInput
14
21
} = React
15
22
16
23
24
+ var PickerItemIOS = PickerIOS . Item
25
+
26
+
17
27
class Publish extends Component {
18
28
constructor ( props ) {
19
29
super ( props )
30
+ this . tabs = {
31
+ ask : '问答' ,
32
+ share : '分享' ,
33
+ job : '招聘'
34
+ }
35
+ this . state = {
36
+ selectTab : 'share' ,
37
+ isPickerShow : false ,
38
+ dirty : false
39
+ }
40
+ }
41
+
42
+
43
+ _renderPickerContent ( ) {
44
+ return Object . keys ( this . tabs ) . map ( tab => {
45
+ return (
46
+ < PickerItemIOS
47
+ key = { tab }
48
+ value = { tab }
49
+ label = { this . tabs [ tab ] }
50
+ > </ PickerItemIOS >
51
+ )
52
+ } )
53
+ }
54
+
55
+
56
+ _onPickerPress ( ) {
57
+ this . setState ( {
58
+ isPickerShow : true ,
59
+ dirty : true
60
+ } )
61
+ this . titleInput . blur ( )
62
+ this . contentInput . blur ( )
63
+ }
64
+
65
+
66
+ _onPickerValueChange ( tab ) {
67
+ this . setState ( {
68
+ selectTab : tab
69
+ } )
70
+ }
71
+
72
+
73
+ _closeModal ( ) {
74
+ this . setState ( {
75
+ isPickerShow : false
76
+ } )
20
77
}
21
78
22
79
@@ -40,17 +97,168 @@ class Publish extends Component {
40
97
}
41
98
}
42
99
}
100
+
101
+
43
102
return (
44
103
< View style = { styles . container } >
45
104
< Nav
46
105
navs = { navs }
47
106
> </ Nav >
107
+
108
+ < View style = { styles . content } >
109
+ < TouchableOpacity
110
+ onPress = { this . _onPickerPress . bind ( this ) }
111
+ >
112
+ < View style = { styles . row } >
113
+ < Icon
114
+ name = { 'ion|ios-keypad' }
115
+ size = { 24 }
116
+ color = '#1ABC9C'
117
+ style = { [ styles . selectorIcon , styles . labelIcon ] }
118
+ />
119
+
120
+ < Text style = { styles . tabSelectorText } >
121
+ { this . state . dirty ? this . tabs [ this . state . selectTab ] : '请选择板块' }
122
+ </ Text >
123
+
124
+ < Icon
125
+ name = { 'ion|ios-arrow-right' }
126
+ size = { 24 }
127
+ color = 'rgba(0,0,0,0.35)'
128
+ style = { styles . selectorIcon }
129
+ />
130
+ </ View >
131
+ </ TouchableOpacity >
132
+
133
+ < View style = { styles . row } >
134
+ < Icon
135
+ name = { 'ion|ios-bolt' }
136
+ size = { 24 }
137
+ color = '#1ABC9C'
138
+ style = { [ styles . selectorIcon , styles . labelIcon ] }
139
+ />
140
+
141
+ < TextInput
142
+ ref = { view => this . titleInput = view }
143
+ placeholder = '请输入标题'
144
+ style = { styles . titleInput }
145
+ //onChangeText={(text) => this.setState({text})}
146
+ //value={this.state.text}
147
+ />
148
+ </ View >
149
+
150
+
151
+ < TextInput
152
+ ref = { view => this . contentInput = view }
153
+ value = { '\n' + config . replySuffix }
154
+ style = { styles . topicContent }
155
+ multiline = { true }
156
+ //onChangeText={(text) => this.setState({text})}
157
+ //value={this.state.text}
158
+ />
159
+
160
+ </ View >
161
+
162
+
163
+ < Modal
164
+ style = { modalStyles }
165
+ onPressBackdrop = { this . _closeModal . bind ( this ) }
166
+ hideCloseButton = { true }
167
+ isVisible = { this . state . isPickerShow }
168
+ onClose = { ( ) => this . _closeModal ( ) } >
169
+
170
+ < View style = { styles . pickerIOS } >
171
+ < PickerIOS
172
+ selectedValue = { this . state . selectTab }
173
+ onValueChange = { this . _onPickerValueChange . bind ( this ) }
174
+ >
175
+
176
+ { this . _renderPickerContent ( ) }
177
+
178
+ </ PickerIOS >
179
+ </ View >
180
+
181
+ </ Modal >
182
+
48
183
</ View >
49
184
)
50
185
}
51
186
}
52
187
53
- var styles = StyleSheet . create ( { } )
188
+
189
+ var textColor = 'rgba(0,0,0,0.7)'
190
+
191
+
192
+ var styles = StyleSheet . create ( {
193
+ container : {
194
+ height : height ,
195
+ width : width ,
196
+ backgroundColor : 'white'
197
+ } ,
198
+ row : {
199
+ height : 51 ,
200
+ flexDirection : 'row' ,
201
+ alignItems : 'center' ,
202
+ justifyContent : 'space-between' ,
203
+ borderBottomColor : 'rgba(0,0,0,0.03)' ,
204
+ borderBottomWidth : 1
205
+ } ,
206
+ selectorIcon : {
207
+ height : 20 ,
208
+ width : 20
209
+ } ,
210
+ labelIcon : {
211
+ marginRight : 15
212
+ } ,
213
+ tabSelectorText : {
214
+ flex : 1 ,
215
+ color : textColor
216
+ } ,
217
+ titleInput : {
218
+ height : 50 ,
219
+ flex : 1 ,
220
+ color : textColor ,
221
+ fontSize : 14
222
+ } ,
223
+ content : {
224
+ paddingRight : 15 ,
225
+ paddingLeft : 15
226
+ } ,
227
+ topicContent : {
228
+ flexDirection : 'row' ,
229
+ alignItems : 'flex-start' ,
230
+ justifyContent : 'space-between' ,
231
+ paddingTop : 20 ,
232
+ height : height - 51 * 2 - Nav . navHeight
233
+ }
234
+ } )
235
+
236
+
237
+ var modalStyles = StyleSheet . create ( {
238
+ container : {
239
+ position : 'absolute' ,
240
+ top : 0 ,
241
+ bottom : 0 ,
242
+ left : 0 ,
243
+ right : 0 ,
244
+ backgroundColor : 'transparent' ,
245
+ justifyContent : 'flex-end' ,
246
+ } ,
247
+ backdrop : {
248
+ position : 'absolute' ,
249
+ top : 0 ,
250
+ bottom : 0 ,
251
+ left : 0 ,
252
+ right : 0 ,
253
+ backgroundColor : '#000000' ,
254
+ opacity : 0.07 ,
255
+ } ,
256
+ modal : {
257
+ backgroundColor : 'white' ,
258
+
259
+ }
260
+ } )
261
+
54
262
55
263
module . exports = Publish
56
264
0 commit comments