new ui image + minor label fix

This commit is contained in:
Stanimir Karoserov
2014-06-09 17:18:28 +03:00
parent f577816d1e
commit 37727ff411
6 changed files with 102 additions and 1 deletions

View File

@ -161,6 +161,14 @@
<TypeScriptCompile Include="ui\core\view.ios.ts"> <TypeScriptCompile Include="ui\core\view.ios.ts">
<DependentUpon>view.d.ts</DependentUpon> <DependentUpon>view.d.ts</DependentUpon>
</TypeScriptCompile> </TypeScriptCompile>
<TypeScriptCompile Include="ui\image\image.android.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\image\image.d.ts" />
<TypeScriptCompile Include="ui\image\image.ios.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\image\index.ts" />
<TypeScriptCompile Include="ui\label\index.ts" /> <TypeScriptCompile Include="ui\label\index.ts" />
<TypeScriptCompile Include="ui\label\label.d.ts" /> <TypeScriptCompile Include="ui\label\label.d.ts" />
<TypeScriptCompile Include="ui\label\label.android.ts"> <TypeScriptCompile Include="ui\label\label.android.ts">

44
ui/image/image.android.ts Normal file
View File

@ -0,0 +1,44 @@

import observable = require("ui/core/observable");
import view = require("ui/core/view");
import application = require("application");
import imageSource = require("image-source");
export class Image extends view.View {
private static sourceProperty = "source";
private _source: imageSource.ImageSource;
private _android: android.widget.ImageView;
constructor() {
super();
// TODO: Verify that this is always true
var context = application.android.currentContext;
if (!context) {
// TODO: Delayed loading?
}
this._android = new android.widget.ImageView(context);
}
get android(): android.widget.ImageView {
return this._android;
}
get source(): imageSource.ImageSource {
return this._source;
}
set source(value: imageSource.ImageSource) {
this.setProperty(Image.sourceProperty, value);
}
public setNativeProperty(data: observable.PropertyChangeData) {
if (data.propertyName === Image.sourceProperty) {
this._source = data.value;
this._android.setImageBitmap(data.value.android);
} else if (true) {
}
}
}

11
ui/image/image.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
declare module "ui/image" {
import imageSource = require("image-source");
class Image {
android: android.widget.ImageView;
ios: UIKit.UIImageView;
source: imageSource.ImageSource;
}
}

36
ui/image/image.ios.ts Normal file
View File

@ -0,0 +1,36 @@

import observable = require("ui/core/observable");
import view = require("ui/core/view");
import imageSource = require("image-source");
export class Image extends view.View {
private static sourceProperty = "source";
private _source: imageSource.ImageSource;
private _ios: UIKit.UIImageView;
constructor() {
super();
this._ios = new UIKit.UIImageView();
}
get ios(): UIKit.UIImageView {
return this._ios;
}
get source(): imageSource.ImageSource {
return this._source;
}
set source(value: imageSource.ImageSource) {
this.setProperty(Image.sourceProperty, value);
}
public setNativeProperty(data: observable.PropertyChangeData) {
if (data.propertyName === Image.sourceProperty) {
this._source = data.value;
this._ios.image = this._source.ios;
this._ios.sizeToFit();
} else if (true) {
}
}
}

2
ui/image/index.ts Normal file
View File

@ -0,0 +1,2 @@
declare var module, require;
module.exports = require("ui/image/image");

View File

@ -16,7 +16,7 @@ export class Label extends view.View {
var extendsBody = Foundation.NSObject.extends( var extendsBody = Foundation.NSObject.extends(
{ {
observeValueForKeyPathOfObjectChangeContext: function (path: string, sender: Foundation.NSObject, change: Foundation.NSDictionary, context) { observeValueForKeyPathOfObjectChangeContext: function (path: string, sender: Foundation.NSObject, change: Foundation.NSDictionary, context) {
that.updateTwoWayBinding(Label.textProperty, change.objectForKey("new")); that.updateTwoWayBinding(Label.textProperty, change.objectForKey(Foundation.NSKeyValueChangeNewKey));
} }
}, {}); }, {});