Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit d50a4ed

Browse files
committed
android init
1 parent ad9e19f commit d50a4ed

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

Example/index.android.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
* @flow
5+
*/
6+
7+
import React, { Component } from 'react';
8+
import {
9+
AppRegistry,
10+
Text,
11+
View
12+
} from 'react-native';
13+
14+
import ReactNativeTooltipMenu from 'react-native-tooltip-menu';
15+
16+
class Example extends Component {
17+
state = {
18+
counter: 0,
19+
};
20+
21+
render() {
22+
return (
23+
<View style={{ flex: 1, flexDirection: 'column', justifyContent: 'center', padding: 25 }}>
24+
<View>
25+
<Text style={{ textAlign: 'center' }}>This is example of react-native-tooltip-menu</Text>
26+
<Text style={{ textAlign: 'center' }}>Clicked: {this.state.counter}</Text>
27+
</View>
28+
<ReactNativeTooltipMenu
29+
buttonComponent={
30+
<View
31+
style={{
32+
backgroundColor: 'purple',
33+
padding: 10,
34+
borderRadius: 25
35+
}}
36+
>
37+
<Text style={{ color: 'white', flex: 1 }}>Click me to show tooltip!</Text>
38+
</View>
39+
}
40+
items={[
41+
{
42+
label: 'Label #1',
43+
onPress: () => this.setState({ counter: (this.state.counter + 1) })
44+
},
45+
{
46+
label: 'Label #2',
47+
onPress: () => this.setState({ counter: (this.state.counter + 1) }),
48+
},
49+
]}
50+
/>
51+
</View>
52+
)
53+
}
54+
}
55+
56+
AppRegistry.registerComponent('Example', () => Example);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-tooltip-menu",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "ReactNative component showing tooltip with menu items.",
55
"main": "src/index.js",
66
"scripts": {

src/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Tooltip extends React.Component {
9191
labelContainerStyle,
9292
labelStyle,
9393
} = this.props;
94-
const { isModalOpen } = this.state;
94+
const { isModalOpen, onRequestClose } = this.state;
9595
const widthStyle = mapWight(widthType);
9696

9797
return (
@@ -104,7 +104,11 @@ class Tooltip extends React.Component {
104104
{buttonComponent}
105105
</TouchableOpacity>
106106
</View>
107-
<Modal visible={isModalOpen} transparent>
107+
<Modal
108+
visible={isModalOpen}
109+
transparent
110+
onRequestClose={onRequestClose}
111+
>
108112
<View style={[styles.overlay, overlayStyle]}>
109113
<TouchableOpacity activeOpacity={1} focusedOpacity={1} style={{ flex: 1 }} onPress={isModalOpen ? this.hideModal : this.openModal}>
110114
<View style={[styles.component]}>
@@ -167,10 +171,12 @@ Tooltip.propTypes = {
167171
'half',
168172
'full',
169173
]),
174+
onRequestClose: React.PropTypes.func,
170175
};
171176

172177
Tooltip.defaultProps = {
173178
widthType: 'half',
179+
onRequestClose: () => {},
174180
};
175181

176182
export default Tooltip;

0 commit comments

Comments
 (0)