Skip to content

Commit a02ce37

Browse files
committed
Add pull to resfresh example
1 parent bcb9f51 commit a02ce37

6 files changed

Lines changed: 100 additions & 3 deletions

File tree

example/Pages/Menu.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const Menu = props =>
7474
text="Forms and buttons"
7575
target="avignon"
7676
/>
77+
<Button {...props} image={require('../assets/pullrefresh.jpg')} text="Pull To Refresh" target="pullrefresh" />
7778
</ScrollView>;
7879

7980
Menu.route = {

example/Pages/PullToRefresh.js

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

example/Pages/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export { default as TvShow } from './TvShow';
33
export { default as BasicUsage } from './BasicUsage';
44
export { default as ColorsPage } from './Colors';
55
export { default as Avignon } from './Avignon';
6+
export { default as PullToRefresh } from './PullToRefresh';

example/assets/pullrefresh.jpg

171 KB
Loading

example/ios/imageHeaderScrollView.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,8 @@
998998
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
999999
CURRENT_PROJECT_VERSION = 1;
10001000
DEAD_CODE_STRIPPING = NO;
1001-
INFOPLIST_FILE = imageHeaderScrollView/Info.plist;
1001+
DEVELOPMENT_TEAM = "";
1002+
INFOPLIST_FILE = "$(SRCROOT)/imageHeaderScrollViewTests/Info.plist";
10021003
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
10031004
OTHER_LDFLAGS = (
10041005
"$(inherited)",
@@ -1015,7 +1016,8 @@
10151016
buildSettings = {
10161017
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
10171018
CURRENT_PROJECT_VERSION = 1;
1018-
INFOPLIST_FILE = imageHeaderScrollView/Info.plist;
1019+
DEVELOPMENT_TEAM = "";
1020+
INFOPLIST_FILE = "$(SRCROOT)/imageHeaderScrollViewTests/Info.plist";
10191021
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
10201022
OTHER_LDFLAGS = (
10211023
"$(inherited)",

example/main.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { StackNavigator } from 'react-navigation';
22

3-
import { Menu, TvShow, BasicUsage, ColorsPage, Avignon } from './Pages';
3+
import { Menu, TvShow, BasicUsage, ColorsPage, Avignon, PullToRefresh } from './Pages';
44

55
export const App = StackNavigator(
66
{
@@ -19,6 +19,9 @@ export const App = StackNavigator(
1919
avignon: {
2020
screen: Avignon,
2121
},
22+
pullrefresh: {
23+
screen: PullToRefresh,
24+
},
2225
},
2326
{
2427
navigationOptions: {

0 commit comments

Comments
 (0)