fix(layouts): rootlayout not closing when no shadecover transition specified (#9278)

This commit is contained in:
William Juan
2021-03-24 21:49:30 +07:00
committed by Nathan Walker
parent b4415683d8
commit 3c569effed
2 changed files with 20 additions and 15 deletions

View File

@@ -3,7 +3,7 @@
"main": "index", "main": "index",
"types": "index.d.ts", "types": "index.d.ts",
"description": "NativeScript Core Modules", "description": "NativeScript Core Modules",
"version": "8.0.0-alpha.2", "version": "8.0.0-alpha.4",
"homepage": "https://nativescript.org", "homepage": "https://nativescript.org",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -45,21 +45,25 @@ export class RootLayoutBase extends GridLayout {
this.updateShadeCover(this.shadeCover, options.shadeCover); this.updateShadeCover(this.shadeCover, options.shadeCover);
} }
view.opacity = 0; // always begin with view invisible when adding dynamically
this.insertChild(view, this.getChildrenCount() + 1); this.insertChild(view, this.getChildrenCount() + 1);
if (options?.animation?.enterFrom) { if (options?.animation?.enterFrom) {
this.applyInitialState(view, options.animation.enterFrom); setTimeout(() => {
this.getEnterAnimation(view, options.animation.enterFrom) // only apply initial state and animate after the first tick - ensures safe areas and other measurements apply correctly
.play() this.applyInitialState(view, options.animation.enterFrom);
.then(() => { this.getEnterAnimation(view, options.animation.enterFrom)
this.applyDefaultState(view); .play()
resolve(); .then(() => {
}) this.applyDefaultState(view);
.catch((ex) => { resolve();
if (Trace.isEnabled()) { })
Trace.write(`Error playing enter animation: ${ex}`, Trace.categories.Layout, Trace.messageType.error); .catch((ex) => {
} if (Trace.isEnabled()) {
}); Trace.write(`Error playing enter animation: ${ex}`, Trace.categories.Layout, Trace.messageType.error);
}
});
});
} else { } else {
resolve(); resolve();
} }
@@ -88,7 +92,7 @@ export class RootLayoutBase extends GridLayout {
// update shade cover with the topmost popupView options (if not specifically told to ignore) // update shade cover with the topmost popupView options (if not specifically told to ignore)
const shadeCoverOptions = this.popupViews[this.popupViews.length - 1]?.options?.shadeCover; const shadeCoverOptions = this.popupViews[this.popupViews.length - 1]?.options?.shadeCover;
if (shadeCoverOptions && !poppedView?.options?.shadeCover.ignoreShadeRestore) { if (this.shadeCover && shadeCoverOptions && !poppedView?.options?.shadeCover.ignoreShadeRestore) {
this.updateShadeCover(this.shadeCover, shadeCoverOptions); this.updateShadeCover(this.shadeCover, shadeCoverOptions);
} }
@@ -97,7 +101,7 @@ export class RootLayoutBase extends GridLayout {
const exitAnimations: Promise<any>[] = [exitAnimation.play()]; const exitAnimations: Promise<any>[] = [exitAnimation.play()];
// add remove shade cover animation if this is the last opened popup view // add remove shade cover animation if this is the last opened popup view
if (this.popupViews.length === 0) { if (this.popupViews.length === 0 && this.shadeCover) {
exitAnimations.push(this.closeShadeCover(poppedView.options.shadeCover)); exitAnimations.push(this.closeShadeCover(poppedView.options.shadeCover));
} }
return Promise.all(exitAnimations) return Promise.all(exitAnimations)
@@ -341,6 +345,7 @@ export class RootLayoutBase extends GridLayout {
resolve(); resolve();
}); });
} }
resolve();
}); });
} }