Compare commits

...

3 Commits

Author SHA1 Message Date
Marcos Rodriguez Vélez
d369e7ece0
Create ToolTipMenu.podspec 2020-06-13 12:36:26 -04:00
Marcos Rodriguez Vélez
6c6b4f64ca
Update ToolTip.ios.js 2020-06-13 12:28:57 -04:00
Eli Perkins
13c6b86560 Add support for UIMenuControllerArrowDefault (#38)
* Add support for UIMenuControllerArrowDefault
2018-03-15 16:49:08 -04:00
4 changed files with 35 additions and 12 deletions

View File

@ -17,7 +17,7 @@ A react-native component from displaying tooltip. Uses UIMenuController.
- `actions`: Array of actions `[{text: 'Copy', onPress: () => Clipboard.set(this.someValue) }]`
- `longPress`: Boolean indicating if the tooltip should be showing on longPress, false by default.
- `arrowDirection`: String indicating the direction of the tooltip arrow. Possible values are: `up`, `down`, `left`, and `right`. Default is `down`.
- `arrowDirection`: String indicating the direction of the tooltip arrow. Possible values are: `up`, `down`, `left`, `right`, and `default`. Default is `default`, which means to point up or down at the object of focus based on its location on the screen.
#### Props from TouchableHighlight.propTypes

View File

@ -19,7 +19,7 @@ export default class ToolTip extends PureComponent {
text: PropTypes.string.isRequired,
onPress: PropTypes.func
})),
arrowDirection: PropTypes.oneOf(['up', 'down', 'left', 'right']),
arrowDirection: PropTypes.oneOf(['up', 'down', 'left', 'right', 'default']),
longPress: PropTypes.bool,
onHide: PropTypes.func,
onShow: PropTypes.func,
@ -27,7 +27,7 @@ export default class ToolTip extends PureComponent {
};
static defaultProps = {
arrowDirection: 'down',
arrowDirection: 'default',
onHide: () => true,
onShow: () => true
};
@ -60,13 +60,13 @@ export default class ToolTip extends PureComponent {
getTouchableHighlightProps = () => {
const props = {};
Object.keys(TouchableHighlight.propTypes).forEach((key) => props[key] = this.props[key]);
// Object.keys(TouchableHighlight.propTypes).forEach((key) => props[key] = this.props[key]);
if (this.props.longPress) {
props.onLongPress = this.showMenu;
} else {
props.onPress = this.showMenu;
}
// if (this.props.longPress) {
// props.onLongPress = this.showMenu;
// } else {
// props.onPress = this.showMenu;
// }
return props;
};

21
ToolTipMenu.podspec Normal file
View File

@ -0,0 +1,21 @@
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
Pod::Spec.new do |s|
s.name = "ToolTipMenu"
s.version = package['version']
s.summary = package['description']
s.license = package['license']
s.authors = package['author']
s.homepage = package['repository']['url']
s.platform = :ios, "7.0"
s.ios.deployment_target = '7.0'
s.source = { :git => "https://github.com/BlueWallet/react-native-tooltip.git", :tag => "#{s.version}" }
s.preserve_paths = '*'
s.source_files = "ToolTipMenu/*.{h,m}"
s.dependency 'React'
end

View File

@ -35,12 +35,14 @@ RCT_EXPORT_METHOD(show:(nonnull NSNumber *)reactTag
if([arrowDirection isEqualToString: @"up"]){
menuCont.arrowDirection = UIMenuControllerArrowUp;
}else if ([arrowDirection isEqualToString: @"right"]){
} else if ([arrowDirection isEqualToString: @"right"]){
menuCont.arrowDirection = UIMenuControllerArrowRight;
}else if ([arrowDirection isEqualToString: @"left"]) {
} else if ([arrowDirection isEqualToString: @"left"]) {
menuCont.arrowDirection = UIMenuControllerArrowLeft;
} else {
} else if ([arrowDirection isEqualToString: @"down"]) {
menuCont.arrowDirection = UIMenuControllerArrowDown;
} else {
menuCont.arrowDirection = UIMenuControllerArrowDefault;
}
menuCont.menuItems = menuItems;
[menuCont setMenuVisible:YES animated:YES];