Merge branch 'master' into doubleTap-location

This commit is contained in:
Luke Curran
2020-02-21 15:02:23 -06:00
committed by GitHub
15 changed files with 105 additions and 10 deletions

View File

@ -14,6 +14,7 @@ const modulesLoadedForUI = new Set<string>();
const defaultExtensionMap: ExtensionMap = {
".js": ".js",
".ts": ".js",
".kt": ".js",
".css": ".css",
".scss": ".css",
".less": ".css",

View File

@ -470,6 +470,12 @@ export abstract class ViewBase extends Observable {
*/
_setupAsRootView(context: any): void;
/**
* When returning true the callLoaded method will be run in setTimeout
* Method is intended to be overridden by inheritors and used as "protected"
*/
_shouldDelayLoad(): boolean;
/**
* @private
*/

View File

@ -615,10 +615,18 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
public loadView(view: ViewBase): void {
if (view && !view.isLoaded) {
view.callLoaded();
if (this._shouldDelayLoad()) {
setTimeout(() => view.callLoaded());
} else {
view.callLoaded();
}
}
}
public _shouldDelayLoad(): boolean {
return false;
}
public unloadView(view: ViewBase): void {
if (view && view.isLoaded) {
view.callUnloaded();
@ -1053,7 +1061,7 @@ export const classNameProperty = new Property<ViewBase, string>({
cssClasses.clear();
if (shouldAddModalRootViewCssClasses) {
cssClasses.add(MODAL_ROOT_VIEW_CSS_CLASS);
cssClasses.add(MODAL_ROOT_VIEW_CSS_CLASS);
} else if (shouldAddRootViewCssClasses) {
cssClasses.add(ROOT_VIEW_CSS_CLASS);
}

View File

@ -42,6 +42,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
public actionBarVisibility: "auto" | "never" | "always";
public _currentEntry: BackstackEntry;
public _animationInProgress = false;
public _executingContext: NavigationContext;
public _isInFrameStack = false;
public static defaultAnimatedNavigation = true;

View File

@ -147,6 +147,10 @@ export class Frame extends View {
* @private
*/
navigationBarHeight: number;
/**
* @private
*/
_animationInProgress: boolean;
/**
* @private
*/
@ -218,21 +222,21 @@ export function setFragmentClass(clazz: any): void;
/**
* @deprecated Use Frame.getFrameById() instead.
*
*
* Gets a frame by id.
*/
export function getFrameById(id: string): Frame;
/**
* @deprecated Use Frame.topmost() instead.
*
*
* Gets the topmost frame in the frames stack. An application will typically has one frame instance. Multiple frames handle nested (hierarchical) navigation scenarios.
*/
export function topmost(): Frame;
/**
* @deprecated Use Frame.goBack() instead.
*
*
* Navigates back using the navigation hierarchy (if any). Updates the Frame stack as needed.
* This method will start from the topmost Frame and will recursively search for an instance that has the canGoBack operation available.
*/
@ -241,7 +245,7 @@ export function goBack();
//@private
/**
* @deprecated Use Frame._stack() instead.
*
*
* @private
*/
export function _stack(): Array<Frame>;
@ -487,7 +491,7 @@ export function setActivityCallbacks(activity: any /*androidx.appcompat.app.AppC
//@private
/**
* @deprecated Use Frame.reloadPage() instead.
*
*
* @private
*/
export function reloadPage(context?: ModuleContext): void;

View File

@ -93,7 +93,7 @@ class UIViewControllerImpl extends UIViewController {
return;
}
const frame = this.navigationController ? (<any>this.navigationController).owner : null;
const frame = (this.navigationController ? (<any>this.navigationController).owner : null);
const newEntry = this[ENTRY];
// Don't raise event if currentPage was showing modal page.
@ -199,7 +199,7 @@ class UIViewControllerImpl extends UIViewController {
if (!owner) {
return;
}
// Cache presentedViewController if any. We don't want to raise
// navigation events in case of presenting view controller.
if (!owner._presentedViewController) {
@ -230,7 +230,6 @@ class UIViewControllerImpl extends UIViewController {
if (!page || page.modal || page._presentedViewController) {
return;
}
// Forward navigation does not remove page from frame so we raise unloaded manually.
if (page.isLoaded) {
page.callUnloaded();
@ -349,6 +348,10 @@ export class Page extends PageBase {
//
}
public _shouldDelayLoad(): boolean {
return this._frame && this._frame._animationInProgress;
}
public onLoaded(): void {
super.onLoaded();
if (this.hasActionBar) {

View File

@ -1091,7 +1091,18 @@ export class Tabs extends TabsBase {
}
this._currentNativeSelectedIndex = value;
let itemControllerOwner = null;
if (itemController._owner) {
let itemControllerOwner = <Frame>itemController._owner.get();
// do not load new views while the animation is in progress https://stackoverflow.com/a/47031524/613113
itemControllerOwner._animationInProgress = true;
}
this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => {
if (itemControllerOwner) {
itemControllerOwner._animationInProgress = false;
}
if (finished) {
// HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606
invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null));