Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fixNavigator(Navigator: *) {
- return (...args: any[]) => {
- class FixedNavigator extends Navigator(...args) {
- _blockDispatch: boolean;
- constructor(...constructorArgs: any[]) {
- super(...constructorArgs);
- const originalDispatch = this.dispatch;
- this.dispatch = (...dispatchArgs): boolean => {
- // console.log('Dispatch', ...dispatchArgs);
- let handled = false;
- const { type, routeName, force } = dispatchArgs[0]; // get action
- if (
- (type !== 'Navigation/NAVIGATE' && type !== 'Navigation/BACK') ||
- (type === 'Navigation/NAVIGATE' &&
- (routeName === 'DrawerClose' ||
- routeName === 'DrawerOpen' ||
- routeName === 'DrawerToggle')) ||
- force === true
- ) {
- // Non Navigate/Back action or Drawer action should dispatch right away
- handled = originalDispatch(...dispatchArgs);
- } else if (!this._blockDispatch) {
- this._blockDispatch = true;
- handled = originalDispatch(...dispatchArgs);
- InteractionManager.runAfterInteractions(() => {
- this._blockDispatch = false; // release after animation ended
- });
- } else {
- handled = true;
- }
- return handled;
- };
- }
- }
- return FixedNavigator;
- };
- }
- const MainNavigator = fixNavigator(StackNavigator)({
- //kode lo di sini
- })
Add Comment
Please, Sign In to add comment