Add a flag we can use to skip string template calcs in release

This commit is contained in:
Panayot Cankov
2016-05-17 15:36:33 +03:00
parent 114f8b47ae
commit eda260323e
42 changed files with 705 additions and 238 deletions

View File

@ -71,12 +71,16 @@ export function resolvePageFromEntry(entry: definition.NavigationEntry): Page {
var moduleExports;
if (global.moduleExists(entry.moduleName)) {
trace.write("Loading pre-registered JS module: " + entry.moduleName, trace.categories.Navigation);
if (trace.enabled) {
trace.write("Loading pre-registered JS module: " + entry.moduleName, trace.categories.Navigation);
}
moduleExports = global.loadModule(entry.moduleName);
} else {
var moduleExportsResolvedPath = resolveFileName(moduleNamePath, "js");
if (moduleExportsResolvedPath) {
trace.write("Loading JS file: " + moduleExportsResolvedPath, trace.categories.Navigation);
if (trace.enabled) {
trace.write("Loading JS file: " + moduleExportsResolvedPath, trace.categories.Navigation);
}
// Exclude extension when doing require.
moduleExportsResolvedPath = moduleExportsResolvedPath.substr(0, moduleExportsResolvedPath.length - 3)
@ -85,7 +89,9 @@ export function resolvePageFromEntry(entry: definition.NavigationEntry): Page {
}
if (moduleExports && moduleExports.createPage) {
trace.write("Calling createPage()", trace.categories.Navigation);
if (trace.enabled) {
trace.write("Calling createPage()", trace.categories.Navigation);
}
page = moduleExports.createPage();
}
else {
@ -113,7 +119,9 @@ function pageFromBuilder(moduleNamePath: string, moduleExports: any): Page {
// Possible XML file path.
var fileName = resolveFileName(moduleNamePath, "xml");
if (fileName) {
trace.write("Loading XML file: " + fileName, trace.categories.Navigation);
if (trace.enabled) {
trace.write("Loading XML file: " + fileName, trace.categories.Navigation);
}
ensureBuilder();
@ -163,7 +171,9 @@ export class Frame extends CustomLayoutView implements definition.Frame {
* @param to The backstack entry to navigate back to.
*/
public goBack(backstackEntry?: definition.BackstackEntry) {
trace.write(`GO BACK`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`GO BACK`, trace.categories.Navigation);
}
if (!this.canGoBack()) {
// TODO: Do we need to throw an error?
return;
@ -190,12 +200,16 @@ export class Frame extends CustomLayoutView implements definition.Frame {
this._processNavigationContext(navigationContext);
}
else {
trace.write(`Going back scheduled`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`Going back scheduled`, trace.categories.Navigation);
}
}
}
public navigate(param: any) {
trace.write(`NAVIGATE`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`NAVIGATE`, trace.categories.Navigation);
}
var entry = buildEntryFromArgs(param);
var page = resolvePageFromEntry(entry);
@ -219,7 +233,9 @@ export class Frame extends CustomLayoutView implements definition.Frame {
this._processNavigationContext(navigationContext);
}
else {
trace.write(`Navigation scheduled`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`Navigation scheduled`, trace.categories.Navigation);
}
}
}

View File

@ -25,9 +25,13 @@ var navDepth = -1;
var activityInitialized = false;
function onFragmentShown(fragment: FragmentClass) {
trace.write(`SHOWN ${fragment.getTag()}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`SHOWN ${fragment.getTag()}`, trace.categories.NativeLifecycle);
}
if (fragment[CLEARING_HISTORY]) {
trace.write(`${fragment.getTag()} has been shown, but we are currently clearing history. Returning.`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${fragment.getTag()} has been shown, but we are currently clearing history. Returning.`, trace.categories.NativeLifecycle);
}
return null;
}
@ -62,10 +66,14 @@ function onFragmentShown(fragment: FragmentClass) {
}
function onFragmentHidden(fragment: FragmentClass, destroyed: boolean) {
trace.write(`HIDDEN ${fragment.getTag()}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`HIDDEN ${fragment.getTag()}`, trace.categories.NativeLifecycle);
}
if (fragment[CLEARING_HISTORY]) {
trace.write(`${fragment.getTag()} has been hidden, but we are currently clearing history. Clearing any existing transitions.`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${fragment.getTag()} has been hidden, but we are currently clearing history. Clearing any existing transitions.`, trace.categories.NativeLifecycle);
}
transitionModule._clearBackwardTransitions(fragment);
transitionModule._clearForwardTransitions(fragment);
}
@ -118,7 +126,9 @@ export class Frame extends frameCommon.Frame {
}
public _navigateCore(backstackEntry: definition.BackstackEntry) {
trace.write(`${this}._navigateCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}._navigateCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
}
let activity = this._android.activity;
if (!activity) {
@ -149,7 +159,9 @@ export class Frame extends frameCommon.Frame {
let fragment: android.app.Fragment;
while (i >= 0) {
fragment = manager.findFragmentByTag(manager.getBackStackEntryAt(i--).getName());
trace.write(`${fragment.getTag()}[CLEARING_HISTORY] = true;`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${fragment.getTag()}[CLEARING_HISTORY] = true;`, trace.categories.NativeLifecycle);
}
fragment[CLEARING_HISTORY] = true;
}
@ -158,13 +170,17 @@ export class Frame extends frameCommon.Frame {
fragment = manager.findFragmentByTag(this.currentPage[TAG]);
if (fragment) {
fragment[CLEARING_HISTORY] = true;
trace.write(`${fragment.getTag()}[CLEARING_HISTORY] = true;`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${fragment.getTag()}[CLEARING_HISTORY] = true;`, trace.categories.NativeLifecycle);
}
}
}
if (backStackEntryCount) {
let firstEntryName = manager.getBackStackEntryAt(0).getName();
trace.write(`manager.popBackStack(${firstEntryName}, android.app.FragmentManager.POP_BACK_STACK_INCLUSIVE);`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`manager.popBackStack(${firstEntryName}, android.app.FragmentManager.POP_BACK_STACK_INCLUSIVE);`, trace.categories.NativeLifecycle);
}
manager.popBackStack(firstEntryName, android.app.FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
this._currentEntry = null;
@ -214,24 +230,34 @@ export class Frame extends frameCommon.Frame {
if (isFirstNavigation) {
fragmentTransaction.add(this.containerViewId, newFragment, newFragmentTag);
trace.write(`fragmentTransaction.add(${newFragmentTag});`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`fragmentTransaction.add(${newFragmentTag});`, trace.categories.NativeLifecycle);
}
}
else {
if (this.android.cachePagesOnNavigate && !backstackEntry.entry.clearHistory) {
if (currentFragment) {
fragmentTransaction.hide(currentFragment);
trace.write(`fragmentTransaction.hide(${currentFragmentTag});`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`fragmentTransaction.hide(${currentFragmentTag});`, trace.categories.NativeLifecycle);
}
}
else {
trace.write(`Could not find ${currentFragmentTag} to hide.`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`Could not find ${currentFragmentTag} to hide.`, trace.categories.NativeLifecycle);
}
}
fragmentTransaction.add(this.containerViewId, newFragment, newFragmentTag);
trace.write(`fragmentTransaction.add(${newFragmentTag});`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`fragmentTransaction.add(${newFragmentTag});`, trace.categories.NativeLifecycle);
}
}
else {
fragmentTransaction.replace(this.containerViewId, newFragment, newFragmentTag);
trace.write(`fragmentTransaction.replace(${newFragmentTag});`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`fragmentTransaction.replace(${newFragmentTag});`, trace.categories.NativeLifecycle);
}
}
// Add to backStack if needed.
@ -239,7 +265,9 @@ export class Frame extends frameCommon.Frame {
// We add each entry in the backstack to avoid the "Stack corrupted" mismatch
let backstackTag = this._currentEntry[BACKSTACK_TAG];
fragmentTransaction.addToBackStack(backstackTag);
trace.write(`fragmentTransaction.addToBackStack(${backstackTag});`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`fragmentTransaction.addToBackStack(${backstackTag});`, trace.categories.NativeLifecycle);
}
}
}
@ -259,7 +287,9 @@ export class Frame extends frameCommon.Frame {
}
fragmentTransaction.commit();
trace.write(`fragmentTransaction.commit();`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`fragmentTransaction.commit();`, trace.categories.NativeLifecycle);
}
}
public _goBackCore(backstackEntry: definition.BackstackEntry) {
@ -272,7 +302,9 @@ export class Frame extends frameCommon.Frame {
this._currentEntry.isNavigation = true;
}
trace.write(`${this}._goBackCore(pageId: ${backstackEntry.resolvedPage.id}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}._goBackCore(pageId: ${backstackEntry.resolvedPage.id}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
}
var manager = this._android.activity.getFragmentManager();
if (manager.getBackStackEntryCount() > 0) {
@ -360,24 +392,32 @@ export class Frame extends frameCommon.Frame {
let weakActivityInstance = weakActivity.get();
let isCurrent = args.activity === weakActivityInstance;
if (!weakActivityInstance) {
trace.write(`Frame _processNavigationContext: Drop For Activity GC-ed`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`Frame _processNavigationContext: Drop For Activity GC-ed`, trace.categories.Navigation);
}
unsubscribe();
return
}
if (isCurrent) {
trace.write(`Frame _processNavigationContext: Activity.Resumed, Continue`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`Frame _processNavigationContext: Activity.Resumed, Continue`, trace.categories.Navigation);
}
super._processNavigationContext(navigationContext);
unsubscribe();
}
}
let unsubscribe = () => {
trace.write(`Frame _processNavigationContext: Unsubscribe from Activity.Resumed`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`Frame _processNavigationContext: Unsubscribe from Activity.Resumed`, trace.categories.Navigation);
}
application.android.off(application.AndroidApplication.activityResumedEvent, resume);
application.android.off(application.AndroidApplication.activityStoppedEvent, unsubscribe);
application.android.off(application.AndroidApplication.activityDestroyedEvent, unsubscribe);
}
trace.write(`Frame._processNavigationContext: Subscribe for Activity.Resumed`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`Frame._processNavigationContext: Subscribe for Activity.Resumed`, trace.categories.Navigation);
}
application.android.on(application.AndroidApplication.activityResumedEvent, resume);
application.android.on(application.AndroidApplication.activityStoppedEvent, unsubscribe);
application.android.on(application.AndroidApplication.activityDestroyedEvent, unsubscribe);
@ -508,16 +548,22 @@ function findPageForFragment(fragment: android.app.Fragment, frame: Frame) {
var page: pages.Page;
var entry: definition.BackstackEntry;
trace.write(`Finding page for ${fragmentTag}.`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`Finding page for ${fragmentTag}.`, trace.categories.NativeLifecycle);
}
if (fragmentTag === (<any>pages).DIALOG_FRAGMENT_TAG) {
trace.write(`No need to find page for dialog fragment.`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`No need to find page for dialog fragment.`, trace.categories.NativeLifecycle);
}
return;
}
if (frame.currentPage && frame.currentPage[TAG] === fragmentTag) {
page = frame.currentPage;
entry = frame._currentEntry;
trace.write(`Current page matches fragment ${fragmentTag}.`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`Current page matches fragment ${fragmentTag}.`, trace.categories.NativeLifecycle);
}
}
else {
var backStack = frame.backStack;
@ -529,7 +575,9 @@ function findPageForFragment(fragment: android.app.Fragment, frame: Frame) {
}
if (entry) {
page = entry.resolvedPage;
trace.write(`Found ${page} for ${fragmentTag}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`Found ${page} for ${fragmentTag}`, trace.categories.NativeLifecycle);
}
}
}
@ -584,7 +632,9 @@ class FragmentClass extends android.app.Fragment {
}
public onHiddenChanged(hidden: boolean): void {
trace.write(`${this.getTag()}.onHiddenChanged(${hidden})`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${this.getTag()}.onHiddenChanged(${hidden})`, trace.categories.NativeLifecycle);
}
super.onHiddenChanged(hidden);
if (hidden) {
onFragmentHidden(this, false);
@ -600,12 +650,16 @@ class FragmentClass extends android.app.Fragment {
animator = super.onCreateAnimator(transit, enter, nextAnim);
}
trace.write(`${this.getTag()}.onCreateAnimator(${transit}, ${enter}, ${nextAnim}): ${animator}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${this.getTag()}.onCreateAnimator(${transit}, ${enter}, ${nextAnim}): ${animator}`, trace.categories.NativeLifecycle);
}
return animator;
}
public onCreate(savedInstanceState: android.os.Bundle): void {
trace.write(`${this.getTag()}.onCreate(${savedInstanceState})`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${this.getTag()}.onCreate(${savedInstanceState})`, trace.categories.NativeLifecycle);
}
super.onCreate(savedInstanceState);
super.setHasOptionsMenu(true);
@ -626,7 +680,9 @@ class FragmentClass extends android.app.Fragment {
}
public onCreateView(inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle): android.view.View {
trace.write(`${this.getTag()}.onCreateView(inflater, container, ${savedInstanceState})`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${this.getTag()}.onCreateView(inflater, container, ${savedInstanceState})`, trace.categories.NativeLifecycle);
}
var entry = this.entry;
var page = entry.resolvedPage;
if (savedInstanceState && savedInstanceState.getBoolean(HIDDEN, false)) {
@ -641,7 +697,9 @@ class FragmentClass extends android.app.Fragment {
}
public onSaveInstanceState(outState: android.os.Bundle): void {
trace.write(`${this.getTag()}.onSaveInstanceState(${outState})`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${this.getTag()}.onSaveInstanceState(${outState})`, trace.categories.NativeLifecycle);
}
super.onSaveInstanceState(outState);
if (this.isHidden()) {
outState.putBoolean(HIDDEN, true);
@ -649,14 +707,18 @@ class FragmentClass extends android.app.Fragment {
}
public onDestroyView(): void {
trace.write(`${this.getTag()}.onDestroyView()`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${this.getTag()}.onDestroyView()`, trace.categories.NativeLifecycle);
}
super.onDestroyView();
// Detaching the page has been move in onFragmentHidden due to transitions.
onFragmentHidden(this, true);
}
public onDestroy(): void {
trace.write(`${this.getTag()}.onDestroy()`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`${this.getTag()}.onDestroy()`, trace.categories.NativeLifecycle);
}
super.onDestroy();
this.entry[FRAGMENT] = undefined;
}
@ -672,7 +734,9 @@ class NativeScriptActivity extends android.app.Activity {
}
protected onCreate(savedInstanceState: android.os.Bundle): void {
trace.write(`NativeScriptActivity.onCreate(${savedInstanceState})`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`NativeScriptActivity.onCreate(${savedInstanceState})`, trace.categories.NativeLifecycle);
}
let app = application.android;
let intent = this.getIntent();
@ -752,7 +816,9 @@ class NativeScriptActivity extends android.app.Activity {
protected onStart(): void {
super.onStart();
trace.write("NativeScriptActivity.onStart();", trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write("NativeScriptActivity.onStart();", trace.categories.NativeLifecycle);
}
let rootView = this.rootView
if (rootView && !rootView.isLoaded) {
rootView.onLoaded();
@ -761,7 +827,9 @@ class NativeScriptActivity extends android.app.Activity {
protected onStop(): void {
super.onStop();
trace.write("NativeScriptActivity.onStop();", trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write("NativeScriptActivity.onStop();", trace.categories.NativeLifecycle);
}
let rootView = this.rootView
if (rootView && rootView.isLoaded) {
rootView.onUnloaded();
@ -775,11 +843,15 @@ class NativeScriptActivity extends android.app.Activity {
}
super.onDestroy();
trace.write("NativeScriptActivity.onDestroy();", trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write("NativeScriptActivity.onDestroy();", trace.categories.NativeLifecycle);
}
}
public onBackPressed(): void {
trace.write("NativeScriptActivity.onBackPressed;", trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write("NativeScriptActivity.onBackPressed;", trace.categories.NativeLifecycle);
}
var args = <application.AndroidActivityBackPressedEventData>{
eventName: "activityBackPressed",
@ -799,7 +871,9 @@ class NativeScriptActivity extends android.app.Activity {
}
public onRequestPermissionsResult (requestCode: number, permissions: Array<String>, grantResults: Array<number>): void {
trace.write("NativeScriptActivity.onRequestPermissionsResult;", trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write("NativeScriptActivity.onRequestPermissionsResult;", trace.categories.NativeLifecycle);
}
application.android.notify(<application.AndroidActivityRequestPermissionsEventData>{
eventName: "activityRequestPermissions",
@ -813,7 +887,9 @@ class NativeScriptActivity extends android.app.Activity {
protected onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void {
super.onActivityResult(requestCode, resultCode, data);
trace.write(`NativeScriptActivity.onActivityResult(${requestCode}, ${resultCode}, ${data})`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`NativeScriptActivity.onActivityResult(${requestCode}, ${resultCode}, ${data})`, trace.categories.NativeLifecycle);
}
var result = application.android.onActivityResult;
if (result) {

View File

@ -70,7 +70,9 @@ export class Frame extends frameCommon.Frame {
}
public _navigateCore(backstackEntry: definition.BackstackEntry) {
trace.write(`${this}._navigateCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}._navigateCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
}
let viewController: UIViewController = backstackEntry.resolvedPage.ios;
if (!viewController) {
throw new Error("Required page does not have a viewController created.");
@ -109,7 +111,9 @@ export class Frame extends frameCommon.Frame {
// First navigation.
if (!this._currentEntry) {
this._ios.controller.pushViewControllerAnimated(viewController, animated);
trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
}
return;
}
@ -119,7 +123,9 @@ export class Frame extends frameCommon.Frame {
var newControllers = NSMutableArray.alloc().initWithCapacity(1);
newControllers.addObject(viewController);
this._ios.controller.setViewControllersAnimated(newControllers, animated);
trace.write(`${this}.setViewControllersAnimated([${viewController}], ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}.setViewControllersAnimated([${viewController}], ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
}
return;
}
@ -141,25 +147,33 @@ export class Frame extends frameCommon.Frame {
// replace the controllers instead of pushing directly
this._ios.controller.setViewControllersAnimated(newControllers, animated);
trace.write(`${this}.setViewControllersAnimated([originalControllers - lastController + ${viewController}], ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}.setViewControllersAnimated([originalControllers - lastController + ${viewController}], ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
}
return;
}
// General case.
this._ios.controller.pushViewControllerAnimated(viewController, animated);
trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}.pushViewControllerAnimated(${viewController}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
}
}
public _goBackCore(backstackEntry: definition.BackstackEntry) {
navDepth = backstackEntry[NAV_DEPTH];
trace.write(`${this}._goBackCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}._goBackCore(page: ${backstackEntry.resolvedPage}, backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}, clearHistory: ${backstackEntry.entry.clearHistory}), navDepth: ${navDepth}`, trace.categories.Navigation);
}
if (!this._shouldSkipNativePop) {
var controller = backstackEntry.resolvedPage.ios;
var animated = this._currentEntry ? this._getIsAnimatedNavigation(this._currentEntry.entry) : false;
this._updateActionBar(backstackEntry.resolvedPage);
trace.write(`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
if (trace.enabled) {
trace.write(`${this}.popToViewControllerAnimated(${controller}, ${animated}); depth = ${navDepth}`, trace.categories.Navigation);
}
this._ios.controller.popToViewControllerAnimated(controller, animated);
}
}
@ -327,7 +341,10 @@ export class Frame extends frameCommon.Frame {
return;
}
trace.write(`Forcing navigationBar.frame.origin.y to ${statusBarHeight} due to a higher in-call status-bar`, trace.categories.Layout);
if (trace.enabled) {
trace.write(`Forcing navigationBar.frame.origin.y to ${statusBarHeight} due to a higher in-call status-bar`, trace.categories.Layout);
}
this._ios.controller.navigationBar.autoresizingMask = UIViewAutoresizing.UIViewAutoresizingNone;
this._ios.controller.navigationBar.removeConstraints((<any>this)._ios.controller.navigationBar.constraints);
this._ios.controller.navigationBar.frame = CGRectMake(
@ -352,15 +369,21 @@ class TransitionDelegate extends NSObject {
}
public animationWillStart(animationID: string, context: any): void {
trace.write(`START ${this._id}`, trace.categories.Transition);
if (trace.enabled) {
trace.write(`START ${this._id}`, trace.categories.Transition);
}
}
public animationDidStop(animationID: string, finished: boolean, context: any): void {
if (finished) {
trace.write(`END ${this._id}`, trace.categories.Transition);
if (trace.enabled) {
trace.write(`END ${this._id}`, trace.categories.Transition);
}
}
else {
trace.write(`CANCEL ${this._id}`, trace.categories.Transition);
if (trace.enabled) {
trace.write(`CANCEL ${this._id}`, trace.categories.Transition);
}
}
var index = transitionDelegates.indexOf(this);
@ -405,7 +428,10 @@ class UINavigationControllerAnimatedDelegate extends NSObject implements UINavig
return null;
}
trace.write(`UINavigationControllerImpl.navigationControllerAnimationControllerForOperationFromViewControllerToViewController(${operation}, ${fromVC}, ${toVC}), transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`UINavigationControllerImpl.navigationControllerAnimationControllerForOperationFromViewControllerToViewController(${operation}, ${fromVC}, ${toVC}), transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
}
if (!transitionModule) {
transitionModule = require("ui/transition");
}
@ -440,7 +466,10 @@ class UINavigationControllerImpl extends UINavigationController {
public viewDidLayoutSubviews(): void {
let owner = this._owner.get();
if (owner) {
trace.write(this._owner + " viewDidLayoutSubviews, isLoaded = " + owner.isLoaded, trace.categories.ViewHierarchy);
if (trace.enabled) {
trace.write(this._owner + " viewDidLayoutSubviews, isLoaded = " + owner.isLoaded, trace.categories.ViewHierarchy);
}
owner._updateLayout();
}
}
@ -475,7 +504,9 @@ class UINavigationControllerImpl extends UINavigationController {
public pushViewControllerAnimated(viewController: UIViewController, animated: boolean): void {
let navigationTransition = <definition.NavigationTransition>viewController[TRANSITION];
trace.write(`UINavigationControllerImpl.pushViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`UINavigationControllerImpl.pushViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!animated || !navigationTransition || !nativeTransition) {
@ -491,7 +522,9 @@ class UINavigationControllerImpl extends UINavigationController {
public setViewControllersAnimated(viewControllers: NSArray, animated: boolean): void {
var viewController = viewControllers.lastObject;
var navigationTransition = <definition.NavigationTransition>viewController[TRANSITION];
trace.write(`UINavigationControllerImpl.setViewControllersAnimated(${viewControllers}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`UINavigationControllerImpl.setViewControllersAnimated(${viewControllers}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
}
let nativeTransition = _getNativeTransition(navigationTransition, true);
if (!animated || !navigationTransition || !nativeTransition) {
@ -507,7 +540,9 @@ class UINavigationControllerImpl extends UINavigationController {
public popViewControllerAnimated(animated: boolean): UIViewController {
var lastViewController = this.viewControllers.lastObject;
var navigationTransition = <definition.NavigationTransition>lastViewController[TRANSITION];
trace.write(`UINavigationControllerImpl.popViewControllerAnimated(${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`UINavigationControllerImpl.popViewControllerAnimated(${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
}
if (navigationTransition && navigationTransition.name === "non-animated") {
//https://github.com/NativeScript/NativeScript/issues/1787
@ -529,7 +564,9 @@ class UINavigationControllerImpl extends UINavigationController {
public popToViewControllerAnimated(viewController: UIViewController, animated: boolean): NSArray {
let lastViewController = this.viewControllers.lastObject;
let navigationTransition = <definition.NavigationTransition>lastViewController[TRANSITION];
trace.write(`UINavigationControllerImpl.popToViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
if (trace.enabled) {
trace.write(`UINavigationControllerImpl.popToViewControllerAnimated(${viewController}, ${animated}); transition: ${JSON.stringify(navigationTransition)}`, trace.categories.NativeLifecycle);
}
if (navigationTransition && navigationTransition.name === "non-animated") {
//https://github.com/NativeScript/NativeScript/issues/1787
@ -585,19 +622,29 @@ export function _getNativeCurve(transition: definition.NavigationTransition): UI
if (transition.curve) {
switch (transition.curve) {
case AnimationCurve.easeIn:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseIn.", trace.categories.Transition);
if (trace.enabled) {
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseIn.", trace.categories.Transition);
}
return UIViewAnimationCurve.UIViewAnimationCurveEaseIn;
case AnimationCurve.easeOut:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseOut.", trace.categories.Transition);
if (trace.enabled) {
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseOut.", trace.categories.Transition);
}
return UIViewAnimationCurve.UIViewAnimationCurveEaseOut;
case AnimationCurve.easeInOut:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseInOut.", trace.categories.Transition);
if (trace.enabled) {
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveEaseInOut.", trace.categories.Transition);
}
return UIViewAnimationCurve.UIViewAnimationCurveEaseInOut;
case AnimationCurve.linear:
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveLinear.", trace.categories.Transition);
if (trace.enabled) {
trace.write("Transition curve resolved to UIViewAnimationCurve.UIViewAnimationCurveLinear.", trace.categories.Transition);
}
return UIViewAnimationCurve.UIViewAnimationCurveLinear;
default:
trace.write("Transition curve resolved to original: " + transition.curve, trace.categories.Transition);
if (trace.enabled) {
trace.write("Transition curve resolved to original: " + transition.curve, trace.categories.Transition);
}
return transition.curve;
}
}