mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
feat: Frame replacePage by entry (#9460)
* feat: Frame replacePage by entry * feat(webpack): improved svelte HMR (#9497) * update svelte config to use svelte-loader * handle null config * fix: worker support in .svelte files & update snapshots * fix after merge Co-authored-by: halfnelson <dpershouse@gmail.com> Co-authored-by: Igor Randjelovic <rigor789@gmail.com> * feat(webpack): use svelte-loader and fallback to svelte-loader-hot Allows running older projects * feat: allow overwriting replacePage transition Co-authored-by: farfromrefuge <martin.guillon@akylas.fr> Co-authored-by: halfnelson <dpershouse@gmail.com>
This commit is contained in:

committed by
Nathan Walker

parent
86ff418166
commit
ffab4c3165
@ -631,7 +631,14 @@ export class FrameBase extends CustomLayoutView {
|
||||
if (this.currentPage && viewMatchesModuleContext(this.currentPage, context, ['markup', 'script'])) {
|
||||
Trace.write(`Change Handled: Replacing page ${context.path}`, Trace.categories.Livesync);
|
||||
|
||||
this.replacePage(context.path);
|
||||
// replace current page with a default fade transition
|
||||
this.replacePage({
|
||||
moduleName: context.path,
|
||||
transition: {
|
||||
name: 'fade',
|
||||
duration: 100,
|
||||
},
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -676,13 +683,18 @@ export class FrameBase extends CustomLayoutView {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected replacePage(pagePath: string): void {
|
||||
public replacePage(entry: string | NavigationEntry): void {
|
||||
const currentBackstackEntry = this._currentEntry;
|
||||
const contextModuleName = sanitizeModuleName(pagePath);
|
||||
|
||||
const newPage = <Page>Builder.createViewFromEntry({ moduleName: contextModuleName });
|
||||
if (typeof entry === 'string') {
|
||||
const contextModuleName = sanitizeModuleName(entry);
|
||||
entry = { moduleName: contextModuleName };
|
||||
}
|
||||
|
||||
const newPage = Builder.createViewFromEntry(entry) as Page;
|
||||
|
||||
const newBackstackEntry: BackstackEntry = {
|
||||
entry: currentBackstackEntry.entry,
|
||||
entry: Object.assign({}, currentBackstackEntry.entry, entry),
|
||||
resolvedPage: newPage,
|
||||
navDepth: currentBackstackEntry.navDepth,
|
||||
fragmentTag: currentBackstackEntry.fragmentTag,
|
||||
|
Reference in New Issue
Block a user