Skip to content

Commit 041d1e7

Browse files
committed
complete Example
1 parent 8a59602 commit 041d1e7

File tree

20 files changed

+550
-367
lines changed

20 files changed

+550
-367
lines changed

.idea/workspace.xml

Lines changed: 259 additions & 319 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/App.js

Lines changed: 105 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,121 @@
44
* @flow
55
*/
66

7-
import React, { Component } from 'react';
7+
import React, {Component} from 'react';
88
import {
9-
Platform,
10-
StyleSheet,
11-
Text,
12-
View
9+
Platform,
10+
StyleSheet,
11+
Text,
12+
View,
13+
ScrollView,
14+
Animated,
1315
} from 'react-native';
14-
16+
import {SmartRefreshControl, AnyHeader} from 'react-native-smartrefreshlayout-next';
17+
import Icon from 'react-native-vector-icons/Ionicons'
18+
import {DotIndicator,SkypeIndicator} from 'react-native-indicators';
19+
const AnimatedIcon = Animated.createAnimatedComponent(Icon)
1520
const instructions = Platform.select({
16-
ios: 'Press Cmd+R to reload,\n' +
21+
ios: 'Press Cmd+R to reload,\n' +
1722
'Cmd+D or shake for dev menu',
18-
android: 'Double tap R on your keyboard to reload,\n' +
23+
android: 'Double tap R on your keyboard to reload,\n' +
1924
'Shake or press menu button for dev menu',
2025
});
2126

2227
type Props = {};
2328
export default class App extends Component<Props> {
24-
render() {
25-
return (
26-
<View style={styles.container}>
27-
<Text style={styles.welcome}>
28-
Welcome to React Native!
29-
</Text>
30-
<Text style={styles.instructions}>
31-
To get started, edit App.js
32-
</Text>
33-
<Text style={styles.instructions}>
34-
{instructions}
35-
</Text>
36-
</View>
37-
);
38-
}
29+
state = {
30+
text:'下拉刷新',
31+
rotate:new Animated.Value(0),
32+
refreshing:false
33+
}
34+
35+
render() {
36+
return (
37+
<ScrollView
38+
refreshControl={
39+
<SmartRefreshControl
40+
ref={ref=>this._refreshc = ref}
41+
onPullDownToRefresh={()=>{
42+
this.setState({
43+
text:'下拉刷新',
44+
refreshing:false
45+
})
46+
Animated.timing(this.state.rotate,{
47+
toValue:0,
48+
duration:197,
49+
useNativeDriver:true,
50+
}).start()
51+
}
52+
}
53+
onRefresh={()=>{
54+
this.setState({
55+
refreshing:true,
56+
text:'正在刷新'
57+
})
58+
setTimeout(()=>{
59+
this._refreshc && this._refreshc.finishRefresh();
60+
},1000)
61+
}}
62+
onReleaseToRefresh={()=>{
63+
this.setState({
64+
text:'释放刷新'
65+
})
66+
Animated.timing(this.state.rotate,{
67+
toValue:1,
68+
duration:197,
69+
useNativeDriver:true,
70+
}).start()
71+
}}
72+
headerHeight={100}
73+
HeaderComponent={
74+
<AnyHeader style={{
75+
height: 100,
76+
flexDirection: 'row',
77+
alignItems: 'center',
78+
justifyContent: 'center',
79+
}}>
80+
{this.state.refreshing?<SkypeIndicator style={{flex:0}} size={24} color={'#2783cf'}/>:<AnimatedIcon style={{
81+
transform:[{
82+
rotate:this.state.rotate.interpolate({
83+
inputRange:[0,1],
84+
outputRange:['0deg','180deg']
85+
})
86+
}]
87+
}} name="md-arrow-up" color="#2783cf" size={24}/>}
88+
<Text style={{marginLeft:15}}>{this.state.text}</Text>
89+
</AnyHeader>
90+
}
91+
/>
92+
}
93+
>
94+
<View style={styles.container}>
95+
<Text style={styles.instructions}>
96+
To get started, edit App.js
97+
</Text>
98+
<Text style={styles.instructions}>
99+
{instructions}
100+
</Text>
101+
</View>
102+
</ScrollView>
103+
);
104+
}
39105
}
40106

41107
const styles = StyleSheet.create({
42-
container: {
43-
flex: 1,
44-
justifyContent: 'center',
45-
alignItems: 'center',
46-
backgroundColor: '#F5FCFF',
47-
},
48-
welcome: {
49-
fontSize: 20,
50-
textAlign: 'center',
51-
margin: 10,
52-
},
53-
instructions: {
54-
textAlign: 'center',
55-
color: '#333333',
56-
marginBottom: 5,
57-
},
108+
container: {
109+
flex: 1,
110+
justifyContent: 'center',
111+
alignItems: 'center',
112+
backgroundColor: '#F5FCFF',
113+
},
114+
welcome: {
115+
fontSize: 20,
116+
textAlign: 'center',
117+
margin: 10,
118+
},
119+
instructions: {
120+
textAlign: 'center',
121+
color: '#333333',
122+
marginBottom: 5,
123+
},
58124
});

Example/android/app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ android {
137137
}
138138

139139
dependencies {
140+
compile project(':react-native-vector-icons')
141+
compile project(':react-native-smartrefreshlayout-next')
140142
compile fileTree(dir: "libs", include: ["*.jar"])
141143
compile "com.android.support:appcompat-v7:23.0.1"
142144
compile "com.facebook.react:react-native:+" // From node_modules
64 KB
Binary file not shown.
12.8 KB
Binary file not shown.
54 KB
Binary file not shown.
162 KB
Binary file not shown.
55.6 KB
Binary file not shown.
141 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)