back navigation fixes and tweaks
This commit is contained in:
parent
9bc5a2ecac
commit
95a33b411b
6 changed files with 34 additions and 8 deletions
|
@ -173,7 +173,7 @@ class ChannelPage extends React.PureComponent {
|
||||||
const { permanent_url: permanentUrl } = claim;
|
const { permanent_url: permanentUrl } = claim;
|
||||||
navigation.navigate({
|
navigation.navigate({
|
||||||
routeName: Constants.DRAWER_ROUTE_CHANNEL_CREATOR,
|
routeName: Constants.DRAWER_ROUTE_CHANNEL_CREATOR,
|
||||||
params: { editChannelUrl: permanentUrl },
|
params: { editChannelUrl: permanentUrl, returnUrl: permanentUrl },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -210,7 +210,7 @@ class ChannelPage extends React.PureComponent {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
{ cancelable: true }
|
{ cancelable: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
View,
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
|
import { navigateBack, navigateToUri, logPublish, uploadImageAsset } from 'utils/helper';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import ChannelIconItem from 'component/channelIconItem';
|
import ChannelIconItem from 'component/channelIconItem';
|
||||||
import ChannelRewardsDriver from 'component/channelRewardsDriver';
|
import ChannelRewardsDriver from 'component/channelRewardsDriver';
|
||||||
|
@ -37,6 +37,7 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
autoStyle: null,
|
autoStyle: null,
|
||||||
|
returnUrl: null,
|
||||||
canSave: true,
|
canSave: true,
|
||||||
claimId: null,
|
claimId: null,
|
||||||
creditsInputFocused: false,
|
creditsInputFocused: false,
|
||||||
|
@ -77,6 +78,7 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
descriptionFocused: false,
|
descriptionFocused: false,
|
||||||
websiteFocused: false,
|
websiteFocused: false,
|
||||||
emailFocused: false,
|
emailFocused: false,
|
||||||
|
hasReturnedBack: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
didFocusListener;
|
didFocusListener;
|
||||||
|
@ -118,7 +120,14 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const { currentRoute: prevRoute, drawerStack: prevDrawerStack, notify } = this.props;
|
const {
|
||||||
|
currentRoute: prevRoute,
|
||||||
|
drawerStack: prevDrawerStack,
|
||||||
|
popDrawerStack,
|
||||||
|
setPlayerVisible,
|
||||||
|
navigation,
|
||||||
|
notify,
|
||||||
|
} = this.props;
|
||||||
const { currentRoute, drawerStack, updatingChannel, updateChannelError } = nextProps;
|
const { currentRoute, drawerStack, updatingChannel, updateChannelError } = nextProps;
|
||||||
|
|
||||||
if (Constants.DRAWER_ROUTE_CHANNEL_CREATOR === currentRoute && currentRoute !== prevRoute) {
|
if (Constants.DRAWER_ROUTE_CHANNEL_CREATOR === currentRoute && currentRoute !== prevRoute) {
|
||||||
|
@ -142,6 +151,11 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
) {
|
) {
|
||||||
// navigated back from the form
|
// navigated back from the form
|
||||||
this.setState({ currentPhase: Constants.PHASE_LIST });
|
this.setState({ currentPhase: Constants.PHASE_LIST });
|
||||||
|
if (!this.state.hasReturnedBack && this.state.returnUrl) {
|
||||||
|
this.setState({ hasReturnedBack: true }, () =>
|
||||||
|
navigateBack(navigation, drawerStack, popDrawerStack, setPlayerVisible),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,11 +185,12 @@ export default class ChannelCreator extends React.PureComponent {
|
||||||
|
|
||||||
let isEditMode = false;
|
let isEditMode = false;
|
||||||
if (navigation.state.params) {
|
if (navigation.state.params) {
|
||||||
const { editChannelUrl, displayForm } = navigation.state.params;
|
const { editChannelUrl, displayForm, returnUrl } = navigation.state.params;
|
||||||
if (editChannelUrl) {
|
if (editChannelUrl) {
|
||||||
isEditMode = true;
|
isEditMode = true;
|
||||||
this.setState({ editChannelUrl, currentPhase: Constants.PHASE_CREATE });
|
this.setState({ editChannelUrl, currentPhase: Constants.PHASE_CREATE });
|
||||||
}
|
}
|
||||||
|
this.setState({ returnUrl });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEditMode && hasFormState) {
|
if (!isEditMode && hasFormState) {
|
||||||
|
|
|
@ -86,8 +86,10 @@ class DiscoverPage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
onComponentFocused = () => {
|
onComponentFocused = () => {
|
||||||
const { pushDrawerStack, setPlayerVisible } = this.props;
|
const { pushDrawerStack, setPlayerVisible, currentRoute } = this.props;
|
||||||
// pushDrawerStack();
|
if (currentRoute === Constants.DRAWER_ROUTE_DISCOVER) {
|
||||||
|
pushDrawerStack();
|
||||||
|
}
|
||||||
|
|
||||||
NativeModules.Firebase.setCurrentScreen('Your tags');
|
NativeModules.Firebase.setCurrentScreen('Your tags');
|
||||||
setPlayerVisible();
|
setPlayerVisible();
|
||||||
|
|
|
@ -328,7 +328,11 @@ class FilePage extends React.PureComponent {
|
||||||
|
|
||||||
onEditPressed = () => {
|
onEditPressed = () => {
|
||||||
const { claim, navigation } = this.props;
|
const { claim, navigation } = this.props;
|
||||||
navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } });
|
const uri = this.state.uri || this.getPurchaseUrl();
|
||||||
|
navigation.navigate({
|
||||||
|
routeName: Constants.DRAWER_ROUTE_PUBLISH,
|
||||||
|
params: { editMode: true, claimToEdit: claim, returnUrl: uri },
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onDeletePressed = () => {
|
onDeletePressed = () => {
|
||||||
|
|
|
@ -42,6 +42,9 @@ reducers[Constants.ACTION_PUSH_DRAWER_STACK] = (state, action) => {
|
||||||
if (lastRoute === Constants.DRAWER_ROUTE_PUBLISH_FORM && routeName === Constants.DRAWER_ROUTE_PUBLISH) {
|
if (lastRoute === Constants.DRAWER_ROUTE_PUBLISH_FORM && routeName === Constants.DRAWER_ROUTE_PUBLISH) {
|
||||||
canPushStack = false;
|
canPushStack = false;
|
||||||
}
|
}
|
||||||
|
if (routeName === Constants.DRAWER_ROUTE_DISCOVER && newStack.length === 1) {
|
||||||
|
canPushStack = false;
|
||||||
|
}
|
||||||
|
|
||||||
let lastRouteInStack;
|
let lastRouteInStack;
|
||||||
if (canPushStack) {
|
if (canPushStack) {
|
||||||
|
|
|
@ -169,6 +169,7 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
|
||||||
if (popDrawerStack) {
|
if (popDrawerStack) {
|
||||||
popDrawerStack();
|
popDrawerStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setPlayerVisible) {
|
if (setPlayerVisible) {
|
||||||
setPlayerVisible(false);
|
setPlayerVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -176,6 +177,7 @@ export function navigateBack(navigation, drawerStack, popDrawerStack, setPlayerV
|
||||||
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
|
const target = drawerStack[drawerStack.length > 1 ? drawerStack.length - 2 : 0];
|
||||||
const { route, params } = target;
|
const { route, params } = target;
|
||||||
navigation.goBack(navigation.state.key);
|
navigation.goBack(navigation.state.key);
|
||||||
|
|
||||||
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
|
if (!DrawerRoutes.includes(route) && !InnerDrawerRoutes.includes(route) && isURIValid(route)) {
|
||||||
navigateToUri(navigation, route, null, true, null, setPlayerVisible);
|
navigateToUri(navigation, route, null, true, null, setPlayerVisible);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue