Skip to content

Commit 734c429

Browse files
committed
add flex styling example
1 parent 4ce89e3 commit 734c429

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react';
2+
import { Pressable as LegacyPressable, StyleSheet, View } from 'react-native';
3+
import {
4+
Pressable as GesturizedPressable,
5+
ScrollView,
6+
} from 'react-native-gesture-handler';
7+
import { LoremIpsum } from '../../common';
8+
9+
export default function FlexExample() {
10+
return (
11+
<ScrollView>
12+
<View style={styles.container}>
13+
<GesturizedNesting />
14+
<LegacyNesting />
15+
</View>
16+
<LoremIpsum words={40} />
17+
</ScrollView>
18+
);
19+
}
20+
21+
function GesturizedNesting() {
22+
return (
23+
<GesturizedPressable style={styles.outer}>
24+
<GesturizedPressable style={styles.inner} />
25+
</GesturizedPressable>
26+
);
27+
}
28+
29+
function LegacyNesting() {
30+
return (
31+
<LegacyPressable style={styles.outer}>
32+
<LegacyPressable style={styles.inner} />
33+
</LegacyPressable>
34+
);
35+
}
36+
37+
const styles = StyleSheet.create({
38+
text: {
39+
padding: 10,
40+
},
41+
container: {
42+
flex: 1,
43+
flexDirection: 'row',
44+
justifyContent: 'center',
45+
gap: 50,
46+
},
47+
inner: {
48+
backgroundColor: 'green',
49+
width: 50,
50+
height: 50,
51+
},
52+
outer: {
53+
backgroundColor: 'red',
54+
width: 150,
55+
height: 150,
56+
57+
alignItems: 'center',
58+
justifyContent: 'center',
59+
},
60+
});

example/src/release_tests/gesturizedPressable/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { RippleExample } from './androidRippleExample';
88
import { FunctionalStyleExample } from './functionalStylesExample';
99
import { DelayedPressExample } from './delayedPressExample';
1010
import { DelayHoverExample } from './hoverDelayExample';
11+
import FlexExample from './flexStyling';
1112

1213
type TestingEntryProps = {
1314
title: string;
@@ -64,6 +65,9 @@ export default function Example() {
6465
platform="web">
6566
<DelayHoverExample />
6667
</TestingEntry>
68+
<TestingEntry title="Flex behaviour of nested pressables">
69+
<FlexExample />
70+
</TestingEntry>
6771
</ScrollView>
6872
);
6973
}

0 commit comments

Comments
 (0)