mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
new ui image + minor label fix
This commit is contained in:
@ -161,6 +161,14 @@
|
||||
<TypeScriptCompile Include="ui\core\view.ios.ts">
|
||||
<DependentUpon>view.d.ts</DependentUpon>
|
||||
</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\label.d.ts" />
|
||||
<TypeScriptCompile Include="ui\label\label.android.ts">
|
||||
|
44
ui/image/image.android.ts
Normal file
44
ui/image/image.android.ts
Normal 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
11
ui/image/image.d.ts
vendored
Normal 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
36
ui/image/image.ios.ts
Normal 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
2
ui/image/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
declare var module, require;
|
||||
module.exports = require("ui/image/image");
|
@ -16,7 +16,7 @@ export class Label extends view.View {
|
||||
var extendsBody = Foundation.NSObject.extends(
|
||||
{
|
||||
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));
|
||||
}
|
||||
}, {});
|
||||
|
||||
|
Reference in New Issue
Block a user