mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Property renamed and bug fixes
This commit is contained in:
@@ -61,6 +61,9 @@
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="apps\action-bar-demo\pages\action-bar-hidden.ts">
|
||||
<DependentUpon>action-bar-hidden.xml</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="apps\action-bar-demo\pages\action-items-text.ts">
|
||||
<DependentUpon>action-items-text.xml</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
@@ -84,6 +87,9 @@
|
||||
<DependentUpon>main-page.xml</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="apps\cuteness.unoptimized\reddit-app-view-model.ts" />
|
||||
<Content Include="apps\action-bar-demo\pages\action-bar-hidden.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="apps\action-bar-demo\pages\center-view-stack.xml" />
|
||||
<Content Include="apps\action-bar-demo\pages\center-view-segmented.xml" />
|
||||
<Content Include="apps\action-bar-demo\pages\center-view.xml" />
|
||||
@@ -1755,7 +1761,7 @@
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
||||
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2linear-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
||||
@@ -2,6 +2,7 @@
|
||||
<Page>
|
||||
<ScrollView>
|
||||
<StackLayout>
|
||||
<Button tap="itemTap" text="action bar hidden" tag="action-bar-hidden" />
|
||||
<Button tap="itemTap" text="page title and icon" tag="page-title-icon" />
|
||||
<Button tap="itemTap" text="navigation button" tag="navigation-button" />
|
||||
<Button tap="itemTap" text="action items icons" tag="action-items-icon" />
|
||||
|
||||
9
apps/action-bar-demo/pages/action-bar-hidden.ts
Normal file
9
apps/action-bar-demo/pages/action-bar-hidden.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import pages = require("ui/page");
|
||||
import view = require("ui/core/view");
|
||||
|
||||
var toggle = false;
|
||||
export function toggleTap(args) {
|
||||
var page = <pages.Page>view.getAncestor(<view.View>args.object, "Page")
|
||||
page.actionBarHidden = toggle;
|
||||
toggle = !toggle;
|
||||
}
|
||||
8
apps/action-bar-demo/pages/action-bar-hidden.xml
Normal file
8
apps/action-bar-demo/pages/action-bar-hidden.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<Page actionBarHidden="true">
|
||||
<Page.actionBar>
|
||||
<ActionBar title="Hide Test"/>
|
||||
</Page.actionBar>
|
||||
<StackLayout>
|
||||
<Button text="hide/show" tap="toggleTap" />
|
||||
</StackLayout>
|
||||
</Page>
|
||||
@@ -158,16 +158,16 @@ export class ActionBar extends view.View implements dts.ActionBar {
|
||||
}
|
||||
}
|
||||
|
||||
public _shouldShow(): boolean {
|
||||
public _isEmpty(): boolean {
|
||||
if (this.title ||
|
||||
(this.android && this.android.icon) ||
|
||||
this.navigationButton ||
|
||||
this.actionItems.getItems().length > 0) {
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,20 @@ export class ActionBar extends common.ActionBar {
|
||||
public _updateAndroid(menu: android.view.IMenu) {
|
||||
var actionBar: android.app.ActionBar = frame.topmost().android.actionBar;
|
||||
|
||||
if (this.page.actionBarHidden) {
|
||||
if (actionBar.isShowing()) {
|
||||
actionBar.hide();
|
||||
}
|
||||
|
||||
// If action bar is hidden - no need to fill it with items.
|
||||
return;
|
||||
}
|
||||
|
||||
// Assure action bar is showing;
|
||||
if (!actionBar.isShowing()) {
|
||||
actionBar.show();
|
||||
}
|
||||
|
||||
this._addActionItems(menu);
|
||||
|
||||
// Set title
|
||||
|
||||
2
ui/action-bar/action-bar.d.ts
vendored
2
ui/action-bar/action-bar.d.ts
vendored
@@ -49,7 +49,7 @@ declare module "ui/action-bar" {
|
||||
update();
|
||||
|
||||
//@private
|
||||
_shouldShow(): boolean
|
||||
_isEmpty(): boolean
|
||||
_updateAndroid(menu: android.view.IMenu);
|
||||
_onAndroidItemSelected(itemId: number): boolean
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import pages = require("ui/page");
|
||||
import enums = require("ui/enums");
|
||||
import utils = require("utils/utils");
|
||||
import view = require("ui/core/view");
|
||||
import types = require("utils/types");
|
||||
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(frameCommon, exports);
|
||||
@@ -84,7 +85,12 @@ export class Frame extends frameCommon.Frame {
|
||||
|
||||
case enums.NavigationBarVisibility.auto:
|
||||
var pageInstance: pages.Page = page || this.currentPage;
|
||||
newValue = this.backStack.length > 0 || (pageInstance && pageInstance.actionBar._shouldShow());
|
||||
if (pageInstance && types.isDefined(pageInstance.actionBarHidden)) {
|
||||
newValue = !pageInstance.actionBarHidden;
|
||||
}
|
||||
else {
|
||||
newValue = this.backStack.length > 0 || (pageInstance && !pageInstance.actionBar._isEmpty());
|
||||
}
|
||||
newValue = !!newValue; // Make sure it is boolean
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,23 +10,23 @@ import actionBar = require("ui/action-bar");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import proxy = require("ui/core/proxy");
|
||||
|
||||
var navigationBarHiddenProperty = new dependencyObservable.Property(
|
||||
"navigationBarHidden",
|
||||
var actionBarHiddenProperty = new dependencyObservable.Property(
|
||||
"actionBarHidden",
|
||||
"Page",
|
||||
new proxy.PropertyMetadata(undefined, dependencyObservable.PropertyMetadataSettings.AffectsLayout)
|
||||
);
|
||||
|
||||
function onNavigationBarHiddenPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
function onActionBarHiddenPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
var page = <Page>data.object;
|
||||
if (page.isLoaded) {
|
||||
page._updateNavigationBar(data.newValue);
|
||||
page._updateActionBar(data.newValue);
|
||||
}
|
||||
}
|
||||
|
||||
(<proxy.PropertyMetadata>navigationBarHiddenProperty.metadata).onSetNativeValue = onNavigationBarHiddenPropertyChanged;
|
||||
(<proxy.PropertyMetadata>actionBarHiddenProperty.metadata).onSetNativeValue = onActionBarHiddenPropertyChanged;
|
||||
|
||||
export class Page extends contentView.ContentView implements dts.Page {
|
||||
public static navigationBarHiddenProperty = navigationBarHiddenProperty;
|
||||
public static actionBarHiddenProperty = actionBarHiddenProperty;
|
||||
public static navigatingToEvent = "navigatingTo";
|
||||
public static navigatedToEvent = "navigatedTo";
|
||||
public static navigatingFromEvent = "navigatingFrom";
|
||||
@@ -47,22 +47,22 @@ export class Page extends contentView.ContentView implements dts.Page {
|
||||
public onLoaded() {
|
||||
this._applyCss();
|
||||
|
||||
if (this.navigationBarHidden !== undefined) {
|
||||
this._updateNavigationBar(this.navigationBarHidden);
|
||||
if (this.actionBarHidden !== undefined) {
|
||||
this._updateActionBar(this.actionBarHidden);
|
||||
}
|
||||
|
||||
super.onLoaded();
|
||||
}
|
||||
|
||||
get navigationBarHidden(): boolean {
|
||||
return this._getValue(Page.navigationBarHiddenProperty);
|
||||
get actionBarHidden(): boolean {
|
||||
return this._getValue(Page.actionBarHiddenProperty);
|
||||
}
|
||||
|
||||
set navigationBarHidden(value: boolean) {
|
||||
this._setValue(Page.navigationBarHiddenProperty, value);
|
||||
set actionBarHidden(value: boolean) {
|
||||
this._setValue(Page.actionBarHiddenProperty, value);
|
||||
}
|
||||
|
||||
public _updateNavigationBar(hidden: boolean) {
|
||||
public _updateActionBar(hidden: boolean) {
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@@ -83,26 +83,7 @@ export class Page extends pageCommon.Page {
|
||||
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();
|
||||
}
|
||||
}
|
||||
public _updateActionBar(hidden: boolean) {
|
||||
this.actionBar.update();
|
||||
}
|
||||
}
|
||||
4
ui/page/page.d.ts
vendored
4
ui/page/page.d.ts
vendored
@@ -49,7 +49,7 @@ declare module "ui/page" {
|
||||
/**
|
||||
* Dependency property used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||
*/
|
||||
public static navigationBarHiddenProperty: dependencyObservable.Property;
|
||||
public static actionBarHiddenProperty: dependencyObservable.Property;
|
||||
|
||||
/**
|
||||
* String value used when hooking to shownModally event.
|
||||
@@ -81,7 +81,7 @@ declare module "ui/page" {
|
||||
/**
|
||||
* Used to hide the Navigation Bar in iOS and the Action Bar in Android.
|
||||
*/
|
||||
navigationBarHidden: boolean;
|
||||
actionBarHidden: boolean;
|
||||
|
||||
/**
|
||||
* A valid css string which will be applied for all nested UI components (based on css rules).
|
||||
|
||||
@@ -3,6 +3,7 @@ import definition = require("ui/page");
|
||||
import viewModule = require("ui/core/view");
|
||||
import trace = require("trace");
|
||||
import utils = require("utils/utils");
|
||||
import types = require("utils/types");
|
||||
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(pageCommon, exports);
|
||||
@@ -148,8 +149,8 @@ export class Page extends pageCommon.Page {
|
||||
(<any>this)._UIModalPresentationFormSheet = false;
|
||||
}
|
||||
|
||||
public _updateNavigationBar(hidden: boolean) {
|
||||
if (this.ios.navigationController.navigationBarHidden !== hidden) {
|
||||
public _updateActionBar(hidden: boolean) {
|
||||
if (types.isDefined(hidden) && this.ios.navigationController.navigationBarHidden !== hidden) {
|
||||
this.ios.navigationController.navigationBarHidden = hidden;
|
||||
this.requestLayout();
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ export class TabView extends common.TabView {
|
||||
|
||||
public _addTabs(newItems: Array<definition.TabViewItem>) {
|
||||
var parentPage = <page.Page>view.getAncestor(this, "Page");
|
||||
if (parentPage && parentPage.navigationBarHidden) {
|
||||
if (parentPage && parentPage.actionBarHidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ export class TabView extends common.TabView {
|
||||
|
||||
public _removeTabs(oldItems: Array<definition.TabViewItem>) {
|
||||
var parentPage = <page.Page>view.getAncestor(this, "Page");
|
||||
if (parentPage && parentPage.navigationBarHidden) {
|
||||
if (parentPage && parentPage.actionBarHidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user