From 5fcfb753509c9ca72c1a805afba3eb42e8f2b56b Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Thu, 27 Aug 2020 09:07:25 +0200 Subject: [PATCH] android fragment transitions fully working now --- packages/core/ui/frame/frame-common.ts | 2 +- packages/core/ui/frame/index.android.ts | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/core/ui/frame/frame-common.ts b/packages/core/ui/frame/frame-common.ts index f8b98e87e..f52530aa3 100644 --- a/packages/core/ui/frame/frame-common.ts +++ b/packages/core/ui/frame/frame-common.ts @@ -259,8 +259,8 @@ export class FrameBase extends CustomLayoutView { public _updateBackstack(entry: BackstackEntry, navigationType: NavigationType): void { const isBack = navigationType === NavigationType.back; const isReplace = navigationType === NavigationType.replace; - this.raiseCurrentPageNavigatedEvents(isBack); const current = this._currentEntry; + this.raiseCurrentPageNavigatedEvents(isBack); // Do nothing for Hot Module Replacement if (isBack) { diff --git a/packages/core/ui/frame/index.android.ts b/packages/core/ui/frame/index.android.ts index 0c876dc06..6cc4af7ff 100644 --- a/packages/core/ui/frame/index.android.ts +++ b/packages/core/ui/frame/index.android.ts @@ -444,6 +444,9 @@ export class Frame extends FrameBase { } else { transaction.add(this.containerViewId, newFragment, newFragmentTag); } + if (this._currentEntry && this._currentEntry.entry.backstackVisible === false) { + transaction.remove(this._currentEntry.fragment); + } transaction.commitAllowingStateLoss(); } @@ -466,7 +469,7 @@ export class Frame extends FrameBase { _reverseTransitions(backstackEntry, this._currentEntry); const currentIndex =this.backStack.length; - const gotBackToIndex = this.backStack.indexOf(backstackEntry); + const goBackToIndex = this.backStack.indexOf(backstackEntry); // the order is important so that the transition listener called be // the one from the current entry we are going back from @@ -481,9 +484,10 @@ export class Frame extends FrameBase { transaction.remove((this._currentEntry).fragment); } - for (let index = gotBackToIndex + 1; index < currentIndex; index++) { + for (let index = goBackToIndex + 1; index < currentIndex; index++) { transaction.remove(this.backStack[index].fragment); } + transaction.commitAllowingStateLoss(); }