Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pressEvent() {
const { icon } = this.props;
if (icon === 'settings') SafeAction('Settings');
else if (icon === 'arrow-back') {
Actions.pop();
if (Actions.state.routes.length === 2) {
setTimeout(() => Actions.refresh(), 1000);
}
} else if (icon === 'home') {
Actions.popTo('Menu');
// Clear last location
setLastLocation('');
setTimeout(() => Actions.refresh(), 1000);
} else SafeAction('Search');
}
}
const onBackPress = () => {
console.log(Actions.state);
if (Actions.state.index !== 0) {
return false
}
Actions.pop()
return true
}
export const SafeAction = (screen, obj, max = 0) => {
if (Actions.state.routes.filter(r => r.routeName === screen).length > max) {
console.log(`${screen} rejected`);
} else {
Actions.push(screen, obj);
console.log(`${screen} pushed`);
}
};
const onBackPress = () => {
console.log(Actions.state);
if (Actions.state.index !== 0) {
return false
}
Actions.pop()
return true
}
onBackPress = () => {
if (Actions.state.index == 0) return false;
else Actions.pop(); return true;
}
}
render() {
let backButton = (Actions.state.routes[0].index === 0 || this.props.hideBackButton) ?
constructor(props) {
super(props);
let hasMenu = false;
if (Actions.state.routes.findIndex(r => r.routeName === 'Menu') > 0) {
hasMenu = true;
}
this.state = {
menu: hasMenu,
icon: hasMenu ? 'home' : require('../../img/Ship.png')
}
}
onBackPress = () => {
if (Actions.state.index == 0) return false;
else Actions.pop(); return true;
}
}
return function () {
if (Actions.state.routes[0].index > 0) {
Actions.pop();
return true;
}
ts = Date.now();
if (!hasTip) {
let handler = function () {
let now = Date.now();
if (now - ts < 1000) {
requestAnimationFrame(handler)
} else {
hasTip = false
}
};
handler();
hasTip = true;
Toast(I18n("doublePressExit"));
onClose() {
if (Actions.state.index === 0) {
return false;
}
Animated.timing(this.state.opacity, {
duration: animaTime,
toValue: 0,
}).start(Actions.pop());
return true;
}