-
Notifications
You must be signed in to change notification settings - Fork 247
/
StylingExample.js
131 lines (119 loc) · 2.79 KB
/
StylingExample.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
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
import React, { Component } from 'react';
import { Text, StyleSheet } from 'react-native';
import Menu, {
MenuProvider,
MenuOptions,
MenuOption,
MenuTrigger,
renderers,
} from 'react-native-popup-menu';
const { ContextMenu, SlideInMenu, Popover } = renderers;
class BasicExampleComponent extends Component {
constructor(props, ctx) {
super(props, ctx);
this.state = { renderer: ContextMenu };
}
render() {
return (
<Menu
renderer={this.state.renderer}
rendererProps={{ anchorStyle: styles.anchorStyle }}
style={{ height: 50 }}
>
<MenuTrigger text='Select option' customStyles={triggerStyles} />
<MenuOptions customStyles={optionsStyles}>
<MenuOption text='Context Menu'
onSelect={() => this.setState({renderer: ContextMenu})}/>
<MenuOption text='Slide-in Menu'
onSelect={() => this.setState({renderer: SlideInMenu})}/>
<MenuOption text='Popover'
onSelect={() => this.setState({renderer: Popover})}/>
<MenuOption text='Three (custom)' customStyles={optionStyles}
onSelect={() => alert('Selected custom styled option')} />
<MenuOption disabled={true}>
<Text style={{color: '#ccc'}}>Four (disabled)</Text>
</MenuOption>
</MenuOptions>
</Menu>
);
}
}
const BasicExample = () => (
<MenuProvider customStyles={menuProviderStyles}>
<BasicExampleComponent />
</MenuProvider>
)
export default BasicExample
const triggerStyles = {
triggerText: {
color: 'white',
},
triggerOuterWrapper: {
backgroundColor: 'orange',
padding: 5,
flex: 1,
},
triggerWrapper: {
backgroundColor: 'blue',
alignItems: 'center',
justifyContent: 'center',
flex: 1,
},
triggerTouchable: {
underlayColor: 'darkblue',
activeOpacity: 70,
style : {
flex: 1,
},
},
};
const optionsStyles = {
optionsContainer: {
backgroundColor: 'green',
padding: 5,
},
optionsWrapper: {
backgroundColor: 'purple',
},
optionWrapper: {
backgroundColor: 'yellow',
margin: 5,
},
optionTouchable: {
underlayColor: 'gold',
activeOpacity: 70,
},
optionText: {
color: 'brown',
},
};
const optionStyles = {
optionTouchable: {
underlayColor: 'red',
activeOpacity: 40,
},
optionWrapper: {
backgroundColor: 'pink',
margin: 5,
},
optionText: {
color: 'black',
},
};
const styles = StyleSheet.create({
container: {
flexDirection: 'column',
padding: 30,
},
backdrop: {
backgroundColor: 'red',
opacity: 0.5,
},
anchorStyle: {
backgroundColor: 'blue',
},
});
const menuProviderStyles = {
menuProviderWrapper: styles.container,
backdrop: styles.backdrop,
};