-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathPullToRefresh.js
83 lines (75 loc) · 2.05 KB
/
PullToRefresh.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React from 'react';
import { StyleSheet, Text, Image, TouchableOpacity, View, Dimensions, RefreshControl } from 'react-native';
import { Header } from 'react-navigation';
import HeaderImageScrollView from 'react-native-image-header-scroll-view';
const MIN_HEIGHT = Header.HEIGHT;
const MAX_HEIGHT = 200;
class BasicUsage extends React.Component {
constructor() {
super();
this.state = {
refreshing: false,
};
}
_onRefresh() {
this.setState({
refreshing: true,
});
setTimeout(() => {
this.setState({
refreshing: false,
});
}, 2000);
}
render() {
return (
<View style={styles.container}>
<HeaderImageScrollView
maxHeight={MAX_HEIGHT}
minHeight={MIN_HEIGHT}
minOverlayOpacity={0.4}
renderHeader={() => <Image source={require('../../assets/pullrefresh.jpg')} style={styles.image} />}
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this._onRefresh.bind(this)}
tintColor="white"
/>
}
renderTouchableFixedForeground={() => (
<View style={{ height: MAX_HEIGHT, justifyContent: 'center', alignItems: 'center' }}>
<TouchableOpacity onPress={() => console.log('tap!!')} style={styles.button}>
<Text style={styles.buttonText}>Click Me!</Text>
</TouchableOpacity>
</View>
)}
scrollViewBackgroundColor="#ddddff"
>
<View style={{ height: 1000 }} />
</HeaderImageScrollView>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
image: {
height: MAX_HEIGHT,
width: Dimensions.get('window').width,
},
button: {
borderWidth: 1,
borderRadius: 8,
paddingVertical: 10,
paddingHorizontal: 30,
borderColor: 'white',
backgroundColor: '#00000066',
},
buttonText: {
color: 'white',
backgroundColor: 'transparent',
},
});
export default BasicUsage;