Skip to content

Commit 24a8c53

Browse files
committed
Add ScrollView inside Overlay example
Complex layouts were added to relevant parts in the playground app.
1 parent 025c5e8 commit 24a8c53

File tree

5 files changed

+74
-211
lines changed

5 files changed

+74
-211
lines changed

playground/src/screens/ComplexLayout.js

Lines changed: 0 additions & 197 deletions
This file was deleted.

playground/src/screens/OverlayScreen.js

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class OverlayScreen extends React.Component {
2828
<Button label='Alert' testID={ALERT_BUTTON} onPress={() => alert('Alert displayed')} />
2929
<Button label='Show overlay' testID={SHOW_OVERLAY_BTN} onPress={() => this.showOverlay(true)} />
3030
<Button label='Show touch through overlay' testID={SHOW_TOUCH_THROUGH_OVERLAY_BTN} onPress={() => this.showOverlay(false)} />
31+
<Button label='Show overlay with ScrollView' onPress={this.showOverlayWithScrollView} />
3132
<Button label='Set Root' testID={SET_ROOT_BTN} onPress={this.setRoot} />
3233
</Root>
3334
);
@@ -40,20 +41,9 @@ class OverlayScreen extends React.Component {
4041

4142
setRoot = () => Navigation.setRoot({ root: component(Screens.Pushed) })
4243

43-
// await Navigation.showOverlay({
44-
// component: {
45-
// name: 'navigation.playground.CustomDialog',
46-
// options: {
47-
// layout: {
48-
// componentBackgroundColor: 'transparent'
49-
// },
50-
// overlay: {
51-
// interceptTouchOutside: false
52-
// }
53-
// }
54-
// }
55-
// });
56-
// });
44+
showOverlayWithScrollView = () => Navigation.showOverlay(Screens.ScrollViewOverlay, {
45+
layout: { componentBackgroundColor: 'transparent' }
46+
});
5747
}
5848

5949
module.exports = OverlayScreen;

playground/src/screens/Screens.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
Modal: 'Modal',
88
Overlay: 'Overlay',
99
OverlayAlert: 'OverlayAlert',
10+
ScrollViewOverlay: 'ScrollViewOverlay',
1011
Lifecycle: 'Lifecycle',
1112
BackHandler: 'BackHandler',
1213
BottomTabs: 'BottomTabs',
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const React = require('react');
2+
const { PureComponent } = require('react');
3+
const { View, Text, ScrollView, StyleSheet } = require('react-native');
4+
5+
const colors = [
6+
'#3182C8',
7+
'#00AAAF',
8+
'#00A65F',
9+
'#E2902B',
10+
'#D9644A',
11+
'#CF262F',
12+
'#8B1079',
13+
'#48217B'
14+
];
15+
16+
class ScrollViewOverlay extends PureComponent {
17+
18+
render() {
19+
return (
20+
<View style={styles.root}>
21+
<View style={{ height: 200, width: '80%', alignSelf: 'center', flexDirection: 'row' }}>
22+
<ScrollView style={styles.scrollView} contentContainerStyle={styles.content}>
23+
{colors.map(this.renderRow)}
24+
</ScrollView>
25+
</View>
26+
</View>
27+
);
28+
}
29+
30+
renderRow = (color) => <Text key={color} style={[styles.row, { backgroundColor: color }]}>{color}</Text>
31+
}
32+
33+
const styles = StyleSheet.create({
34+
scrollView: {
35+
backgroundColor: 'blue'
36+
},
37+
root: {
38+
flex: 1,
39+
flexDirection: 'column',
40+
justifyContent: 'flex-end'
41+
},
42+
row: {
43+
height: 40,
44+
textAlign: 'center',
45+
textAlignVertical: 'center',
46+
color: 'white',
47+
},
48+
content: {
49+
backgroundColor: 'blue'
50+
},
51+
h1: {
52+
fontSize: 24,
53+
textAlign: 'center',
54+
margin: 10
55+
},
56+
h2: {
57+
fontSize: 12,
58+
textAlign: 'center',
59+
margin: 10
60+
},
61+
footer: {
62+
fontSize: 10,
63+
color: '#888',
64+
marginTop: 10
65+
}
66+
});
67+
68+
module.exports = ScrollViewOverlay;

playground/src/screens/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function registerScreens() {
2525
Navigation.registerComponent(Screens.Lifecycle, () => require('./LifecycleScreen'));
2626
Navigation.registerComponent(Screens.Overlay, () => require('./OverlayScreen'));
2727
Navigation.registerComponent(Screens.OverlayAlert, () => require('./OverlayAlert'));
28+
Navigation.registerComponent(Screens.ScrollViewOverlay, () => require('./ScrollViewOverlay'));
2829
Navigation.registerComponent(Screens.RoundButton, () => require('./RoundedButton'));
2930
Navigation.registerComponent(Screens.ReactTitleView, () => require('./CustomTopBar'));
3031
Navigation.registerComponent(Screens.EventsScreen, () => require('./StaticEventsScreen'));

0 commit comments

Comments
 (0)