mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Implemented simple label for iOS
This commit is contained in:
2
ui/core/view.d.ts
vendored
2
ui/core/view.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
import proxy = require("ui/core/proxy");
|
||||
|
||||
export declare class View extends proxy.ProxyObject {
|
||||
addToParent: (parent: any) => void;
|
||||
public addToParent(parent: any);
|
||||
android: any;
|
||||
ios: any;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user