Merge pull request #1049 from NativeScript/feature/respect-show-action-bar

Respect frame.android.showActionBar when page.actionBarHidden is not …
This commit is contained in:
Alexander Vakrilov
2015-11-09 09:50:00 +02:00
2 changed files with 27 additions and 5 deletions

View File

@ -97,8 +97,8 @@ export class ActionBar extends common.ActionBar {
if (!this._toolbar) { if (!this._toolbar) {
return; return;
} }
if (this.page.actionBarHidden) { if (!this.page.frame || !this.page.frame._getNavBarVisible(this.page)) {
this._toolbar.setVisibility(android.view.View.GONE); this._toolbar.setVisibility(android.view.View.GONE);
// If action bar is hidden - no need to fill it with items. // If action bar is hidden - no need to fill it with items.
@ -304,4 +304,4 @@ function getIconVisibility(iconVisibility: string): boolean {
default: default:
return false; return false;
} }
} }

View File

@ -5,6 +5,7 @@ import trace = require("trace");
import observable = require("data/observable"); import observable = require("data/observable");
import utils = require("utils/utils"); import utils = require("utils/utils");
import application = require("application"); import application = require("application");
import types = require("utils/types");
global.moduleMerge(frameCommon, exports); global.moduleMerge(frameCommon, exports);
@ -346,7 +347,15 @@ export class Frame extends frameCommon.Frame {
} }
public _getNavBarVisible(page: pages.Page): boolean { public _getNavBarVisible(page: pages.Page): boolean {
return this._android.showActionBar; if (types.isDefined(page.actionBarHidden)) {
return !page.actionBarHidden;
}
if (this._android && types.isDefined(this._android.showActionBar)) {
return this._android.showActionBar;
}
return true;
} }
} }
@ -520,9 +529,9 @@ var framesCache: Array<WeakRef<AndroidFrame>> = new Array<WeakRef<AndroidFrame>>
class AndroidFrame extends observable.Observable implements definition.AndroidFrame { class AndroidFrame extends observable.Observable implements definition.AndroidFrame {
public rootViewGroup: android.view.ViewGroup; public rootViewGroup: android.view.ViewGroup;
public hasOwnActivity = false; public hasOwnActivity = false;
public showActionBar = false;
public frameId; public frameId;
private _showActionBar = true;
private _activity: android.app.Activity; private _activity: android.app.Activity;
private _owner: Frame; private _owner: Frame;
private _cachePagesOnNavigate: boolean; private _cachePagesOnNavigate: boolean;
@ -534,6 +543,19 @@ class AndroidFrame extends observable.Observable implements definition.AndroidFr
framesCache.push(new WeakRef(this)); framesCache.push(new WeakRef(this));
} }
public get showActionBar(): boolean {
return this._showActionBar;
}
public set showActionBar(value: boolean) {
if (this._showActionBar !== value) {
this._showActionBar = value;
if (this.owner.currentPage) {
this.owner.currentPage.actionBar.update();
}
}
}
public get activity(): android.app.Activity { public get activity(): android.app.Activity {
if (this._activity) { if (this._activity) {
return this._activity; return this._activity;