mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 10:01:08 +08:00
fix(android): prevent error on navigation back after using page transition (#10439)
This commit is contained in:
@ -282,7 +282,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
getApplicationContext()
|
||||
getApplicationContext(),
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -305,7 +305,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -343,7 +343,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -391,7 +391,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -429,7 +429,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -466,7 +466,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -504,7 +504,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -550,7 +550,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -635,7 +635,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -685,7 +685,7 @@ export class FileSystemAccess implements IFileSystemAccess {
|
||||
reject(err);
|
||||
},
|
||||
}),
|
||||
null
|
||||
null,
|
||||
);
|
||||
} catch (ex) {
|
||||
reject(ex);
|
||||
@ -986,7 +986,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1019,7 +1019,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1058,7 +1058,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1098,7 +1098,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1137,7 +1137,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1174,7 +1174,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1215,7 +1215,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1254,7 +1254,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1293,7 +1293,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
@ -1332,7 +1332,7 @@ export class FileSystemAccess29 extends FileSystemAccess {
|
||||
onError(error) {
|
||||
reject(error);
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ function timelineProfileFunctionFactory<F extends Function>(fn: F, name: string,
|
||||
const end = time();
|
||||
console.log(`Timeline: Modules: ${name} ${this} (${start}ms. - ${end}ms.)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
: function () {
|
||||
const start = time();
|
||||
try {
|
||||
@ -128,7 +128,7 @@ function timelineProfileFunctionFactory<F extends Function>(fn: F, name: string,
|
||||
const end = time();
|
||||
console.log(`Timeline: Modules: ${name} (${start}ms. - ${end}ms.)`);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
const enum MemberType {
|
||||
|
@ -273,7 +273,7 @@ export class ActionBar extends ActionBarBase {
|
||||
owner._raiseTap();
|
||||
}
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
this.nativeViewProtected.setNavigationIcon(null);
|
||||
@ -362,7 +362,7 @@ export class ActionBar extends ActionBarBase {
|
||||
owner._raiseTap();
|
||||
}
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,14 @@ export abstract class Font implements FontDefinition {
|
||||
return this.fontWeight === FontWeight.SEMI_BOLD || this.fontWeight === FontWeight.BOLD || this.fontWeight === '700' || this.fontWeight === FontWeight.EXTRA_BOLD || this.fontWeight === FontWeight.BLACK;
|
||||
}
|
||||
|
||||
protected constructor(public readonly fontFamily: string, public readonly fontSize: number, fontStyle?: FontStyleType, fontWeight?: FontWeightType, fontScale?: number, public readonly fontVariationSettings?: Array<FontVariationSettingsType>) {
|
||||
protected constructor(
|
||||
public readonly fontFamily: string,
|
||||
public readonly fontSize: number,
|
||||
fontStyle?: FontStyleType,
|
||||
fontWeight?: FontWeightType,
|
||||
fontScale?: number,
|
||||
public readonly fontVariationSettings?: Array<FontVariationSettingsType>,
|
||||
) {
|
||||
this.fontStyle = fontStyle ?? FontStyle.NORMAL;
|
||||
this.fontWeight = fontWeight ?? FontWeight.NORMAL;
|
||||
this.fontScale = fontScale ?? 1;
|
||||
|
@ -2,14 +2,14 @@ import type { View } from '../core/view';
|
||||
import { ViewBase } from '../core/view-base';
|
||||
import { BackstackEntry } from '../frame';
|
||||
import { isNumber } from '../../utils/types';
|
||||
import { FadeTransition } from './fade-transition';
|
||||
import { Transition } from '.';
|
||||
import { getPageStartDefaultsForType, getRectFromProps, SharedTransition, SharedTransitionAnimationType, SharedTransitionEventData } from './shared-transition';
|
||||
import { getRectFromProps, SharedTransition, SharedTransitionAnimationType, SharedTransitionEventData } from './shared-transition';
|
||||
import { ImageSource } from '../../image-source';
|
||||
import { ContentView } from '../content-view';
|
||||
import { GridLayout } from '../layouts/grid-layout';
|
||||
import { ad } from '../../utils';
|
||||
import { Screen } from '../../platform';
|
||||
import { ExpandedEntry } from '../frame/fragment.transitions.android';
|
||||
import { android as AndroidUtils } from '../../utils/native-helper';
|
||||
// import { Image } from '../image';
|
||||
|
||||
@NativeClass
|
||||
@ -175,12 +175,20 @@ export class PageTransition extends Transition {
|
||||
return animationSet;
|
||||
}
|
||||
|
||||
androidFragmentTransactionCallback(fragmentTransaction: androidx.fragment.app.FragmentTransaction, currentEntry: BackstackEntry, newEntry: BackstackEntry) {
|
||||
androidFragmentTransactionCallback(fragmentTransaction: androidx.fragment.app.FragmentTransaction, currentEntry: ExpandedEntry, newEntry: BackstackEntry) {
|
||||
const fromPage = currentEntry.resolvedPage;
|
||||
const toPage = newEntry.resolvedPage;
|
||||
const newFragment: androidx.fragment.app.Fragment = newEntry.fragment;
|
||||
const state = SharedTransition.getState(this.id);
|
||||
const pageEnd = state?.pageEnd;
|
||||
if (!state) {
|
||||
// when navigating transition is set on the currentEntry but never cleaned up
|
||||
// which means that on a next navigation forward (without transition) and back
|
||||
// we will go here with an empty state!
|
||||
currentEntry.transition = null;
|
||||
return;
|
||||
}
|
||||
|
||||
const pageEnd = state.pageEnd;
|
||||
|
||||
//we can't look for presented right now as the toPage might not be loaded
|
||||
// and thus some views like ListView/Pager... might not have loaded their "children"
|
||||
@ -281,10 +289,10 @@ function loadViewInBackground(view: View) {
|
||||
hiddenHost.content = hostView;
|
||||
hiddenHost.visibility = 'collapse';
|
||||
hostView.addChild(view);
|
||||
hiddenHost._setupAsRootView(ad.getApplicationContext());
|
||||
hiddenHost._setupAsRootView(AndroidUtils.getApplicationContext());
|
||||
hiddenHost.callLoaded();
|
||||
|
||||
ad.getCurrentActivity().addContentView(hiddenHost.android, new android.view.ViewGroup.LayoutParams(0, 0));
|
||||
AndroidUtils.getCurrentActivity().addContentView(hiddenHost.android, new android.view.ViewGroup.LayoutParams(0, 0));
|
||||
|
||||
return {
|
||||
hiddenHost,
|
||||
|
@ -18,7 +18,7 @@ export function platformCheck(parent?: string) {
|
||||
|
||||
throw new Error(errorMsg);
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ interface IReplacementMap {
|
||||
* @internal
|
||||
*/
|
||||
export function getFileReplacementsFromEnv(
|
||||
env: IWebpackEnv = _env
|
||||
env: IWebpackEnv = _env,
|
||||
): IReplacementMap {
|
||||
const fileReplacements: IReplacementMap = {};
|
||||
|
||||
@ -50,7 +50,7 @@ export function getFileReplacementsFromEnv(
|
||||
|
||||
export function applyFileReplacements(
|
||||
config,
|
||||
fileReplacements: IReplacementMap = getFileReplacementsFromEnv()
|
||||
fileReplacements: IReplacementMap = getFileReplacementsFromEnv(),
|
||||
) {
|
||||
Object.entries(fileReplacements).forEach(([_replace, _with]) => {
|
||||
// in case we are replacing source files - we'll use aliases
|
||||
|
@ -17,7 +17,7 @@ export function error(...data: any): Error {
|
||||
// we return the error - the caller can throw or ignore
|
||||
if (typeof data[0] === 'string') {
|
||||
return new Error(
|
||||
'\n\n[@nativescript/webpack]\n---\n\n' + dedent(data[0]) + '\n\n---\n'
|
||||
'\n\n[@nativescript/webpack]\n---\n\n' + dedent(data[0]) + '\n\n---\n',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,12 @@ import { getProjectFilePath } from './project';
|
||||
export function addVirtualEntry(
|
||||
config: Config,
|
||||
name: string,
|
||||
contents: string
|
||||
contents: string,
|
||||
): string {
|
||||
return addVirtualModule(
|
||||
config,
|
||||
`__@nativescript_webpack_virtual_entry_${name}__`,
|
||||
contents
|
||||
contents,
|
||||
);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ export function addVirtualEntry(
|
||||
export function addVirtualModule(
|
||||
config: Config,
|
||||
name: string,
|
||||
contents: string
|
||||
contents: string,
|
||||
): string {
|
||||
const virtualEntryPath = join(getEntryDirPath(), `${name}`);
|
||||
|
||||
@ -51,7 +51,7 @@ export function addVirtualModule(
|
||||
// todo: we can remove this special handling once we no longer support v11
|
||||
if (config.plugins.has('AngularCompilerPlugin')) {
|
||||
const compatEntryPath = getProjectFilePath(
|
||||
join('node_modules', '.nativescript', `${name}`)
|
||||
join('node_modules', '.nativescript', `${name}`),
|
||||
);
|
||||
mkdirSync(dirname(compatEntryPath), { recursive: true });
|
||||
writeFileSync(compatEntryPath, options[virtualEntryPath]);
|
||||
|
@ -143,7 +143,7 @@ export function useConfig(config: keyof typeof defaultConfigs | false) {
|
||||
*/
|
||||
export function chainWebpack(
|
||||
chainFn: (config: Config, env: IWebpackEnv) => any,
|
||||
options?: { order?: number }
|
||||
options?: { order?: number },
|
||||
) {
|
||||
webpackChains.push({
|
||||
order: options?.order || 0,
|
||||
@ -160,8 +160,8 @@ export function chainWebpack(
|
||||
export function mergeWebpack(
|
||||
mergeFn: (
|
||||
config: Partial<webpack.Configuration>,
|
||||
env: IWebpackEnv
|
||||
) => any | Partial<webpack.Configuration>
|
||||
env: IWebpackEnv,
|
||||
) => any | Partial<webpack.Configuration>,
|
||||
) {
|
||||
webpackMerges.push(mergeFn);
|
||||
}
|
||||
@ -217,7 +217,7 @@ export function resolveChainableConfig(): Config {
|
||||
* @param chainableConfig Optional chain config to use.
|
||||
*/
|
||||
export function resolveConfig(
|
||||
chainableConfig = resolveChainableConfig()
|
||||
chainableConfig = resolveChainableConfig(),
|
||||
): webpack.Configuration {
|
||||
if (!hasInitialized) {
|
||||
throw error('resolveConfig() must be called after init()');
|
||||
|
Reference in New Issue
Block a user