mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Use [srcProperty.native]
This commit is contained in:
@@ -110,11 +110,7 @@ export abstract class ImageBase extends View implements ImageDefinition {
|
|||||||
export const imageSourceProperty = new Property<ImageBase, ImageSource>({ name: "imageSource" });
|
export const imageSourceProperty = new Property<ImageBase, ImageSource>({ name: "imageSource" });
|
||||||
imageSourceProperty.register(ImageBase);
|
imageSourceProperty.register(ImageBase);
|
||||||
|
|
||||||
function onSrcPropertyChanged(image: ImageBase, oldValue: string, newValue: string) {
|
export const srcProperty = new Property<ImageBase, any>({ name: "src"});
|
||||||
image._createImageSourceFromSrc();
|
|
||||||
};
|
|
||||||
|
|
||||||
export const srcProperty = new Property<ImageBase, any>({ name: "src", valueChanged: onSrcPropertyChanged });
|
|
||||||
srcProperty.register(ImageBase);
|
srcProperty.register(ImageBase);
|
||||||
|
|
||||||
export const loadModeProperty = new Property<ImageBase, "sync" | "async">({ name: "loadMode", defaultValue: "async" });
|
export const loadModeProperty = new Property<ImageBase, "sync" | "async">({ name: "loadMode", defaultValue: "async" });
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, unsetValue, Color,
|
ImageSource, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, unsetValue, Color,
|
||||||
isDataURI, isFileOrResourcePath, RESOURCE_PREFIX
|
isDataURI, isFileOrResourcePath, RESOURCE_PREFIX
|
||||||
} from "./image-common";
|
} from "./image-common";
|
||||||
import { path, knownFolders } from "file-system";
|
import { path, knownFolders } from "file-system";
|
||||||
@@ -157,6 +157,13 @@ export class Image extends ImageBase {
|
|||||||
set [imageSourceProperty.native](value: ImageSource) {
|
set [imageSourceProperty.native](value: ImageSource) {
|
||||||
this._setNativeImage(value ? value.android : null);
|
this._setNativeImage(value ? value.android : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get [srcProperty.native](): any {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
set [srcProperty.native](value: any) {
|
||||||
|
this._createImageSourceFromSrc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Interfaces([org.nativescript.widgets.image.Worker.OnImageLoadedListener])
|
@Interfaces([org.nativescript.widgets.image.Worker.OnImageLoadedListener])
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, layout, Color,
|
ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, srcProperty, layout, Color,
|
||||||
traceEnabled, traceWrite, traceCategories
|
traceEnabled, traceWrite, traceCategories
|
||||||
} from "./image-common";
|
} from "./image-common";
|
||||||
|
|
||||||
@@ -149,4 +149,11 @@ export class Image extends ImageBase {
|
|||||||
set [imageSourceProperty.native](value: ImageSource) {
|
set [imageSourceProperty.native](value: ImageSource) {
|
||||||
this._setNativeImage(value ? value.ios : null);
|
this._setNativeImage(value ? value.ios : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get [srcProperty.native](): any {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
set [srcProperty.native](value: any) {
|
||||||
|
this._createImageSourceFromSrc();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user