Implemented simple label for iOS

This commit is contained in:
atanasovg
2014-06-06 14:10:53 +03:00
parent 14dd0b799a
commit 3e033da3ff
3 changed files with 58 additions and 3 deletions

2
ui/core/view.d.ts vendored
View File

@@ -1,7 +1,7 @@
import proxy = require("ui/core/proxy"); import proxy = require("ui/core/proxy");
export declare class View extends proxy.ProxyObject { export declare class View extends proxy.ProxyObject {
addToParent: (parent: any) => void; public addToParent(parent: any);
android: any; android: any;
ios: any; ios: any;
} }

View File

@@ -1 +1,11 @@
 import proxy = require("ui/core/proxy");
export class View extends proxy.ProxyObject {
public addToParent(parent: UIKit.UIView) {
var nativeInstance: UIKit.UIView = this["ios"];
if (nativeInstance) {
// TODO: Check for existing parent
parent.addSubview(nativeInstance);
}
}
}

View File

@@ -1,5 +1,50 @@
import view = require("ui/core/view"); import observable = require("ui/core/observable");
import view = require("ui/core/view");
import application = require("application");
export class Label extends view.View { export class Label extends view.View {
private static textProperty = "text";
private _ios: UIKit.UILabel;
private changedHandler: Foundation.NSObject;
constructor() {
super();
this._ios = new UIKit.UILabel();
//var extendsBody = Foundation.NSObject.extends(
// {
// onTextChanged: function (path, sender, change, context) {
// }
// },
// {
// exposedMethods: { "tick:": "v@:@" }
// });
//this.changedHandler = new extendsBody();
}
get ios(): UIKit.UILabel {
return this._ios;
}
get text(): string {
return this._ios.text;
}
set text(value: string) {
this.setProperty(Label.textProperty, value);
}
public setNativeProperty(data: observable.PropertyChangeData) {
// TODO: Will this be a gigantic if-else switch?
if (data.propertyName === Label.textProperty) {
this._ios.text = data.value;
} else if (true) {
}
}
public addToParent(parent: UIKit.UIView) {
super.addToParent(parent);
this._ios.sizeToFit();
}
} }