forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFABExample.tsx
98 lines (88 loc) · 2.32 KB
/
FABExample.tsx
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
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Colors, FAB, Portal, useTheme } from 'react-native-paper';
const ButtonExample = () => {
const [visible, setVisible] = React.useState<boolean>(true);
const [open, setOpen] = React.useState<boolean>(false);
const {
colors: { background },
} = useTheme();
return (
<View style={[styles.container, { backgroundColor: background }]}>
<View style={styles.row}>
<FAB
small
icon={visible ? 'eye-off' : 'eye'}
style={styles.fab}
onPress={() => setVisible(!visible)}
/>
</View>
<View style={styles.row}>
<FAB
icon="heart"
style={styles.fab}
onPress={() => {}}
visible={visible}
/>
<FAB
icon="check"
label="Extended FAB"
style={styles.fab}
onPress={() => {}}
visible={visible}
/>
<FAB
icon="cancel"
label="Disabled FAB"
style={styles.fab}
onPress={() => {}}
visible={visible}
disabled
/>
<FAB
icon="cancel"
label="Loading FAB"
style={styles.fab}
onPress={() => {}}
visible={visible}
loading
/>
<Portal>
<FAB.Group
open={open}
icon={open ? 'calendar-today' : 'plus'}
actions={[
{ icon: 'plus', onPress: () => {} },
{ icon: 'star', label: 'Star', onPress: () => {} },
{ icon: 'email', label: 'Email', onPress: () => {} },
{ icon: 'bell', label: 'Remind', onPress: () => {} },
]}
onStateChange={({ open }: { open: boolean }) => setOpen(open)}
onPress={() => {
if (open) {
// do something if the speed dial is open
}
}}
visible={visible}
/>
</Portal>
</View>
</View>
);
};
ButtonExample.title = 'Floating Action Button';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.grey200,
padding: 4,
},
row: {
justifyContent: 'center',
alignItems: 'center',
},
fab: {
margin: 8,
},
});
export default ButtonExample;