-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathindex.tsx
More file actions
158 lines (142 loc) · 4.04 KB
/
index.tsx
File metadata and controls
158 lines (142 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import React from 'react';
import { StyleSheet, Text, View, ScrollView } from 'react-native';
import {
GestureHandlerRootView,
Clickable,
ClickableProps,
} from 'react-native-gesture-handler';
import { COLORS } from '../../../common';
type ButtonWrapperProps = ClickableProps & {
name: string;
color: string;
};
function ClickableWrapper({ name, color, ...rest }: ButtonWrapperProps) {
return (
<Clickable
style={[styles.button, { backgroundColor: color }]}
onPressIn={() => console.log(`[${name}] onPressIn`)}
onPress={() => console.log(`[${name}] onPress`)}
onLongPress={() => console.log(`[${name}] onLongPress`)}
onPressOut={() => console.log(`[${name}] onPressOut`)}
{...rest}>
<Text style={styles.buttonText}>{name}</Text>
</Clickable>
);
}
export default function ClickableExample() {
return (
<GestureHandlerRootView style={styles.container}>
<ScrollView contentContainerStyle={styles.scrollContent}>
<View style={styles.section}>
<Text style={styles.sectionHeader}>Buttons replacements</Text>
<Text>New component that replaces all buttons and pressables.</Text>
<View style={styles.row}>
<ClickableWrapper name="Base" color={COLORS.DARK_PURPLE} />
<ClickableWrapper
name="Rect"
color={COLORS.WEB_BLUE}
activeUnderlayOpacity={0.105}
/>
<ClickableWrapper
name="Borderless"
activeOpacity={0.3}
color={COLORS.RED}
/>
</View>
</View>
<View style={styles.section}>
<Text style={styles.sectionHeader}>Custom animations</Text>
<Text>Animated underlay.</Text>
<View style={styles.row}>
<ClickableWrapper
name="Click me!"
color={COLORS.YELLOW}
activeUnderlayOpacity={0.3}
/>
<ClickableWrapper
name="Click me!"
color={COLORS.NAVY}
defaultUnderlayOpacity={0.7}
activeUnderlayOpacity={0.5}
underlayColor={COLORS.DARK_GREEN}
/>
</View>
<Text>Animated component.</Text>
<View style={styles.row}>
<ClickableWrapper
name="Click me!"
color={COLORS.LIGHT_BLUE}
defaultOpacity={0.3}
activeOpacity={0.7}
/>
<ClickableWrapper
name="Click me!"
color={COLORS.DARK_SALMON}
defaultOpacity={0.7}
activeOpacity={0.5}
/>
</View>
</View>
<View style={styles.section}>
<Text style={styles.sectionHeader}>Android ripple</Text>
<Text>Configurable ripple effect on Clickable component.</Text>
<View style={styles.row}>
<ClickableWrapper
name="Default"
color={COLORS.ANDROID}
androidRipple={{}}
/>
<ClickableWrapper
name="Borderless"
color={COLORS.ANDROID}
androidRipple={{
color: COLORS.KINDA_BLUE,
borderless: true,
radius: 55,
}}
/>
</View>
</View>
</ScrollView>
</GestureHandlerRootView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
scrollContent: {
paddingBottom: 40,
},
section: {
padding: 20,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: '#ccc',
alignItems: 'center',
},
row: {
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
gap: 10,
marginTop: 20,
marginBottom: 20,
},
sectionHeader: {
fontSize: 16,
fontWeight: 'bold',
marginBottom: 4,
},
button: {
width: 110,
height: 50,
borderRadius: 12,
alignItems: 'center',
justifyContent: 'center',
},
buttonText: {
color: 'white',
fontSize: 14,
fontWeight: '600',
},
});