Skip to content

Commit 26a2b0e

Browse files
committed
revert removing parts of combo example
1 parent 098739d commit 26a2b0e

2 files changed

Lines changed: 73 additions & 3 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { View, Text, StyleSheet } from 'react-native';
2+
import {
3+
BorderlessButton,
4+
BorderlessButtonProps,
5+
} from 'react-native-gesture-handler';
6+
7+
export const InfoButton = (props: BorderlessButtonProps & { name: string }) => (
8+
<BorderlessButton
9+
{...props}
10+
style={styles.infoButton}
11+
// eslint-disable-next-line no-alert
12+
onPress={() => window.alert(`${props.name} info button clicked`)}>
13+
<View style={styles.infoButtonBorders}>
14+
<Text style={styles.infoButtonText}>i</Text>
15+
</View>
16+
</BorderlessButton>
17+
);
18+
19+
const styles = StyleSheet.create({
20+
infoButton: {
21+
width: 40,
22+
height: 40,
23+
},
24+
infoButtonBorders: {
25+
borderColor: '#467AFB',
26+
borderWidth: 2,
27+
width: 20,
28+
height: 20,
29+
alignItems: 'center',
30+
justifyContent: 'center',
31+
borderRadius: 10,
32+
margin: 10,
33+
},
34+
infoButtonText: {
35+
color: '#467AFB',
36+
fontWeight: 'bold',
37+
backgroundColor: 'transparent',
38+
},
39+
});

apps/common-app/src/release_tests/combo/index.tsx

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
View,
88
Alert,
99
TouchableHighlightProps as RNTouchableHighlightProps,
10-
Button,
1110
} from 'react-native';
1211

1312
import {
@@ -29,6 +28,7 @@ import { PinchableBox } from '../../recipes/scaleAndRotate';
2928
import { PressBox } from '../../basic/multitap';
3029

3130
import { LoremIpsum } from '../../common';
31+
import { InfoButton } from './InfoButton';
3232

3333
const WrappedSlider = createNativeWrapper(Slider, {
3434
shouldCancelWhenOutside: false,
@@ -172,14 +172,41 @@ class Combo extends Component<ComboProps> {
172172
<RectButton
173173
style={styles.rectButton}
174174
onPress={() => Alert.alert('First row clicked')}>
175-
<Button title="first" />
175+
<Text style={styles.buttonText}>
176+
Swipe this row & observe highlight delay
177+
</Text>
178+
{/* Info icon will cancel when you scroll in the direction of the scrollview
179+
but if you move finger horizontally it would allow you to "re-enter" into
180+
an active state. This is typical for most of the buttons on iOS (but not
181+
on Android where the touch cancels as soon as you leave the area of the
182+
button). */}
183+
<InfoButton name="first" />
176184
</RectButton>
177185
</Swipeable>
178186
<View style={styles.buttonDelimiter} />
179187
<RectButton
180188
style={styles.rectButton}
181189
onPress={() => Alert.alert('Second row clicked')}>
182-
<Button title="second" />
190+
<Text style={styles.buttonText}>
191+
Second info icon will block scrolling
192+
</Text>
193+
{/* Info icon will block interaction with other gesture handlers including
194+
the scrollview handler its a descendant of. This is typical for buttons
195+
embedded in a scrollable content on iOS. */}
196+
<InfoButton disallowInterruption name="second" />
197+
</RectButton>
198+
<View style={styles.buttonDelimiter} />
199+
<RectButton
200+
style={styles.rectButton}
201+
onPress={() => Alert.alert('Third row clicked')}>
202+
<Text style={styles.buttonText}>
203+
This one will cancel when you drag outside
204+
</Text>
205+
{/* Info icon will cancel when you drag your finger outside of its bounds and
206+
then back unlike all the previous icons that would activate when you re-enter
207+
their activation area. This is a typical bahaviour for android but less frequent
208+
for most of the iOS native apps. */}
209+
<InfoButton shouldCancelWhenOutside name="third" />
183210
</RectButton>
184211
</View>
185212
<LoremIpsum />
@@ -219,6 +246,10 @@ const styles = StyleSheet.create({
219246
marginRight: 20,
220247
backgroundColor: '#999',
221248
},
249+
buttonText: {
250+
fontWeight: 'bold',
251+
backgroundColor: 'transparent',
252+
},
222253
slider: {
223254
margin: 10,
224255
flex: 1,

0 commit comments

Comments
 (0)