Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update entry file & README to fix deprecations #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A react-native component from displaying tooltip. Uses UIMenuController.
Files to "Your Project Name"` [(Screenshot)](http://url.brentvatne.ca/jQp8) then [(Screenshot)](http://url.brentvatne.ca/1gqUD).
3. Add `libRNToolTipMenu.a` to `Build Phases -> Link Binary With Libraries`
[(Screenshot)](http://url.brentvatne.ca/17Xfe).
4. Whenever you want to use it within React code: `var ToolTip = require('react-native-tooltip');`
4. Whenever you want to use it within React code: `import ToolTip from 'react-native-tooltip';`

## Usage

Expand All @@ -32,24 +32,26 @@ You can see the list on the react native [website](https://facebook.github.io/re
### Example

```javascript
var React = require('react-native');
var {
import React from 'react';
import {
AppRegistry,
StyleSheet,
PixelRatio,
View,
Text,
} = React;
} from 'react-native';

var ToolTip = require('react-native-tooltip');
import ToolTip from 'react-native-tooltip';

var tooltip = React.createClass({
getInitialState: function() {
return {
class tooltip extends React.Component {
constructor() {
super();

this.state = {
input: 'chirag',
}
},
render: function() {
};
}
render() {
return (
<View style={styles.container}>
<View style={styles.textinputContainer}>
Expand All @@ -72,7 +74,7 @@ var tooltip = React.createClass({
</View>
);
}
});
}

var styles = StyleSheet.create({
container: {
Expand Down
8 changes: 4 additions & 4 deletions ToolTip.android.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

var warning = require('warning');
const warning = require('warning');

var ToolTip = {
test: function() {
const ToolTip = {
test() {
warning("Not yet implemented for Android.");
}
},
};

module.exports = ToolTip;
64 changes: 32 additions & 32 deletions ToolTip.ios.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
'use strict';

var {
const {
requireNativeComponent,
TouchableHighlight,
View,
NativeModules,
findNodeHandle,
} = require('react-native');
var React = require('react');
var ToolTipMenu = NativeModules.ToolTipMenu;
var RCTToolTipText = requireNativeComponent('RCTToolTipText', null);

var propTypes = {
actions: React.PropTypes.arrayOf(React.PropTypes.shape({
text: React.PropTypes.string.isRequired,
onPress: React.PropTypes.func,
const PropTypes = require('prop-types');
const React = require('react');
const ToolTipMenu = NativeModules.ToolTipMenu;
const RCTToolTipText = requireNativeComponent('RCTToolTipText', null);

const propTypes = {
actions: PropTypes.arrayOf(PropTypes.shape({
text: PropTypes.string.isRequired,
onPress: PropTypes.func,
})),
arrowDirection: React.PropTypes.oneOf(['up', 'down', 'left', 'right']),
longPress: React.PropTypes.bool,
arrowDirection: PropTypes.oneOf(['up', 'down', 'left', 'right']),
longPress: PropTypes.bool,
...TouchableHighlight.propTypes,
};

var ViewClass = React.createClass({
getDefaultProps: function() {
return {
arrowDirection: 'down'
};
},
class ViewClass extends React.Component {
static defaultProps = {
arrowDirection: 'down'
};

showMenu: function() {
showMenu = () => {
ToolTipMenu.show(findNodeHandle(this.refs.toolTipText), this.getOptionTexts(), this.props.arrowDirection);
},
hideMenu: function() {
};

hideMenu = () => {
ToolTipMenu.hide();
},
getOptionTexts: function() {
};

getOptionTexts = () => {
return this.props.actions.map((option) => option.text);
},
};

// Assuming there is no actions with the same text
getCallback: function(optionText) {
getCallback = (optionText) => {
var selectedOption = this.props.actions.find((option) => option.text === optionText);

if (selectedOption) {
return selectedOption.onPress;
}

return null;
},
};

getTouchableHighlightProps: function() {
getTouchableHighlightProps = () => {
var props = {};

Object.keys(TouchableHighlight.propTypes).forEach((key) => props[key] = this.props[key]);
Expand All @@ -62,17 +62,17 @@ var ViewClass = React.createClass({
}

return props;
},
};

handleToolTipTextChange: function(event) {
handleToolTipTextChange = (event) => {
var callback = this.getCallback(event.nativeEvent.text);

if (callback) {
callback(event);
}
},
};

render: function() {
render() {
return (
<RCTToolTipText ref='toolTipText' onChange={this.handleToolTipTextChange}>
<TouchableHighlight
Expand All @@ -85,7 +85,7 @@ var ViewClass = React.createClass({
</RCTToolTipText>
);
}
});
}

ViewClass.propTypes = propTypes;

Expand Down
129 changes: 129 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@
"react-component",
"ios",
"tooltip"
]
],
"dependencies": {
"create-react-class": "^15.6.2",
"prop-types": "^15.6.0"
}
}