diff --git a/BCL.csproj b/BCL.csproj index cfe0edb89..bc71a73a0 100644 --- a/BCL.csproj +++ b/BCL.csproj @@ -271,6 +271,14 @@ + + + + button.d.ts + + + button.d.ts + diff --git a/ui/button/button.android.ts b/ui/button/button.android.ts new file mode 100644 index 000000000..6b9cbfc53 --- /dev/null +++ b/ui/button/button.android.ts @@ -0,0 +1,37 @@ +import observable = require("ui/core/observable"); +import view = require("ui/core/view"); +import application = require("application"); + +export class Button extends view.View { + private static textProperty = "text"; + private _android: android.widget.Button; + + constructor() { + super(); + this._android = new android.widget.Button(application.android.currentContext); + + var that = this; + this._android.setOnClickListener(new android.view.View.OnClickListener({ + onClick: function (v) { that.emit("click"); } + })); + } + + get android(): android.widget.Button { + return this._android; + } + + get text(): string { + return this.android.getText().toString(); + } + set text(value: string) { + this.setProperty(Button.textProperty, value); + } + + public setNativeProperty(data: observable.PropertyChangeData) { + if (data.propertyName === Button.textProperty) { + this.android.setText(data.value); + } else if (true) { + // + } + } +} \ No newline at end of file diff --git a/ui/button/button.d.ts b/ui/button/button.d.ts new file mode 100644 index 000000000..19fa3d6eb --- /dev/null +++ b/ui/button/button.d.ts @@ -0,0 +1,5 @@ +declare module "ui/button" { + class Button { + text: string; + } +} \ No newline at end of file diff --git a/ui/button/button.ios.ts b/ui/button/button.ios.ts new file mode 100644 index 000000000..63d600e7e --- /dev/null +++ b/ui/button/button.ios.ts @@ -0,0 +1,36 @@ +import observable = require("ui/core/observable"); +import view = require("ui/core/view"); +import application = require("application"); + +export class Button extends view.View { + private static textProperty = "text"; + private _ios: UIKit.UIButton; + + constructor() { + super(); + this._ios = UIKit.UIButton.buttonWithType(UIKit.UIButtonType.UIButtonTypeRoundedRect); + + var that = this; + var target = Foundation.NSObject.extends({ click: (args) => { that.emit("click"); } }, { exposedMethods: { "click:": "v@:@" } }); + this._ios.addTargetActionForControlEvents(new target(), "click:", UIKit.UIControlEvents.UIControlEventTouchUpInside); + } + + get ios(): UIKit.UIButton { + return this._ios; + } + + get text(): string { + return this.ios.titleForState(UIKit.UIControlState.UIControlStateNormal); + } + set text(value: string) { + this.setProperty(Button.textProperty, value); + } + + public setNativeProperty(data: observable.PropertyChangeData) { + if (data.propertyName === Button.textProperty) { + this.ios.setTitleForState(data.value, UIKit.UIControlState.UIControlStateNormal); + } else if (true) { + // + } + } +} \ No newline at end of file diff --git a/ui/button/index.ts b/ui/button/index.ts new file mode 100644 index 000000000..f2e6219b9 --- /dev/null +++ b/ui/button/index.ts @@ -0,0 +1,2 @@ +declare var module, require; +module.exports = require("ui/button/button"); \ No newline at end of file diff --git a/ui/dialogs/Readme.md b/ui/dialogs/Readme.md index 51bcf9828..bf92a284c 100644 --- a/ui/dialogs/Readme.md +++ b/ui/dialogs/Readme.md @@ -55,7 +55,7 @@ Custom dialogs: d.show(); setTimeout(function(){ d.hide(); }, 2000); - //or cancelable + //or cancelable loading dialog var d = new dialogs.Dialog("Loading...", function(r){ dialogs.alert("You just canceled loading!"); }, { cancelButtonText: "Cancel" }); d.show();