Skip to content

Commit

Permalink
- hot fix for dismiss
Browse files Browse the repository at this point in the history
  • Loading branch information
prscms committed Sep 8, 2018
1 parent 5a5f995 commit 25a81ca
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 57 deletions.
17 changes: 12 additions & 5 deletions Example/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@ export default class App extends Component<Props> {

this.state = {
visible: false,
dismiss: false,
reference: undefined
}
}

_onPress (ref) {
this.setState({ visible: true, dismiss: false, reference: ref });
this.setState({ visible: true, reference: ref });

// setTimeout(() => {
// this.setState({ dismiss: true })
// this.setState({ visible: false })
// }, 1000)

// Tooltips.Show(ref, {
// text: "Long Press Description"
// })

// setTimeout(() => {
// Tooltips.Dismiss(ref)
// }, 1000);
}

render() {
Expand All @@ -51,9 +58,9 @@ export default class App extends Component<Props> {
<Bottom style={styles.bottom} onPress={ref => {
this._onPress(ref);
}} />
<Tooltips text={"Long Press Description"} visible={this.state.visible} dismiss={this.state.dismiss} reference={this.state.reference} autoHide={true} onHide={() => {
<Tooltips text={"Long Press Description"} visible={this.state.visible} reference={this.state.reference} autoHide={true} onHide={() => {
console.log("On Hide");
}} />
}} clickToHide={false} />
</View>;
}
}
Expand Down
86 changes: 51 additions & 35 deletions RNTooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class Tooltips extends PureComponent {
autoHide: PropTypes.bool,
duration: PropTypes.number,
clickToHide: PropTypes.bool,
dismiss: PropTypes.bool,
corner: PropTypes.number,
tintColor: PropTypes.string,
textColor: PropTypes.string,
Expand All @@ -56,7 +55,6 @@ class Tooltips extends PureComponent {
position: 4,
align: 2,
autoHide: true,
dismiss: false,
duration: Platform.OS === "android" ? 4000 : 4,
clickToHide: false,
corner: Platform.OS === "android" ? 30 : 0,
Expand All @@ -69,31 +67,47 @@ class Tooltips extends PureComponent {
};

static Show(ref, props) {
if (typeof ref !== 'number') {
ref = findNodeHandle(ref);
}

if (props.text === undefined) {
props.text = Tooltips.defaultProps.text;
} else if (props.position === undefined) {
}
if (props.position === undefined) {
props.position = Tooltips.defaultProps.position;
} else if (props.align === undefined) {
}
if (props.align === undefined) {
props.align = Tooltips.defaultProps.align;
} else if (props.autoHide === undefined) {
}
if (props.autoHide === undefined) {
props.autoHide = Tooltips.defaultProps.autoHide;
} else if (props.duration === undefined) {
}
if (props.duration === undefined) {
props.duration = Tooltips.defaultProps.duration;
} else if (props.clickToHide === undefined) {
}
if (props.clickToHide === undefined) {
props.clickToHide = Tooltips.defaultProps.clickToHide;
} else if (props.corner === undefined) {
}
if (props.corner === undefined) {
props.corner = Tooltips.defaultProps.corner;
} else if (props.tintColor === undefined) {
}
if (props.tintColor === undefined) {
props.tintColor = Tooltips.defaultProps.tintColor;
} else if (props.textColor === undefined) {
}
if (props.textColor === undefined) {
props.textColor = Tooltips.defaultProps.textColor;
} else if (props.textSize === undefined) {
}
if (props.textSize === undefined) {
props.textSize = Tooltips.defaultProps.textSize;
} else if (props.gravity === undefined) {
}
if (props.gravity === undefined) {
props.gravity = Tooltips.defaultProps.gravity;
} else if (props.shadow === undefined) {
}
if (props.shadow === undefined) {
props.shadow = Tooltips.defaultProps.shadow;
} else if (props.arrow === undefined) {
}
if (props.arrow === undefined) {
props.arrow = Tooltips.defaultProps.arrow
}

Expand All @@ -107,31 +121,33 @@ class Tooltips extends PureComponent {
}

static Dismiss(ref) {
if (typeof ref !== "number") {
ref = findNodeHandle(ref);
}

RNTooltips.Dismiss(ref);
}

componentDidUpdate() {
if (this.props.visible && this.props.reference) {
if (this.props.dismiss) {
Tooltips.Dismiss(findNodeHandle(this.props.reference))
} else {
Tooltips.Show(findNodeHandle(this.props.reference), {
text: this.props.text,
position: this.props.position,
align: this.props.align,
autoHide: this.props.autoHide,
duration: this.props.duration,
clickToHide: this.props.clickToHide,
corner: this.props.corner,
tintColor: this.props.tintColor,
textColor: this.props.textColor,
textSize: this.props.textSize,
arrow: this.props.arrow,
gravity: this.props.gravity,
shadow: this.props.shadow,
onHide: this.props.onHide
});
}
if (this.props.visible === true && this.props.reference) {
Tooltips.Show(findNodeHandle(this.props.reference), {
text: this.props.text,
position: this.props.position,
align: this.props.align,
autoHide: this.props.autoHide,
duration: this.props.duration,
clickToHide: this.props.clickToHide,
corner: this.props.corner,
tintColor: this.props.tintColor,
textColor: this.props.textColor,
textSize: this.props.textSize,
arrow: this.props.arrow,
gravity: this.props.gravity,
shadow: this.props.shadow,
onHide: this.props.onHide
});
} else if (this.props.visible === false && this.props.reference) {
Tooltips.Dismiss(findNodeHandle(this.props.reference))
}
}

Expand Down
16 changes: 0 additions & 16 deletions ios/RNTooltips.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
58B511D71A9E6C8500147676 /* Sources */,
58B511D81A9E6C8500147676 /* Frameworks */,
58B511D91A9E6C8500147676 /* CopyFiles */,
FA0E49E01FC8EB10CDF2A91A /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -222,21 +221,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
FA0E49E01FC8EB10CDF2A91A /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-RNTooltips/Pods-RNTooltips-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-tooltips",
"version": "0.0.7",
"version": "0.0.8",
"description": "React Native: Native Tooltip View",
"main": "RNTooltips.js",
"scripts": {
Expand Down

0 comments on commit 25a81ca

Please sign in to comment.