@@ -13,6 +13,7 @@ var markdown = require("markdown").markdown
1313var Return = require ( '../components/overlay/Return' )
1414var CommentHtml = require ( '../components/htmlRender/CommentHtml' )
1515var CommentUp = require ( '../components/comment/CommentUp' )
16+ var Nav = require ( '../components/Nav' )
1617
1718var TopicService = require ( '../services/TopicService' )
1819var genColor = require ( '../util/genColor' )
@@ -222,35 +223,13 @@ class Comments extends Component {
222223 }
223224
224225
225- _onReturnPress ( ) {
226- this . props . router . pop ( )
227- }
228-
229-
230- _onReturnToTopic ( ) {
231- this . props . router . toTopic ( {
232- topic : this . topic
233- } )
234- }
235-
236-
237226 _onAuthorImgPress ( authorName ) {
238227 this . props . router . toUser ( {
239228 userName : authorName
240229 } )
241230 }
242231
243232
244- _onCommentTitlePress ( ) {
245- this . _listView . setNativeProps ( {
246- contentOffset : {
247- x : 0 ,
248- y : 0
249- }
250- } )
251- }
252-
253-
254233 renderRow ( comment , sectionID , rowID , highlightRow ) {
255234 var authorName = comment . author . loginname
256235 var domain = config . domain
@@ -431,47 +410,48 @@ class Comments extends Component {
431410
432411 render ( ) {
433412 var count = this . state . ds . getRowCount ( )
434- var returnToTopic = (
435- < TouchableHighlight
436- onPress = { this . _onReturnToTopic . bind ( this ) }
437- underlayColor = 'rgba(0,0,0,0.1)'
438- style = { styles . navToTopic } >
439- < Text style = { styles . navReturnText } >
440- 正文
441- </ Text >
442- </ TouchableHighlight >
443- )
444413
445- return (
446- < View style = { styles . container } >
447- < View
448- ref = { view => this . nav = view }
449- style = { styles . nav } >
450- < TouchableHighlight
451- onPress = { this . _onReturnPress . bind ( this ) }
452- underlayColor = 'rgba(0,0,0,0.1)'
453- style = { styles . navReturn } >
454- < Text style = { styles . navReturnText } >
455- 返回
456- </ Text >
457- </ TouchableHighlight >
414+ var router = this . props . router
458415
459- < TouchableOpacity
460- onPress = { this . _onCommentTitlePress . bind ( this ) }
461- style = { styles . navTitle } >
462- < Text style = { styles . titleText } >
463- 评论
464- < Text style = { styles . countText } >
465- { ' ' + count . toString ( ) }
466- </ Text >
467- </ Text >
468- </ TouchableOpacity >
416+ var navs = {
417+ Left : {
418+ text : '返回' ,
419+ onPress : ( ) => {
420+ router . pop ( )
421+ }
422+ } ,
423+ Center : {
424+ text : '评论 ' + count ,
425+ onPress : ( ) => {
426+ this . _listView . setNativeProps ( {
427+ contentOffset : {
428+ x : 0 ,
429+ y : 0
430+ }
431+ } )
432+ }
433+ }
434+ }
469435
470- {
471- ( this . state . didFocus && this . props . reply && this . state . isLoaded ) ? returnToTopic : null
436+ if ( this . state . didFocus && this . props . reply && this . state . isLoaded ) {
437+ navs = {
438+ ...navs ,
439+ Right : {
440+ text : '正文' ,
441+ onPress : ( ) => {
442+ router . toTopic ( {
443+ topic : this . topic
444+ } )
472445 }
446+ }
447+ }
448+ }
473449
474- </ View >
450+ return (
451+ < View style = { styles . container } >
452+ < Nav
453+ navs = { navs }
454+ > </ Nav >
475455
476456 < View
477457 ref = { view => this . commentsView = view }
@@ -507,47 +487,12 @@ var styles = StyleSheet.create({
507487 backgroundColor : 'white' ,
508488 height : height
509489 } ,
510- nav : {
511- height : navHeight ,
512- width : width ,
513- borderBottomColor : 'rgba(0,0,0,0.03)' ,
514- borderBottomWidth : 1 ,
515- flexDirection : 'row' ,
516- justifyContent : 'center' ,
517- alignItems : 'center'
518- } ,
519-
520- navReturn : {
521- height : navHeight ,
522- position : 'absolute' ,
523- left : 0 ,
524- top : 0 ,
525- paddingLeft : 15 ,
526- paddingRight : 15
527- } ,
528-
529- navToTopic : {
530- height : navHeight ,
531- position : 'absolute' ,
532- right : 0 ,
533- top : 0 ,
534- paddingLeft : 15 ,
535- paddingRight : 15
536- } ,
537- navReturnText : {
538- lineHeight : navHeight - 20 ,
539- fontSize : 16
540- } ,
541490
542491 titleText : {
543492 color : 'rgba(0,0,0,0.7)' ,
544493 fontSize : 16
545494 } ,
546495
547- countText : {
548- color : 'rgba(0,0,0,0.45)'
549- } ,
550-
551496 comments : {
552497 //marginTop: 20,
553498 width : width ,
0 commit comments