dont use replace transaction anymore.

That way we dont “unload” and “load” fragments.
This fixes black screens and slow transitions with opengl or cameras

# Conflicts:
#	packages/core/ui/frame/fragment.transitions.android.ts
#	packages/core/ui/frame/frame-common.ts
#	packages/core/ui/frame/index.android.ts
This commit is contained in:
Martin Guillon
2020-08-07 11:33:26 +02:00
parent 16c154e885
commit 582f5fa6eb
3 changed files with 28 additions and 9 deletions

View File

@ -143,13 +143,12 @@ export function _setAndroidFragmentTransitions(animated: boolean, navigationTran
if (currentFragmentNeedsDifferentAnimation) {
setupCurrentFragmentFadeTransition(navigationTransition, currentEntry);
}
} else if (name === 'explode') {
} else if (name === 'explode') {
setupNewFragmentExplodeTransition(navigationTransition, newEntry);
if (currentFragmentNeedsDifferentAnimation) {
setupCurrentFragmentExplodeTransition(navigationTransition, currentEntry);
}
} else if (name.indexOf('flip') === 0) {
navigationTransition = { duration: 3000, curve: null };
const direction = name.substr('flip'.length) || 'right'; //Extract the direction from the string
const flipTransition = new FlipTransition(direction, navigationTransition.duration, navigationTransition.curve);

View File

@ -296,10 +296,6 @@ export class FrameBase extends CustomLayoutView {
private raiseCurrentPageNavigatedEvents(isBack: boolean) {
const page = this.currentPage;
if (page) {
if (page.isLoaded) {
// Forward navigation does not remove page from frame so we raise unloaded manually.
page.callUnloaded();
}
page.onNavigatedFrom(isBack);
}
}

View File

@ -324,6 +324,8 @@ export class Frame extends FrameBase {
// If we had real navigation process queue.
this._processNavigationQueue(entry.resolvedPage);
} else {
// Otherwise currentPage was recreated so this wasn't real navigation.
// Continue with next item in the queue.
@ -436,7 +438,7 @@ export class Frame extends FrameBase {
//transaction.setTransition(androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
}
transaction.replace(this.containerViewId, newFragment, newFragmentTag);
transaction.add(this.containerViewId, newFragment, newFragmentTag);
transaction.commitAllowingStateLoss();
}
@ -458,8 +460,30 @@ export class Frame extends FrameBase {
_reverseTransitions(backstackEntry, this._currentEntry);
transaction.replace(this.containerViewId, backstackEntry.fragment, backstackEntry.fragmentTag);
const currentIndex =this.backStack.length;
const gotBackToIndex = this.backStack.indexOf(backstackEntry);
for (let index = gotBackToIndex + 1; index < currentIndex; index++) {
transaction.remove(this.backStack[index].fragment);
}
if (this._currentEntry !== backstackEntry) {
// if we are going back we need to store where we are backing to
// so that we can set the current entry
if ((this._currentEntry as any).exitTransitionListener) {
(this._currentEntry as any).exitTransitionListener.backEntry = backstackEntry;
}
if ((this._currentEntry as any).returnTransitionListener) {
(this._currentEntry as any).returnTransitionListener.backEntry = backstackEntry;
}
if ((this._currentEntry as any).enterTransitionListener) {
(this._currentEntry as any).enterTransitionListener.backEntry = backstackEntry;
}
if ((this._currentEntry as any).reenterTransitionListener) {
(this._currentEntry as any).reenterTransitionListener.backEntry = backstackEntry;
}
transaction.remove((this._currentEntry).fragment);
}
transaction.commitAllowingStateLoss();
}