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" });
|
||||
imageSourceProperty.register(ImageBase);
|
||||
|
||||
function onSrcPropertyChanged(image: ImageBase, oldValue: string, newValue: string) {
|
||||
image._createImageSourceFromSrc();
|
||||
};
|
||||
|
||||
export const srcProperty = new Property<ImageBase, any>({ name: "src", valueChanged: onSrcPropertyChanged });
|
||||
export const srcProperty = new Property<ImageBase, any>({ name: "src"});
|
||||
srcProperty.register(ImageBase);
|
||||
|
||||
export const loadModeProperty = new Property<ImageBase, "sync" | "async">({ name: "loadMode", defaultValue: "async" });
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, unsetValue, Color,
|
||||
ImageSource, ImageBase, stretchProperty, imageSourceProperty, srcProperty, tintColorProperty, unsetValue, Color,
|
||||
isDataURI, isFileOrResourcePath, RESOURCE_PREFIX
|
||||
} from "./image-common";
|
||||
import { path, knownFolders } from "file-system";
|
||||
@@ -38,7 +38,7 @@ export function initImageCache(context: android.content.Context, mode = CacheMod
|
||||
}
|
||||
|
||||
let params = new org.nativescript.widgets.image.Cache.CacheParams();
|
||||
params.memoryCacheEnabled = mode !== CacheMode.none;
|
||||
params.memoryCacheEnabled = mode !== CacheMode.none;
|
||||
params.setMemCacheSizePercent(memoryCacheSize); // Set memory cache to % of app memory
|
||||
params.diskCacheEnabled = mode === CacheMode.diskAndMemory;
|
||||
params.diskCacheSize = diskCacheSize;
|
||||
@@ -157,6 +157,13 @@ export class Image extends ImageBase {
|
||||
set [imageSourceProperty.native](value: ImageSource) {
|
||||
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])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, layout, Color,
|
||||
ImageSource, ImageBase, stretchProperty, imageSourceProperty, tintColorProperty, srcProperty, layout, Color,
|
||||
traceEnabled, traceWrite, traceCategories
|
||||
} from "./image-common";
|
||||
|
||||
@@ -149,4 +149,11 @@ export class Image extends ImageBase {
|
||||
set [imageSourceProperty.native](value: ImageSource) {
|
||||
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