mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
initial commit
This commit is contained in:
committed by
hshristov
parent
1bd78b4064
commit
f2e614b664
@@ -330,6 +330,16 @@
|
||||
<TypeScriptCompile Include="ui\list-picker\list-picker.ios.ts">
|
||||
<DependentUpon>list-picker.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="ui\tool-bar\tool-bar-common.ts">
|
||||
<DependentUpon>tool-bar.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="ui\tool-bar\tool-bar.android.ts">
|
||||
<DependentUpon>tool-bar.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="ui\tool-bar\tool-bar.d.ts" />
|
||||
<TypeScriptCompile Include="ui\tool-bar\tool-bar.ios.ts">
|
||||
<DependentUpon>tool-bar.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="ui\segmented-bar\segmented-bar-common.ts">
|
||||
<DependentUpon>segmented-bar.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
@@ -1453,6 +1463,9 @@
|
||||
<Content Include="ui\list-picker\package.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="ui\tool-bar\package.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="build\tslint.json" />
|
||||
|
||||
@@ -7,6 +7,26 @@
|
||||
<TabViewItem.view>
|
||||
<StackLayout>
|
||||
|
||||
<ToolBar>
|
||||
<ToolBar.items>
|
||||
<ToolBarItem>
|
||||
<ToolBarItem.view>
|
||||
<Label text="Label" />
|
||||
</ToolBarItem.view>
|
||||
</ToolBarItem>
|
||||
<ToolBarItem>
|
||||
<ToolBarItem.view>
|
||||
<Button text="Button" />
|
||||
</ToolBarItem.view>
|
||||
</ToolBarItem>
|
||||
<ToolBarItem>
|
||||
<ToolBarItem.view>
|
||||
<Image url="http://icons.iconarchive.com/icons/oxygen-icons.org/oxygen/256/Places-favorites-icon.png" />
|
||||
</ToolBarItem.view>
|
||||
</ToolBarItem>
|
||||
</ToolBar.items>
|
||||
</ToolBar>
|
||||
|
||||
<SegmentedBar selectedIndex="1" style="background-color: red; color: white" selectedBackgroundColor="green">
|
||||
<SegmentedBar.items>
|
||||
<SegmentedBarItem title="MAY 3" />
|
||||
|
||||
@@ -32,6 +32,8 @@ var MODULES = {
|
||||
"WebView": "ui/web-view",
|
||||
"SegmentedBar": "ui/segmented-bar",
|
||||
"SegmentedBarItem": "ui/segmented-bar",
|
||||
"ToolBar": "ui/tool-bar",
|
||||
"ToolBarItem": "ui/tool-bar",
|
||||
"TimePicker": "ui/time-picker",
|
||||
"DatePicker": "ui/date-picker",
|
||||
"ListPicker": "ui/list-picker",
|
||||
|
||||
2
ui/tool-bar/package.json
Normal file
2
ui/tool-bar/package.json
Normal file
@@ -0,0 +1,2 @@
|
||||
{ "name" : "tool-bar",
|
||||
"main" : "tool-bar.js" }
|
||||
25
ui/tool-bar/tool-bar-common.ts
Normal file
25
ui/tool-bar/tool-bar-common.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import definition = require("ui/tool-bar");
|
||||
import view = require("ui/core/view");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
|
||||
export module knownCollections {
|
||||
export var items = "items";
|
||||
}
|
||||
|
||||
export class ToolBar extends view.View implements definition.ToolBar {
|
||||
public _addArrayFromBuilder(name: string, value: Array<any>) {
|
||||
if (name === "items") {
|
||||
this._setValue(ToolBar.itemsProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
get items(): Array<definition.ToolBarItem> {
|
||||
return this._getValue(ToolBar.itemsProperty);
|
||||
}
|
||||
set items(value: Array<definition.ToolBarItem>) {
|
||||
this._setValue(ToolBar.itemsProperty, value);
|
||||
}
|
||||
|
||||
public static itemsProperty = new dependencyObservable.Property("items", "ToolBar", new proxy.PropertyMetadata(undefined))
|
||||
}
|
||||
28
ui/tool-bar/tool-bar.android.ts
Normal file
28
ui/tool-bar/tool-bar.android.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import common = require("ui/tool-bar/tool-bar-common");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import types = require("utils/types");
|
||||
|
||||
// merge the exports of the common file with the exports of this file
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(common, exports);
|
||||
|
||||
function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
var view = <ToolBar>data.object;
|
||||
if (!view.android) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
(<proxy.PropertyMetadata>common.ToolBar.itemsProperty.metadata).onSetNativeValue = onItemsPropertyChanged;
|
||||
|
||||
export class ToolBar extends common.ToolBar {
|
||||
private _android: any;
|
||||
|
||||
public _createUI() {
|
||||
this._android = new (<any>android.widget).Toolbar(this._context);
|
||||
}
|
||||
|
||||
get android(): any {
|
||||
return this._android;
|
||||
}
|
||||
}
|
||||
32
ui/tool-bar/tool-bar.d.ts
vendored
Normal file
32
ui/tool-bar/tool-bar.d.ts
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Contains the ToolBar class, which represents a ToolBar component.
|
||||
*/
|
||||
declare module "ui/tool-bar" {
|
||||
import view = require("ui/core/view");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
|
||||
/**
|
||||
* Represents a ToolBar item.
|
||||
*/
|
||||
interface ToolBarItem {
|
||||
/**
|
||||
* Gets or sets the title of the ToolBar.
|
||||
*/
|
||||
view: view.View;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a UI ToolBar component.
|
||||
*/
|
||||
export class ToolBar extends view.View {
|
||||
/**
|
||||
* Gets or sets the items of the ToolBar.
|
||||
*/
|
||||
items: Array<ToolBarItem>;
|
||||
|
||||
/**
|
||||
* Gets or sets the items dependency property of the ToolBar.
|
||||
*/
|
||||
public static itemsProperty: dependencyObservable.Property;
|
||||
}
|
||||
}
|
||||
41
ui/tool-bar/tool-bar.ios.ts
Normal file
41
ui/tool-bar/tool-bar.ios.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import definition = require("ui/tool-bar");
|
||||
import common = require("ui/tool-bar/tool-bar-common");
|
||||
import dependencyObservable = require("ui/core/dependency-observable");
|
||||
import proxy = require("ui/core/proxy");
|
||||
import view = require("ui/core/view");
|
||||
|
||||
// merge the exports of the common file with the exports of this file
|
||||
declare var exports;
|
||||
require("utils/module-merge").merge(common, exports);
|
||||
|
||||
function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
var bar = <ToolBar>data.object;
|
||||
if (!bar.ios) {
|
||||
return;
|
||||
}
|
||||
|
||||
var items = new NSMutableArray();
|
||||
for (var element in <Array<definition.ToolBarItem>>data.newValue) {
|
||||
if (element.view instanceof view.View) {
|
||||
bar._addView(element.view);
|
||||
items.addObject(element.view.ios);
|
||||
}
|
||||
}
|
||||
|
||||
bar.ios.setItemsAnimated(items, false);
|
||||
}
|
||||
(<proxy.PropertyMetadata>common.ToolBar.itemsProperty.metadata).onSetNativeValue = onItemsPropertyChanged;
|
||||
|
||||
export class ToolBar extends common.ToolBar {
|
||||
private _ios: UIToolbar;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._ios = UIToolbar.new();
|
||||
}
|
||||
|
||||
get ios(): UIToolbar {
|
||||
return this._ios;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user