Skip to content

Commit d581c61

Browse files
authored
Merge pull request #10 from bamlab/fix-content-size
Fix the height bug #7
2 parents b45af6e + 51882f3 commit d581c61

File tree

6 files changed

+57
-2
lines changed

6 files changed

+57
-2
lines changed

example/Pages/Colors.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from 'react';
2+
import { StyleSheet, Image, View, Dimensions } from 'react-native';
3+
import { NavigationBar } from '@exponent/ex-navigation';
4+
5+
import HeaderImageScrollView from 'react-native-image-header-scroll-view';
6+
7+
const MIN_HEIGHT = NavigationBar.DEFAULT_HEIGHT;
8+
9+
const styles = StyleSheet.create({
10+
image: {
11+
height: 200,
12+
width: Dimensions.get('window').width,
13+
},
14+
});
15+
16+
class ColorsPage extends React.Component {
17+
render() {
18+
return (
19+
<View style={{ flex: 1, marginTop: -MIN_HEIGHT }}>
20+
<HeaderImageScrollView
21+
maxHeight={150}
22+
minHeight={80}
23+
fadeOutForeground
24+
renderHeader={() => (
25+
<Image source={require('../assets/cutecat.jpg')} style={styles.image} />
26+
)}
27+
>
28+
<View style={{ height: 100, backgroundColor: 'blue' }} />
29+
<View style={{ height: 100, backgroundColor: 'red' }} />
30+
<View style={{ height: 100, backgroundColor: 'green' }} />
31+
<View style={{ height: 100, backgroundColor: 'purple' }} />
32+
<View style={{ height: 100, backgroundColor: 'orange' }} />
33+
<View style={{ height: 100, backgroundColor: 'pink' }} />
34+
<View style={{ height: 100, backgroundColor: 'brown' }} />
35+
<View style={{ height: 100, backgroundColor: 'yellow' }} />
36+
</HeaderImageScrollView>
37+
</View>
38+
);
39+
}
40+
}
41+
42+
ColorsPage.route = {
43+
navigationBar: {
44+
tintColor: 'white',
45+
backgroundColor: 'transparent',
46+
borderBottomWidth: 0,
47+
statusBarHeight: 0,
48+
elevation: 0,
49+
},
50+
};
51+
52+
export default ColorsPage;

example/Pages/Menu.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ const Menu = () => (
5555
<StatusBar />
5656
<Button image={require('../assets/NZ.jpg')} text="BasicUsage" target="basicUsage" />
5757
<Button image={tvShowContent.image} text="TV Show" target="tvShow" />
58+
<Button image={require('../assets/cutecat.jpg')} text="Cute cat" target="colors" />
5859
</View>
5960
);
6061

example/Pages/index.js

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

example/assets/cutecat.jpg

31 KB
Loading

example/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import {
1111
StackNavigation,
1212
} from '@exponent/ex-navigation';
1313

14-
import { Menu, TvShow, BasicUsage } from './Pages';
14+
import { Menu, TvShow, BasicUsage, ColorsPage } from './Pages';
1515

1616
export const Router = createRouter(() => ({
1717
menu: () => Menu,
1818
tvShow: () => TvShow,
1919
basicUsage: () => BasicUsage,
20+
colors: () => ColorsPage,
2021
}));
2122

2223
class App extends React.Component {

src/ImageHeaderScrollView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class ImageHeaderScrollView extends Component {
148148

149149
const childrenContainerStyle = StyleSheet.flatten([
150150
{ transform: [{ translateY: headerScrollDistance }] },
151-
{ backgroundColor: 'white' },
151+
{ backgroundColor: 'white', paddingBottom: this.props.maxHeight },
152152
this.props.childrenStyle,
153153
]);
154154

0 commit comments

Comments
 (0)