forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFABExample.js
89 lines (78 loc) · 2.06 KB
/
FABExample.js
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
/* @flow */
import * as React from 'react';
import { View, StyleSheet } from 'react-native';
import { Colors, FAB, Portal, withTheme, type Theme } from 'react-native-paper';
type Props = {
theme: Theme,
};
type State = {
open: boolean,
};
class ButtonExample extends React.Component<Props, State> {
static title = 'Floating Action Button';
state = {
open: false,
};
render() {
const {
theme: {
colors: { background },
},
} = this.props;
return (
<View style={[styles.container, { backgroundColor: background }]}>
<View style={styles.row}>
<FAB small icon="add" style={styles.fab} onPress={() => {}} />
<FAB icon="favorite" style={styles.fab} onPress={() => {}} />
<FAB
icon="done"
label="Extended FAB"
style={styles.fab}
onPress={() => {}}
/>
<FAB
icon="cancel"
label="Disabled FAB"
style={styles.fab}
onPress={() => {}}
disabled
/>
<Portal>
<FAB.Group
open={this.state.open}
icon={this.state.open ? 'today' : 'add'}
actions={[
{ icon: 'add', onPress: () => {} },
{ icon: 'star', label: 'Star', onPress: () => {} },
{ icon: 'email', label: 'Email', onPress: () => {} },
{ icon: 'notifications', label: 'Remind', onPress: () => {} },
]}
onStateChange={({ open }) => this.setState({ open })}
onPress={() => {
if (this.state.open) {
// do something if the speed dial is open
}
}}
/>
</Portal>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: Colors.grey200,
padding: 4,
},
row: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
fab: {
margin: 8,
},
});
export default withTheme(ButtonExample);