mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Resolved issue #263
This commit is contained in:
@ -9,14 +9,32 @@ import bindable = require("ui/core/bindable");
|
|||||||
import dependencyObservable = require("ui/core/dependency-observable");
|
import dependencyObservable = require("ui/core/dependency-observable");
|
||||||
import enums = require("ui/enums");
|
import enums = require("ui/enums");
|
||||||
import frameCommon = require("ui/frame/frame-common");
|
import frameCommon = require("ui/frame/frame-common");
|
||||||
|
import proxy = require("ui/core/proxy");
|
||||||
|
|
||||||
var OPTIONS_MENU = "optionsMenu";
|
var OPTIONS_MENU = "optionsMenu";
|
||||||
|
|
||||||
|
var navigationBarHiddenProperty = new dependencyObservable.Property(
|
||||||
|
"navigationBarHidden",
|
||||||
|
"Page",
|
||||||
|
new proxy.PropertyMetadata(false, dependencyObservable.PropertyMetadataSettings.AffectsLayout)
|
||||||
|
);
|
||||||
|
|
||||||
|
function onNavigationBarHiddenPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
|
console.log("onNavigationBarHiddenPropertyChanged("+data.newValue+")");
|
||||||
|
var page = <Page>data.object;
|
||||||
|
if (page.isLoaded) {
|
||||||
|
page._updateNavigationBar(data.newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(<proxy.PropertyMetadata>navigationBarHiddenProperty.metadata).onSetNativeValue = onNavigationBarHiddenPropertyChanged;
|
||||||
|
|
||||||
export module knownCollections {
|
export module knownCollections {
|
||||||
export var optionsMenu = "optionsMenu";
|
export var optionsMenu = "optionsMenu";
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Page extends contentView.ContentView implements dts.Page, view.AddArrayFromBuilder {
|
export class Page extends contentView.ContentView implements dts.Page, view.AddArrayFromBuilder {
|
||||||
|
public static navigationBarHiddenProperty = navigationBarHiddenProperty;
|
||||||
public static navigatingToEvent = "navigatingTo";
|
public static navigatingToEvent = "navigatingTo";
|
||||||
public static navigatedToEvent = "navigatedTo";
|
public static navigatedToEvent = "navigatedTo";
|
||||||
public static navigatingFromEvent = "navigatingFrom";
|
public static navigatingFromEvent = "navigatingFrom";
|
||||||
@ -36,9 +54,24 @@ export class Page extends contentView.ContentView implements dts.Page, view.AddA
|
|||||||
|
|
||||||
public onLoaded() {
|
public onLoaded() {
|
||||||
this._applyCss();
|
this._applyCss();
|
||||||
|
this._updateNavigationBar(this.navigationBarHidden);
|
||||||
super.onLoaded();
|
super.onLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get navigationBarHidden(): boolean {
|
||||||
|
console.log("page-common get navigationBarHidden: " + this._getValue(Page.navigationBarHiddenProperty));
|
||||||
|
return this._getValue(Page.navigationBarHiddenProperty);
|
||||||
|
}
|
||||||
|
|
||||||
|
set navigationBarHidden(value: boolean) {
|
||||||
|
console.log("page-common set navigationBarHidden: " + value);
|
||||||
|
this._setValue(Page.navigationBarHiddenProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public _updateNavigationBar(hidden: boolean) {
|
||||||
|
console.log("page-common._updateNavigationBar("+hidden+")");
|
||||||
|
}
|
||||||
|
|
||||||
get navigationContext(): any {
|
get navigationContext(): any {
|
||||||
return this._navigationContext;
|
return this._navigationContext;
|
||||||
}
|
}
|
||||||
@ -204,6 +237,7 @@ export class Page extends contentView.ContentView implements dts.Page, view.AddA
|
|||||||
this.optionsMenu.setItems(value);
|
this.optionsMenu.setItems(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class OptionsMenu implements dts.OptionsMenu {
|
export class OptionsMenu implements dts.OptionsMenu {
|
||||||
|
@ -89,4 +89,27 @@ export class Page extends pageCommon.Page {
|
|||||||
this._isAddedToNativeVisualTree = false;
|
this._isAddedToNativeVisualTree = false;
|
||||||
this._onDetached(true);
|
this._onDetached(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public _updateNavigationBar(hidden: boolean) {
|
||||||
|
if (!this.frame || !this.frame.android) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var actionBar = this.frame.android.actionBar;
|
||||||
|
|
||||||
|
if (!actionBar) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hidden) {
|
||||||
|
if (actionBar.isShowing()) {
|
||||||
|
actionBar.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!actionBar.isShowing()) {
|
||||||
|
actionBar.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
10
ui/page/page.d.ts
vendored
10
ui/page/page.d.ts
vendored
@ -46,6 +46,11 @@ declare module "ui/page" {
|
|||||||
* Represents a logical unit for navigation (inside Frame).
|
* Represents a logical unit for navigation (inside Frame).
|
||||||
*/
|
*/
|
||||||
export class Page extends contentView.ContentView implements view.AddArrayFromBuilder {
|
export class Page extends contentView.ContentView implements view.AddArrayFromBuilder {
|
||||||
|
/**
|
||||||
|
* Dependency property used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||||
|
*/
|
||||||
|
public static navigationBarHiddenProperty: dependencyObservable.Property;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String value used when hooking to shownModally event.
|
* String value used when hooking to shownModally event.
|
||||||
*/
|
*/
|
||||||
@ -73,6 +78,11 @@ declare module "ui/page" {
|
|||||||
|
|
||||||
constructor(options?: Options)
|
constructor(options?: Options)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||||
|
*/
|
||||||
|
navigationBarHidden: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A valid css string which will be applied for all nested UI components (based on css rules).
|
* A valid css string which will be applied for all nested UI components (based on css rules).
|
||||||
*/
|
*/
|
||||||
|
@ -175,6 +175,13 @@ export class Page extends pageCommon.Page {
|
|||||||
(<any>this)._isModal = false;
|
(<any>this)._isModal = false;
|
||||||
(<any>this)._UIModalPresentationFormSheet = false;
|
(<any>this)._UIModalPresentationFormSheet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public _updateNavigationBar(hidden: boolean) {
|
||||||
|
if (this.ios.navigationController.navigationBarHidden !== hidden) {
|
||||||
|
this.ios.navigationController.navigationBarHidden = hidden;
|
||||||
|
this.requestLayout();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TapBarItemHandlerImpl extends NSObject {
|
class TapBarItemHandlerImpl extends NSObject {
|
||||||
|
@ -6,6 +6,7 @@ import trace = require("trace");
|
|||||||
import imageSource = require("image-source");
|
import imageSource = require("image-source");
|
||||||
import types = require("utils/types");
|
import types = require("utils/types");
|
||||||
import app = require("application");
|
import app = require("application");
|
||||||
|
import page = require("ui/page");
|
||||||
|
|
||||||
var VIEWS_STATES = "_viewStates";
|
var VIEWS_STATES = "_viewStates";
|
||||||
var RESOURCE_PREFIX = "res://";
|
var RESOURCE_PREFIX = "res://";
|
||||||
@ -345,6 +346,11 @@ export class TabView extends common.TabView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public _addTabs(newItems: Array<definition.TabViewItem>) {
|
public _addTabs(newItems: Array<definition.TabViewItem>) {
|
||||||
|
var parentPage = <page.Page>view.getAncestor(this, "Page");
|
||||||
|
if (parentPage && parentPage.navigationBarHidden) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
trace.write("TabView._addTabs(" + newItems + ");", common.traceCategory);
|
trace.write("TabView._addTabs(" + newItems + ");", common.traceCategory);
|
||||||
super._addTabs(newItems);
|
super._addTabs(newItems);
|
||||||
|
|
||||||
@ -364,6 +370,7 @@ export class TabView extends common.TabView {
|
|||||||
actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
|
actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
|
||||||
|
|
||||||
this._originalActionBarIsShowing = actionBar.isShowing();
|
this._originalActionBarIsShowing = actionBar.isShowing();
|
||||||
|
|
||||||
actionBar.show();
|
actionBar.show();
|
||||||
|
|
||||||
// TODO: Where will be the support for more ActionBar settings like Title, Navigation buttons, etc.?
|
// TODO: Where will be the support for more ActionBar settings like Title, Navigation buttons, etc.?
|
||||||
@ -416,6 +423,11 @@ export class TabView extends common.TabView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public _removeTabs(oldItems: Array<definition.TabViewItem>) {
|
public _removeTabs(oldItems: Array<definition.TabViewItem>) {
|
||||||
|
var parentPage = <page.Page>view.getAncestor(this, "Page");
|
||||||
|
if (parentPage && parentPage.navigationBarHidden) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
trace.write("TabView._removeTabs(" + oldItems + ");", common.traceCategory);
|
trace.write("TabView._removeTabs(" + oldItems + ");", common.traceCategory);
|
||||||
super._removeTabs(oldItems);
|
super._removeTabs(oldItems);
|
||||||
|
|
||||||
@ -469,12 +481,9 @@ export class TabView extends common.TabView {
|
|||||||
|
|
||||||
// Select the respective tab in the ActionBar.
|
// Select the respective tab in the ActionBar.
|
||||||
var actionBar = this._getActionBar();
|
var actionBar = this._getActionBar();
|
||||||
if (actionBar) {
|
if (actionBar && index < actionBar.getNavigationItemCount() && index !== actionBar.getSelectedNavigationIndex()) {
|
||||||
var actionBarSelectedIndex = actionBar.getSelectedNavigationIndex();
|
trace.write("TabView actionBar.setSelectedNavigationItem("+index+")", common.traceCategory);
|
||||||
if (actionBarSelectedIndex !== index) {
|
actionBar.setSelectedNavigationItem(index);
|
||||||
trace.write("TabView actionBar.setSelectedNavigationItem("+index+")", common.traceCategory);
|
|
||||||
actionBar.setSelectedNavigationItem(index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select the respective page in the ViewPager
|
// Select the respective page in the ViewPager
|
||||||
|
Reference in New Issue
Block a user