-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathApp.js
More file actions
90 lines (86 loc) · 2.14 KB
/
Copy pathApp.js
File metadata and controls
90 lines (86 loc) · 2.14 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
import React, { Component } from 'react';
import {
Button,
StyleSheet,
Text,
TextInput,
View
} from 'react-native';
import { Popover, PopoverContainer } from 'react-native-simple-popover';
export default class App extends Component {
state = {
isPopoverVisible: true,
popoverPlacement: 'top',
};
render() {
return (
<PopoverContainer padding={20}>
<View style={styles.container}>
<Popover
placement={this.state.popoverPlacement}
arrowColor="#114B5F"
arrowWidth={16}
arrowHeight={8}
isVisible={this.state.isPopoverVisible}
component={() => (
<View style={styles.popoverContainer}>
<Text style={styles.popoverText}>
This is a very long popover text.
Container padding affects max width and height of this popover.
</Text>
</View>
)}
>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
</Popover>
<View style={styles.buttons}>
<Button
title="Toggle Popover"
onPress={() => {
this.setState({ isPopoverVisible: !this.state.isPopoverVisible });
}}
/>
<Button
title="Toggle Placement"
onPress={() => {
this.setState({ popoverPlacement: this.state.popoverPlacement === 'top' ? 'bottom': 'top' });
}}
/>
</View>
</View>
</PopoverContainer>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
buttons: {
position: 'absolute',
flexDirection: 'row',
width: '100%',
top: 0,
left: 0,
marginTop: 20,
justifyContent: 'space-around',
},
popoverContainer: {
backgroundColor: '#114B5F',
padding: 8,
borderRadius: 5,
},
popoverText: {
color: '#E4FDE1',
}
});