@@ -14,10 +14,7 @@ import {
1414 Animated ,
1515 Easing
1616} from 'react-native' ;
17- import { SmartRefreshControl , AnyHeader } from 'react-native-smartrefreshlayout' ;
18- import Icon from 'react-native-vector-icons/Ionicons'
19- import { DotIndicator , SkypeIndicator } from 'react-native-indicators' ;
20- const AnimatedIcon = Animated . createAnimatedComponent ( Icon )
17+ import HuaWeiRefreshControl from './HuaWeiRefreshControl'
2118const instructions = Platform . select ( {
2219 ios : 'Press Cmd+R to reload,\n' +
2320 'Cmd+D or shake for dev menu' ,
@@ -42,75 +39,19 @@ Date.prototype.Format = function (fmt) { // author: meizz
4239}
4340type Props = { } ;
4441export default class App extends Component < Props > {
45- state = {
46- text : '下拉刷新' ,
47- rotate : new Animated . Value ( 0 ) ,
48- refreshing : false
42+ _onRefresh = ( ) => {
43+ setTimeout ( ( ) => {
44+ this . _hw && this . _hw . finishRefresh ( )
45+ } , 1000 )
4946 }
50-
5147 render ( ) {
5248 return (
5349 < ScrollView
50+ style = { { flex :1 } }
5451 refreshControl = {
55- < SmartRefreshControl
56- ref = { ref => this . _refreshc = ref }
57- onRefresh = { ( ) => {
58- console . log ( 'onRefresh' + ( ( new Date ( ) ) . Format ( "yyyy-MM-dd hh:mm:ss.S" ) ) )
59-
60- setTimeout ( ( ) => {
61- this . _refreshc && this . _refreshc . finishRefresh ( ) ;
62- } , 1000 )
63- } }
64- onPullDownToRefresh = { ( ) => {
65- this . setState ( {
66- text :'下拉刷新' ,
67- refreshing :false
68- } )
69- Animated . timing ( this . state . rotate , {
70- toValue :0 ,
71- duration :197 ,
72- useNativeDriver :true ,
73- easing :Easing . linear ( )
74- } ) . start ( )
75- }
76- }
77- onHeaderReleased = { ( e ) => {
78- console . log ( 'onHeaderReleased' + ( ( new Date ( ) ) . Format ( "yyyy-MM-dd hh:mm:ss.S" ) ) )
79- this . setState ( {
80- refreshing :true ,
81- text :'正在刷新'
82- } ) ;
83- } }
84- onReleaseToRefresh = { ( ) => {
85- this . setState ( {
86- text :'释放刷新'
87- } )
88- Animated . timing ( this . state . rotate , {
89- toValue :1 ,
90- duration :197 ,
91- useNativeDriver :true ,
92- easing :Easing . linear ( )
93- } ) . start ( )
94- } }
95- headerHeight = { 100 }
96- HeaderComponent = {
97- < AnyHeader style = { {
98- height : 100 ,
99- flexDirection : 'row' ,
100- alignItems : 'center' ,
101- justifyContent : 'center' ,
102- } } >
103- { this . state . refreshing ?< SkypeIndicator style = { { flex :0 } } size = { 24 } color = { '#2783cf' } /> :< AnimatedIcon style = { {
104- transform :[ {
105- rotate :this . state . rotate . interpolate ( {
106- inputRange :[ 0 , 1 ] ,
107- outputRange :[ '180deg' , '0deg' ]
108- } )
109- } ]
110- } } name = "md-arrow-up" color = "#2783cf" size = { 24 } /> }
111- < Text style = { { marginLeft :15 } } > { this . state . text } </ Text >
112- </ AnyHeader >
113- }
52+ < HuaWeiRefreshControl
53+ ref = { ref => this . _hw = ref }
54+ onRefresh = { this . _onRefresh }
11455 />
11556 }
11657 >
0 commit comments