44'use strict' ;
55
66import React , { Component , PropTypes } from 'react' ;
7- import { StyleSheet , View , WebView , InteractionManager , Text , TouchableOpacity , ActivityIndicator , Alert , Linking , Clipboard , Modal } from 'react-native' ;
7+ import { StyleSheet , View , WebView , InteractionManager , Text , TouchableOpacity , ActivityIndicator , Alert , Linking , Clipboard , Modal , PanResponder , Animated , ToastAndroid } from 'react-native' ;
88import theme from '../constants/theme' ;
99import NavigationBar from '../components/NavigationBar' ;
1010import BackPageComponent from '../components/BackPageComponent' ;
@@ -21,20 +21,45 @@ class WebViewPage extends BackPageComponent{
2121 super ( props ) ;
2222 this . state = {
2323 didMount : false ,
24- showMoreContent : false
24+ showMoreContent : false ,
25+ bottomInfoBarBottomValue : new Animated . Value ( 0 ) ,
26+ toolbarTopValue : new Animated . Value ( 0 )
2527 } ;
2628 this . bottomIconNames = [ 'ios-arrow-back-outline' ,
2729 'ios-arrow-forward-outline' ,
2830 'ios-refresh-outline'
2931 ] ;
3032 this . bottomIconSize = [ px2dp ( 25 ) , px2dp ( 25 ) , px2dp ( 32 ) ] ;
33+
34+ this . moveYThreshold = 5 ;
35+ this . animationFlag = true ;
36+ }
37+
38+ componentWillMount ( ) {
39+ this . _panResponder = PanResponder . create ( {
40+ onMoveShouldSetPanResponder : ( evt , gestureState ) => true ,
41+ onPanResponderMove : ( evt , gestureState ) => {
42+ let y = gestureState . dy ;
43+ if ( y > this . moveYThreshold ) //drag down
44+ if ( this . state . bottomInfoBarBottomValue === px2dp ( 0 ) ) return ;
45+ this . animationFlag = false ;
46+ Animated . timing ( this . state . bottomInfoBarBottomValue , { toValue : 0 } ) . start ( ( ) => this . animationFlag = true ) ;
47+ Animated . timing ( this . state . toolbarTopValue , { toValue : 0 } ) . start ( ) ;
48+ if ( y < - this . moveYThreshold && this . animationFlag ) { //drag up
49+ if ( this . state . bottomInfoBarBottomValue === px2dp ( - 45 ) ) return ;
50+ this . animationFlag = false ;
51+ Animated . timing ( this . state . bottomInfoBarBottomValue , { toValue : px2dp ( - 45 ) } ) . start ( ( ) => this . animationFlag = true ) ;
52+ Animated . timing ( this . state . toolbarTopValue , { toValue : - theme . toolbar . height } ) . start ( ) ;
53+ }
54+ }
55+ } ) ;
3156 }
3257
3358 render ( ) {
3459 const rowData = this . props . rowData ;
3560 return (
3661 < View style = { [ styles . container , { backgroundColor : this . props . pageBackgroundColor } ] } >
37- < View style = { styles . contentContainer } >
62+ < View style = { styles . contentContainer } { ... this . _panResponder . panHandlers } >
3863 { this . state . didMount ?
3964 < WebView
4065 ref = { ( ref ) => { this . webView = ref } }
@@ -63,16 +88,16 @@ class WebViewPage extends BackPageComponent{
6388 </ View >
6489 </ Modal >
6590
66- < View style = { styles . toolbar } >
91+ < Animated . View style = { [ styles . toolbar , { top : this . state . toolbarTopValue } ] } >
6792 < NavigationBar
6893 title = "详细内容"
6994 leftBtnIcon = "arrow-back"
7095 leftBtnPress = { this . _handleBack . bind ( this ) }
7196 rightBtnIcon = "more"
7297 rightBtnPress = { this . _btnOnPressCallback . bind ( this , 9 ) }
7398 />
74- </ View >
75- < View style = { [ styles . bottomInfoBar , { backgroundColor : this . props . webViewToolbarColor , borderTopColor : this . props . segmentColor } ] } >
99+ </ Animated . View >
100+ < Animated . View style = { [ styles . bottomInfoBar , { bottom : this . state . bottomInfoBarBottomValue , backgroundColor : this . props . webViewToolbarColor , borderTopColor : this . props . segmentColor } ] } >
76101 { this . bottomIconNames . map ( ( item , i ) => {
77102 return (
78103 < View key = { i } style = { { flex : 1 , alignItems : 'center' } } >
@@ -99,7 +124,7 @@ class WebViewPage extends BackPageComponent{
99124 </ TouchableOpacity >
100125 }
101126 </ View >
102- </ View >
127+ </ Animated . View >
103128 </ View >
104129 ) ;
105130 }
@@ -208,15 +233,13 @@ const styles = StyleSheet.create({
208233 position : 'absolute' ,
209234 width : theme . screenWidth ,
210235 marginTop : theme . toolbar . paddingTop ,
211- top : 0 ,
212236 zIndex : 1
213237 } ,
214238 webView : {
215239 flex : 1
216240 } ,
217241 bottomInfoBar : {
218242 position : 'absolute' ,
219- bottom : 0 ,
220243 height : px2dp ( 45 ) ,
221244 width : theme . screenWidth ,
222245 borderTopWidth : theme . segment . width ,
0 commit comments