Call loaded/unloaded on the rootView when application is resumed/suspended

Remove dead code from frame.ios
This commit is contained in:
Hristo Hristov
2017-12-15 15:26:23 +02:00
parent 4e74c37313
commit 33cd058718
2 changed files with 31 additions and 17 deletions

View File

@@ -126,6 +126,11 @@ class IOSApplication implements IOSApplicationDefinition {
const ios = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
const object = this;
notify(<ApplicationEventData>{ eventName: resumeEvent, object, ios });
const rootView = this._rootView;
if (rootView && !rootView.isLoaded) {
rootView.callLoaded();
}
if (!displayedOnce) {
notify(<ApplicationEventData>{ eventName: displayedEvent, object, ios });
displayedOnce = true;
@@ -134,10 +139,18 @@ class IOSApplication implements IOSApplicationDefinition {
private didEnterBackground(notification: NSNotification) {
notify(<ApplicationEventData>{ eventName: suspendEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
const rootView = this._rootView;
if (rootView && rootView.isLoaded) {
rootView.callUnloaded();
}
}
private willTerminate(notification: NSNotification) {
notify(<ApplicationEventData>{ eventName: exitEvent, object: this, ios: utils.ios.getter(UIApplication, UIApplication.sharedApplication) });
const rootView = this._rootView;
if (rootView && rootView.isLoaded) {
rootView.callUnloaded();
}
}
private didReceiveMemoryWarning(notification: NSNotification) {

View File

@@ -46,15 +46,9 @@ export function reloadPage(): void {
export class Frame extends FrameBase {
public viewController: UINavigationControllerImpl;
private _ios: iOSFrame;
public _animatedDelegate = <UINavigationControllerDelegate>UINavigationControllerAnimatedDelegate.new();
public _shouldSkipNativePop: boolean = false;
public _navigateToEntry: BackstackEntry;
public _widthMeasureSpec: number;
public _heightMeasureSpec: number;
public _right: number;
public _bottom: number;
private _ios: iOSFrame;
constructor() {
super();
@@ -173,19 +167,17 @@ export class Frame extends FrameBase {
public _goBackCore(backstackEntry: BackstackEntry) {
super._goBackCore(backstackEntry);
navDepth = backstackEntry[NAV_DEPTH];
if (!this._shouldSkipNativePop) {
let controller = backstackEntry.resolvedPage.ios;
let animated = this._currentEntry ? this._getIsAnimatedNavigation(this._currentEntry.entry) : false;
let controller = backstackEntry.resolvedPage.ios;
let animated = this._currentEntry ? this._getIsAnimatedNavigation(this._currentEntry.entry) : false;
this._updateActionBar(backstackEntry.resolvedPage);
if (traceEnabled()) {
traceWrite(`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`, traceCategories.Navigation);
}
this._ios.controller.popToViewControllerAnimated(controller, animated);
this._updateActionBar(backstackEntry.resolvedPage);
if (traceEnabled()) {
traceWrite(`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`, traceCategories.Navigation);
}
this._ios.controller.popToViewControllerAnimated(controller, animated);
}
public _updateActionBar(page?: Page, disableNavBarAnimation: boolean = false): void {
@@ -377,11 +369,20 @@ class UINavigationControllerImpl extends UINavigationController {
public viewWillAppear(animated: boolean): void {
super.viewWillAppear(animated);
const owner = this._owner.get();
if (owner && (!owner.isLoaded && !owner.parent)) {
if (owner && !owner.isLoaded && !owner.parent) {
owner.callLoaded();
}
}
@profile
public viewDidDisappear(animated: boolean): void {
super.viewDidDisappear(animated);
const owner = this._owner.get();
if (owner && owner.isLoaded && !owner.parent && !this.presentedViewController) {
owner.callUnloaded();
}
}
private animateWithDuration(navigationTransition: NavigationTransition,
nativeTransition: UIViewAnimationTransition,
transitionType: string,