mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 20:11:24 +08:00
Image src and imageSource properties defined
This commit is contained in:
@ -49,7 +49,7 @@
|
|||||||
<ListView.itemTemplate>
|
<ListView.itemTemplate>
|
||||||
<GridLayout columns="auto, *">
|
<GridLayout columns="auto, *">
|
||||||
|
|
||||||
<Image url="{{ favorite ? '~/app/images/fav.png' : '~/app/images/addfav.png' }}" style.visibility="{{ canBeFavorited ? 'visible' : 'collapsed' }}"
|
<Image src="{{ favorite ? '~/app/images/fav.png' : '~/app/images/addfav.png' }}" style.visibility="{{ canBeFavorited ? 'visible' : 'collapsed' }}"
|
||||||
tap="toggleFavorite" width="32" height="32" vertical-align="center" margin="20" />
|
tap="toggleFavorite" width="32" height="32" vertical-align="center" margin="20" />
|
||||||
|
|
||||||
<StackLayout col="1">
|
<StackLayout col="1">
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<GridLayout rows="*, auto">
|
<GridLayout rows="*, auto">
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<Image source="{{ imageSource }}" stretch="aspectFill"/>
|
<Image imageSource="{{ imageSource }}" stretch="aspectFill"/>
|
||||||
<Label text="{{ title }}" cssClass="detailsTitle" textWrap="true" />
|
<Label text="{{ title }}" cssClass="detailsTitle" textWrap="true" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<ListView.itemTemplate>
|
<ListView.itemTemplate>
|
||||||
<!-- Binding in template property of an component will use the bindingContext provided by the component. -->
|
<!-- Binding in template property of an component will use the bindingContext provided by the component. -->
|
||||||
<GridLayout columns="auto, *, auto" rows="auto, 25">
|
<GridLayout columns="auto, *, auto" rows="auto, 25">
|
||||||
<Image source="{{ thumbnailImageSource || defaultThumbnailImageSource }}" cssClass="thumbnail" rowSpan="2"/>
|
<Image imageSource="{{ thumbnailImageSource || defaultThumbnailImageSource }}" cssClass="thumbnail" rowSpan="2"/>
|
||||||
<Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" col="1" colSpan="2" minHeight="50" />
|
<Label text="{{ title || 'Downloading...' }}" textWrap="true" cssClass="title" col="1" colSpan="2" minHeight="50" />
|
||||||
<Label text="{{ author ? 'by ' + author : '' }}" cssClass="author" col="1" row="1" />
|
<Label text="{{ author ? 'by ' + author : '' }}" cssClass="author" col="1" row="1" />
|
||||||
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" cssClass="comments" col="2" row="1" />
|
<Label text="{{ num_comments ? num_comments + ' comments' : '' }}" cssClass="comments" col="2" row="1" />
|
||||||
@ -20,7 +20,7 @@
|
|||||||
<TabViewItem title="About">
|
<TabViewItem title="About">
|
||||||
<TabViewItem.view>
|
<TabViewItem.view>
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<Image margin="10" url="~/app/res/telerik-logo.png" />
|
<Image margin="10" src="~/app/res/telerik-logo.png" />
|
||||||
<Label margin="10" textWrap="true" text="{{ aboutText }}" />
|
<Label margin="10" textWrap="true" text="{{ aboutText }}" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</TabViewItem.view>
|
</TabViewItem.view>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<Page loaded="pageLoaded">
|
<Page loaded="pageLoaded">
|
||||||
<Image margin="10" source="{{ imageSource }}" verticalAlignment="center" horizontalAlignment="center"/>
|
<Image margin="10" src="~/app/res/telerik-logo.png" verticalAlignment="center" horizontalAlignment="center"/>
|
||||||
</Page>
|
</Page>
|
@ -14,7 +14,7 @@ export function imageLoaded(args: observable.EventData) {
|
|||||||
var image = <imageDef.Image>args.object;
|
var image = <imageDef.Image>args.object;
|
||||||
|
|
||||||
var logoPath = fs.path.join(__dirname, "tagLine.png");
|
var logoPath = fs.path.join(__dirname, "tagLine.png");
|
||||||
image.source = imageSourceDef.fromFile(logoPath);
|
image.imageSource = imageSourceDef.fromFile(logoPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loginButtonTap(args: observable.EventData) {
|
export function loginButtonTap(args: observable.EventData) {
|
||||||
|
@ -14,7 +14,7 @@ export function createPage() {
|
|||||||
StackLayout.orientation = enums.Orientation.horizontal;
|
StackLayout.orientation = enums.Orientation.horizontal;
|
||||||
|
|
||||||
var image = new imageModule.Image();
|
var image = new imageModule.Image();
|
||||||
image.source = logoImageSource;
|
image.imageSource = logoImageSource;
|
||||||
image.width = 100;
|
image.width = 100;
|
||||||
image.stretch = enums.Stretch.aspectFit;
|
image.stretch = enums.Stretch.aspectFit;
|
||||||
StackLayout.addChild(image);
|
StackLayout.addChild(image);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
<Page>
|
<Page>
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<Label text="resource:" />
|
<Label text="resource:" />
|
||||||
<Image url="res://icon" stretch="none" horizontalAlignment="left"/>
|
<Image src="res://icon" stretch="none" horizontalAlignment="left"/>
|
||||||
|
|
||||||
<Label text="url:" />
|
<Label text="url:" />
|
||||||
<Image url="http://www.google.com/images/errors/logo_sm_2.png" stretch="none" horizontalAlignment="left"/>
|
<Image src="http://www.google.com/images/errors/logo_sm_2.png" stretch="none" horizontalAlignment="left"/>
|
||||||
|
|
||||||
<Label text="app file:" />
|
<Label text="app file:" />
|
||||||
<Image url="~/app/logo.png" stretch="none" horizontalAlignment="left" />
|
<Image src="~/app/logo.png" stretch="none" horizontalAlignment="left" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</Page>
|
</Page>
|
||||||
|
@ -9,7 +9,7 @@ import ImageModule = require("ui/image");
|
|||||||
// Binding the image source property to a view-model property.
|
// Binding the image source property to a view-model property.
|
||||||
//```XML
|
//```XML
|
||||||
// <Page>
|
// <Page>
|
||||||
// {%raw%}<Image source="{{ thumbnailImageSource }}" />{%endraw%}
|
// {%raw%}<Image src="{{ thumbnailImageUrl }}" />{%endraw%}
|
||||||
// </Page>
|
// </Page>
|
||||||
//```
|
//```
|
||||||
|
|
||||||
@ -26,7 +26,8 @@ var imagePath = __dirname + "../../logo.png";
|
|||||||
|
|
||||||
export var test_Image_Members = function () {
|
export var test_Image_Members = function () {
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
TKUnit.assert(types.isDefined(image.url), "Image.url is not defined");
|
TKUnit.assert(types.isDefined(image.src), "Image.src is not defined");
|
||||||
|
TKUnit.assert(types.isDefined(image.imageSource), "Image.imageSource is not defined");
|
||||||
TKUnit.assert(types.isDefined(image.isLoading), "Image.isLoading is not defined");
|
TKUnit.assert(types.isDefined(image.isLoading), "Image.isLoading is not defined");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ export var test_settingImageSource = function () {
|
|||||||
// ### How to create an image and set its source.
|
// ### How to create an image and set its source.
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.source = ImageSourceModule.fromResource("logo");
|
image.imageSource = ImageSourceModule.fromResource("logo");
|
||||||
// ```
|
// ```
|
||||||
// </snippet>
|
// </snippet>
|
||||||
|
|
||||||
@ -55,12 +56,12 @@ export var test_settingImageSource = function () {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export var test_SettingImageUrl = function (done) {
|
export var test_SettingImageSrc = function (done) {
|
||||||
// <snippet module="ui/image" title="Image">
|
// <snippet module="ui/image" title="Image">
|
||||||
// ### How to create an image and set its url.
|
// ### How to create an image and set its src.
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.url = "https://www.google.bg/images/srpr/logo11w.png";
|
image.src = "https://www.google.bg/images/srpr/logo11w.png";
|
||||||
// ```
|
// ```
|
||||||
// </snippet>
|
// </snippet>
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ export var test_SettingImageUrl = function (done) {
|
|||||||
|
|
||||||
var testFunc = function (views: Array<ViewModule.View>) {
|
var testFunc = function (views: Array<ViewModule.View>) {
|
||||||
var testImage = <ImageModule.Image> views[0];
|
var testImage = <ImageModule.Image> views[0];
|
||||||
imageIsLoaded = !!testImage.source;
|
imageIsLoaded = !!testImage.imageSource;
|
||||||
try {
|
try {
|
||||||
TKUnit.assert(testModel.get("imageIsLoading") === false, "Expected: false, Actual: " + testModel.get("imageIsLoading"));
|
TKUnit.assert(testModel.get("imageIsLoading") === false, "Expected: false, Actual: " + testModel.get("imageIsLoading"));
|
||||||
TKUnit.assert(imageIsLoaded === true, "Expected: true, Actual: " + imageIsLoaded);
|
TKUnit.assert(imageIsLoaded === true, "Expected: true, Actual: " + imageIsLoaded);
|
||||||
@ -92,12 +93,12 @@ export var test_SettingImageUrl = function (done) {
|
|||||||
setTimeout(() => { helper.buildUIAndRunTest(image, testFunc) }, 3000);
|
setTimeout(() => { helper.buildUIAndRunTest(image, testFunc) }, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
export var test_SettingImageUrlToFileWithinApp = function (done) {
|
export var test_SettingImageSrcToFileWithinApp = function (done) {
|
||||||
// <snippet module="ui/image" title="Image">
|
// <snippet module="ui/image" title="Image">
|
||||||
// ### How to create an image and set its url to file within the application.
|
// ### How to create an image and set its src to file within the application.
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.url = "~/app/logo.png";
|
image.src = "~/app/logo.png";
|
||||||
// ```
|
// ```
|
||||||
// </snippet>
|
// </snippet>
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ export var test_SettingImageUrlToFileWithinApp = function (done) {
|
|||||||
|
|
||||||
var testFunc = function (views: Array<ViewModule.View>) {
|
var testFunc = function (views: Array<ViewModule.View>) {
|
||||||
var testImage = <ImageModule.Image> views[0];
|
var testImage = <ImageModule.Image> views[0];
|
||||||
imageIsLoaded = !!testImage.source;
|
imageIsLoaded = !!testImage.imageSource;
|
||||||
try {
|
try {
|
||||||
TKUnit.assert(imageIsLoaded === true, "Expected: true, Actual: " + imageIsLoaded);
|
TKUnit.assert(imageIsLoaded === true, "Expected: true, Actual: " + imageIsLoaded);
|
||||||
done(null);
|
done(null);
|
||||||
@ -124,7 +125,7 @@ export var test_SettingStretch_AspectFit = function () {
|
|||||||
// ### How to set image stretching.
|
// ### How to set image stretching.
|
||||||
// ``` JavaScript
|
// ``` JavaScript
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.source = ImageSourceModule.fromFile(imagePath);
|
image.imageSource = ImageSourceModule.fromFile(imagePath);
|
||||||
//// There are 4 modes of stretching none, fill, aspectFill, aspectFit
|
//// There are 4 modes of stretching none, fill, aspectFill, aspectFit
|
||||||
//// The default value is aspectFit.
|
//// The default value is aspectFit.
|
||||||
//// Image stretch can be set by using ImageModule.stretch enum.
|
//// Image stretch can be set by using ImageModule.stretch enum.
|
||||||
@ -152,7 +153,7 @@ export var test_SettingStretch_AspectFit = function () {
|
|||||||
|
|
||||||
export var test_SettingStretch_Default = function () {
|
export var test_SettingStretch_Default = function () {
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.source = ImageSourceModule.fromFile(imagePath);
|
image.imageSource = ImageSourceModule.fromFile(imagePath);
|
||||||
|
|
||||||
var testFunc = function (views: Array<ViewModule.View>) {
|
var testFunc = function (views: Array<ViewModule.View>) {
|
||||||
var testImage = <ImageModule.Image> views[0];
|
var testImage = <ImageModule.Image> views[0];
|
||||||
@ -174,7 +175,7 @@ export var test_SettingStretch_Default = function () {
|
|||||||
|
|
||||||
export var test_SettingStretch_AspectFill = function () {
|
export var test_SettingStretch_AspectFill = function () {
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.source = ImageSourceModule.fromFile(imagePath);
|
image.imageSource = ImageSourceModule.fromFile(imagePath);
|
||||||
image.stretch = enumsModule.Stretch.aspectFill;
|
image.stretch = enumsModule.Stretch.aspectFill;
|
||||||
|
|
||||||
var testFunc = function (views: Array<ViewModule.View>) {
|
var testFunc = function (views: Array<ViewModule.View>) {
|
||||||
@ -197,7 +198,7 @@ export var test_SettingStretch_AspectFill = function () {
|
|||||||
|
|
||||||
export var test_SettingStretch_Fill = function () {
|
export var test_SettingStretch_Fill = function () {
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.source = ImageSourceModule.fromFile(imagePath);
|
image.imageSource = ImageSourceModule.fromFile(imagePath);
|
||||||
image.stretch = enumsModule.Stretch.fill;
|
image.stretch = enumsModule.Stretch.fill;
|
||||||
|
|
||||||
var testFunc = function (views: Array<ViewModule.View>) {
|
var testFunc = function (views: Array<ViewModule.View>) {
|
||||||
@ -220,7 +221,7 @@ export var test_SettingStretch_Fill = function () {
|
|||||||
|
|
||||||
export var test_SettingStretch_none = function () {
|
export var test_SettingStretch_none = function () {
|
||||||
var image = new ImageModule.Image();
|
var image = new ImageModule.Image();
|
||||||
image.source = ImageSourceModule.fromFile(imagePath);
|
image.imageSource = ImageSourceModule.fromFile(imagePath);
|
||||||
image.stretch = enumsModule.Stretch.none;
|
image.stretch = enumsModule.Stretch.none;
|
||||||
|
|
||||||
var testFunc = function (views: Array<ViewModule.View>) {
|
var testFunc = function (views: Array<ViewModule.View>) {
|
||||||
|
@ -17,7 +17,7 @@ import scrollViewModule = require("ui/scroll-view");
|
|||||||
//```XML
|
//```XML
|
||||||
// <Page>
|
// <Page>
|
||||||
// <ScrollView>
|
// <ScrollView>
|
||||||
// {%raw%}<Image source="{{ someBigImage }}" />{%endraw%}
|
// {%raw%}<Image src="{{ someBigImageUrl }}" />{%endraw%}
|
||||||
// </ScrollView>
|
// </ScrollView>
|
||||||
// </Page>
|
// </Page>
|
||||||
//```
|
//```
|
||||||
|
@ -61,6 +61,6 @@ export function setPicture(args: observable.EventData) {
|
|||||||
var img = parent.getViewById<image.Image>("cameraImage");
|
var img = parent.getViewById<image.Image>("cameraImage");
|
||||||
|
|
||||||
camera.takePicture().then(r=> {
|
camera.takePicture().then(r=> {
|
||||||
img.source = r;
|
img.imageSource = r;
|
||||||
}).catch(e => dialogs.alert("ERROR: " + e));
|
}).catch(e => dialogs.alert("ERROR: " + e));
|
||||||
}
|
}
|
@ -6,9 +6,11 @@ import definition = require("ui/image");
|
|||||||
import trace = require("trace");
|
import trace = require("trace");
|
||||||
import enums = require("ui/enums");
|
import enums = require("ui/enums");
|
||||||
import utils = require("utils/utils");
|
import utils = require("utils/utils");
|
||||||
|
import types = require("utils/types");
|
||||||
|
|
||||||
|
var SRC = "src";
|
||||||
|
var IMAGE_SOURCE = "imageSource";
|
||||||
|
|
||||||
var SOURCE = "source";
|
|
||||||
var URL = "url";
|
|
||||||
var IMAGE = "Image";
|
var IMAGE = "Image";
|
||||||
var ISLOADING = "isLoading";
|
var ISLOADING = "isLoading";
|
||||||
var STRETCH = "stretch";
|
var STRETCH = "stretch";
|
||||||
@ -27,54 +29,62 @@ function isAppFile(value: string): boolean {
|
|||||||
return value.indexOf("~/") === 0;
|
return value.indexOf("~/") === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidUrl(url: string): boolean {
|
function isValidUrl(url: any): boolean {
|
||||||
|
if (!types.isString(url)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var value = url ? url.trim() : "";
|
var value = url ? url.trim() : "";
|
||||||
return value !== "" && (isResource(value) || isAppFile(value) || isUrl(value));
|
return value !== "" && (isResource(value) || isAppFile(value) || isUrl(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUrlPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
function onSrcPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
var image = <Image>data.object;
|
var image = <Image>data.object;
|
||||||
var value: string = data.newValue;
|
var value = data.newValue;
|
||||||
|
|
||||||
if (isValidUrl(value)) {
|
if (isValidUrl(value)) {
|
||||||
value = value.trim();
|
value = value.trim();
|
||||||
image.source = null;
|
image.imageSource = null;
|
||||||
image["_url"] = value;
|
image["_url"] = value;
|
||||||
|
|
||||||
image._setValue(Image.isLoadingProperty, true);
|
image._setValue(Image.isLoadingProperty, true);
|
||||||
|
|
||||||
if (isResource(value)) {
|
if (isResource(value)) {
|
||||||
image.source = imageSource.fromResource(value.substr(RESOURCE_PREFIX.length));
|
image.imageSource = imageSource.fromResource(value.substr(RESOURCE_PREFIX.length));
|
||||||
image._setValue(Image.isLoadingProperty, false);
|
image._setValue(Image.isLoadingProperty, false);
|
||||||
}
|
}
|
||||||
else if (isAppFile(value)) {
|
else if (isAppFile(value)) {
|
||||||
image.source = imageSource.fromFile(value);
|
image.imageSource = imageSource.fromFile(value);
|
||||||
image._setValue(Image.isLoadingProperty, false);
|
image._setValue(Image.isLoadingProperty, false);
|
||||||
} else {
|
} else {
|
||||||
imageSource.fromUrl(value).then((r) => {
|
imageSource.fromUrl(value).then((r) => {
|
||||||
if (image["_url"] === value) {
|
if (image["_url"] === value) {
|
||||||
image.source = r;
|
image.imageSource = r;
|
||||||
image._setValue(Image.isLoadingProperty, false);
|
image._setValue(Image.isLoadingProperty, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (value instanceof imageSource.ImageSource) {
|
||||||
|
// Support binding the iamgeSource trough the src propoerty
|
||||||
|
image.imageSource = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Image extends view.View implements definition.Image {
|
export class Image extends view.View implements definition.Image {
|
||||||
|
|
||||||
public static urlProperty = new dependencyObservable.Property(
|
public static srcProperty = new dependencyObservable.Property(
|
||||||
URL,
|
SRC,
|
||||||
IMAGE,
|
IMAGE,
|
||||||
new proxy.PropertyMetadata(
|
new proxy.PropertyMetadata(
|
||||||
"",
|
"",
|
||||||
dependencyObservable.PropertyMetadataSettings.None,
|
dependencyObservable.PropertyMetadataSettings.None,
|
||||||
onUrlPropertyChanged
|
onSrcPropertyChanged
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
public static sourceProperty = new dependencyObservable.Property(
|
public static imageSourceProperty = new dependencyObservable.Property(
|
||||||
SOURCE,
|
IMAGE_SOURCE,
|
||||||
IMAGE,
|
IMAGE,
|
||||||
new proxy.PropertyMetadata(
|
new proxy.PropertyMetadata(
|
||||||
undefined,
|
undefined,
|
||||||
@ -104,18 +114,18 @@ export class Image extends view.View implements definition.Image {
|
|||||||
super(options);
|
super(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
get source(): imageSource.ImageSource {
|
get imageSource(): imageSource.ImageSource {
|
||||||
return this._getValue(Image.sourceProperty);
|
return this._getValue(Image.imageSourceProperty);
|
||||||
}
|
}
|
||||||
set source(value: imageSource.ImageSource) {
|
set imageSource(value: imageSource.ImageSource) {
|
||||||
this._setValue(Image.sourceProperty, value);
|
this._setValue(Image.imageSourceProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get url(): string {
|
get src(): string {
|
||||||
return this._getValue(Image.urlProperty);
|
return this._getValue(Image.srcProperty);
|
||||||
}
|
}
|
||||||
set url(value: string) {
|
set src(value: string) {
|
||||||
this._setValue(Image.urlProperty, value);
|
this._setValue(Image.srcProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isLoading(): boolean {
|
get isLoading(): boolean {
|
||||||
@ -139,8 +149,8 @@ export class Image extends view.View implements definition.Image {
|
|||||||
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
var heightMode = utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
||||||
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
trace.write(this + " :onMeasure: " + utils.layout.getMode(widthMode) + " " + width + ", " + utils.layout.getMode(heightMode) + " " + height, trace.categories.Layout);
|
||||||
|
|
||||||
var nativeWidth = this.source ? this.source.width : 0;
|
var nativeWidth = this.imageSource ? this.imageSource.width : 0;
|
||||||
var nativeHeight = this.source ? this.source.height : 0;
|
var nativeHeight = this.imageSource ? this.imageSource.height : 0;
|
||||||
|
|
||||||
var measureWidth = Math.max(nativeWidth, this.minWidth);
|
var measureWidth = Math.max(nativeWidth, this.minWidth);
|
||||||
var measureHeight = Math.max(nativeHeight, this.minHeight);
|
var measureHeight = Math.max(nativeHeight, this.minHeight);
|
||||||
|
@ -30,7 +30,7 @@ function onStretchPropertyChanged(data: dependencyObservable.PropertyChangeData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSourcePropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
function onImageSourcePropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
var image = <Image>data.object;
|
var image = <Image>data.object;
|
||||||
if (!image.android) {
|
if (!image.android) {
|
||||||
return;
|
return;
|
||||||
@ -42,7 +42,7 @@ function onSourcePropertyChanged(data: dependencyObservable.PropertyChangeData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// register the setNativeValue callback
|
// register the setNativeValue callback
|
||||||
(<proxy.PropertyMetadata>imageCommon.Image.sourceProperty.metadata).onSetNativeValue = onSourcePropertyChanged;
|
(<proxy.PropertyMetadata>imageCommon.Image.imageSourceProperty.metadata).onSetNativeValue = onImageSourcePropertyChanged;
|
||||||
(<proxy.PropertyMetadata>imageCommon.Image.stretchProperty.metadata).onSetNativeValue = onStretchPropertyChanged;
|
(<proxy.PropertyMetadata>imageCommon.Image.stretchProperty.metadata).onSetNativeValue = onStretchPropertyChanged;
|
||||||
|
|
||||||
export class Image extends imageCommon.Image {
|
export class Image extends imageCommon.Image {
|
||||||
|
4
ui/image/image.d.ts
vendored
4
ui/image/image.d.ts
vendored
@ -28,12 +28,12 @@ declare module "ui/image" {
|
|||||||
/**
|
/**
|
||||||
* Gets or sets the image source of the image.
|
* Gets or sets the image source of the image.
|
||||||
*/
|
*/
|
||||||
source: imageSource.ImageSource;
|
imageSource: imageSource.ImageSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets or sets the URL of the image.
|
* Gets or sets the URL of the image.
|
||||||
*/
|
*/
|
||||||
url: string;
|
src: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a value indicating if the image is currently loading
|
* Gets a value indicating if the image is currently loading
|
||||||
|
@ -28,7 +28,7 @@ function onStretchPropertyChanged(data: dependencyObservable.PropertyChangeData)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSourcePropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
function onImageSourcePropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
var image = <Image>data.object;
|
var image = <Image>data.object;
|
||||||
image.ios.image = data.newValue ? data.newValue.ios : null;
|
image.ios.image = data.newValue ? data.newValue.ios : null;
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ function onSourcePropertyChanged(data: dependencyObservable.PropertyChangeData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// register the setNativeValue callback
|
// register the setNativeValue callback
|
||||||
|
(<proxy.PropertyMetadata>imageCommon.Image.imageSourceProperty.metadata).onSetNativeValue = onImageSourcePropertyChanged;
|
||||||
(<proxy.PropertyMetadata>imageCommon.Image.stretchProperty.metadata).onSetNativeValue = onStretchPropertyChanged;
|
(<proxy.PropertyMetadata>imageCommon.Image.stretchProperty.metadata).onSetNativeValue = onStretchPropertyChanged;
|
||||||
(<proxy.PropertyMetadata>imageCommon.Image.sourceProperty.metadata).onSetNativeValue = onSourcePropertyChanged;
|
|
||||||
|
|
||||||
export class Image extends imageCommon.Image {
|
export class Image extends imageCommon.Image {
|
||||||
private _ios: UIImageView;
|
private _ios: UIImageView;
|
||||||
|
Reference in New Issue
Block a user