@nativescript-community/ui-image 4.1.6 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +354 -286
- package/angular/directives.d.ts +2 -2
- package/angular/esm2020/directives.mjs +15 -0
- package/angular/esm2020/index.mjs +2 -0
- package/angular/esm2020/module.mjs +22 -0
- package/angular/esm2020/nativescript-community-ui-image-angular.mjs +2 -0
- package/angular/fesm2015/nativescript-community-ui-image-angular.mjs +39 -0
- package/angular/fesm2020/nativescript-community-ui-image-angular.mjs +35 -0
- package/angular/module.d.ts +3 -3
- package/angular/package.json +22 -8
- package/blueprint.md +561 -0
- package/{image-common.d.ts → index-common.d.ts} +1 -0
- package/{image-common.js → index-common.js} +28 -7
- package/{image.android.d.ts → index.android.d.ts} +3 -2
- package/{image.android.js → index.android.js} +34 -30
- package/{image.d.ts → index.d.ts} +4 -4
- package/{image.ios.d.ts → index.ios.d.ts} +3 -2
- package/{image.ios.js → index.ios.js} +23 -19
- package/package.json +12 -4
- package/platforms/android/include.gradle +5 -6
- package/platforms/android/ui_image.aar +0 -0
- package/platforms/ios/Podfile +1 -1
- package/vue/index.js +1 -1
- package/angular/bundles/nativescript-community-ui-image-angular.umd.js +0 -49
- package/angular/bundles/nativescript-community-ui-image-angular.umd.min.js +0 -2
- package/angular/esm2015/directives.js +0 -15
- package/angular/esm2015/index.js +0 -2
- package/angular/esm2015/module.js +0 -21
- package/angular/esm2015/nativescript-community-ui-image-angular.js +0 -2
- package/angular/fesm2015/nativescript-community-ui-image-angular.js +0 -33
- package/image-common.metadata.json +0 -1
- package/image.android.metadata.json +0 -1
- package/image.ios.metadata.json +0 -1
package/README.md
CHANGED
@@ -1,47 +1,78 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
1
|
+
<!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️-->
|
2
|
+
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
3
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
4
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
5
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
6
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
7
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
8
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
9
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
10
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
11
|
+
DO NOT EDIT THIS READEME DIRECTLY! Edit "bluesprint.md" instead.
|
12
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
13
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
14
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
15
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
16
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
17
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
18
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
19
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
20
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
21
|
+
<h1 align="center">@nativescript-community/ui-image</h1>
|
22
|
+
<p align="center">
|
23
|
+
<a href="https://npmcharts.com/compare/@nativescript-community/ui-image?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/@nativescript-community/ui-image.svg" height="20"/></a>
|
24
|
+
<a href="https://www.npmjs.com/package/@nativescript-community/ui-image"><img alt="NPM Version" src="https://img.shields.io/npm/v/@nativescript-community/ui-image.svg" height="20"/></a>
|
25
|
+
</p>
|
26
|
+
|
27
|
+
<p align="center">
|
28
|
+
<b>Advanced and efficient image display plugin which uses Fresco (Android) and SDWebImage (iOS) to implement caching, placeholders, image effects, and much more.</b></br>
|
29
|
+
<sub><sub>
|
30
|
+
</p>
|
31
|
+
|
32
|
+
<br />
|
33
|
+
|
34
|
+
|
35
|
+
| <img src="https://github.com/nativescript-community/ui-image/raw/master/images/demo-ios.gif" height="500" /> | <img src="https://github.com/nativescript-community/ui-image/raw/master/images/demo-android.gif" height="500" /> |
|
36
|
+
| --- | ----------- |
|
37
|
+
| iOS Demo | Android Demo |
|
38
|
+
|
39
|
+
|
40
|
+
[](#table-of-contents)
|
41
|
+
|
42
|
+
## Table of Contents
|
43
|
+
|
44
|
+
* [Installation](#installation)
|
45
|
+
* [setup](#setup)
|
46
|
+
* [API](#api)
|
47
|
+
* [Events](#events)
|
48
|
+
* [Event arguments](#event-arguments)
|
49
|
+
* [Properties](#properties)
|
50
|
+
* [Advanced *optional* attributes](#advanced-optional-attributes)
|
51
|
+
* [Cache](#cache)
|
52
|
+
* ['Refresh' the 'src'](#refresh-the-src)
|
53
|
+
* [Clear everything from the cache](#clear-everything-from-the-cache)
|
54
|
+
* [Evict all images with a specific URI from the cache](#evict-all-images-with-a-specific-uri-from-the-cache)
|
55
|
+
* [Manually shut down the native imageModule library](#manually-shut-down-the-native-imagemodule-library)
|
56
|
+
* [Flavors](#flavors)
|
57
|
+
* [Demos](#demos)
|
58
|
+
* [Demos and Development](#demos-and-development)
|
59
|
+
* [Setup](#setup)
|
60
|
+
* [Build](#build)
|
61
|
+
* [Demos](#demos-1)
|
62
|
+
* [Questions](#questions)
|
63
|
+
|
64
|
+
|
65
|
+
[](#installation)
|
66
|
+
|
67
|
+
## Installation
|
68
|
+
Run the following command from the root of your project:
|
69
|
+
|
70
|
+
`ns plugin add @nativescript-community/ui-image`
|
71
|
+
|
72
|
+
|
73
|
+
[](#setup)
|
74
|
+
|
75
|
+
## setup
|
45
76
|
|
46
77
|
```javascript
|
47
78
|
import imageModule = require("@nativescript-community/ui-image");
|
@@ -50,234 +81,14 @@ import imageModule = require("@nativescript-community/ui-image");
|
|
50
81
|
imageModule.initialize({ isDownsampleEnabled: true });
|
51
82
|
```
|
52
83
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
<Page
|
58
|
-
xmlns="http://www.nativescript.org/tns.xsd"
|
59
|
-
xmlns:@nativescript-community/ui-image="@nativescript-community/ui-image">
|
60
|
-
<@nativescript-community/ui-image:Img width="250" height="250"
|
61
|
-
src="<uri-to-a-photo-from-the-web-or-a-local-resource>"/>
|
62
|
-
</Page>
|
63
|
-
```
|
64
|
-
|
65
|
-
### In NativeScript + Angular 2
|
66
|
-
|
67
|
-
1. Import the `TNSImageModule` from `@nativescript-community/ui-image/angular` and add it to the `imports` of your initial `@NgModule`, like shown [here](https://github.com/nativescript-community/ui-image/blob/master/demo-angular/app/app.module.ts).
|
68
|
-
2. As described above make sure to initialize the `@nativescript-community/ui-image` plugin in the `launch` event of your {N} application.
|
69
|
-
|
70
|
-
## Examples
|
71
|
-
You can refer the [demo-angular](https://github.com/nativescript-community/ui-image/tree/master/demo-angular) folder of the repo for runnable {N} project that demonstrates the @nativescript-community/ui-image plugin with all of its features in action.
|
72
|
-
|
73
|
-
## Features
|
74
|
-
|
75
|
-
### Basic attributes
|
76
|
-
|
77
|
-
- **src**
|
78
|
-
|
79
|
-
String value used for the image URI. You can use this property to set the image to be loaded from remote location (http, https), from the resources and local files of your {N} application.
|
80
|
-
|
81
|
-
```xml
|
82
|
-
<@nativescript-community/ui-image:Img src="https://docs.nativescript.org/angular/img/cli-getting-started/angular/chapter0/NativeScript_logo.png"/>
|
83
|
-
```
|
84
|
-
|
85
|
-
- **placeholderImageUri**
|
86
|
-
|
87
|
-
String value used for the placeholder image URI. You can use this property to set a placeholder image loaded from the local and resources files of your {N} application.
|
88
|
-
|
89
|
-
**Note: Currently there are limitations on how many different Images can be set to as 'placeholderImage' before OutOfMemoryError is thrown. For best results its recommended to use a single image for all ```placeholderImageUri``` of your Img instances.*
|
90
|
-
|
91
|
-
```xml
|
92
|
-
<@nativescript-community/ui-image:Img placeholderImageUri="~/placeholder.jpg"/>
|
93
|
-
```
|
94
|
-
|
95
|
-
- **failureImageUri**
|
96
|
-
|
97
|
-
String value used for the failure image URI. You can use this property to set a failure image loaded from the local and resources files of your {N} application that will be shown if the loading of the src is not successful.
|
98
|
-
|
99
|
-
```xml
|
100
|
-
<@nativescript-community/ui-image:Img failureImageUri="~/failure.jpg"/>
|
101
|
-
```
|
102
|
-
|
103
|
-
|
104
|
-
### Advanced *optional* attributes
|
105
|
-
|
106
|
-
There are a couple of *optional* attributes that could be set on the Img instance to achieve advanced behaviors:
|
107
|
-
|
108
|
-
- **backgroundUri** (Android only)
|
109
|
-
|
110
|
-
String value used for the background image URI. Using this property has similar effect as the placeholderImageUri but the image is stretched to the size of the Img.
|
111
|
-
|
112
|
-
**Note: Currently there are limitations on how many different Images can be set to as 'background' before OutOfMemoryError is thrown. For best results its recommended to use a single image for all ```backgroundUri``` of your Img instances.*
|
113
|
-
|
114
|
-
```xml
|
115
|
-
<@nativescript-community/ui-image:Img backgroundUri="~/image.jpg"/>
|
116
|
-
```
|
117
|
-
|
118
|
-
- **stretch**
|
119
|
-
|
120
|
-
String value used by Img image scale type. This property can be set to:
|
121
|
-
|
122
|
-
'*center*' - Performs no scaling.
|
123
|
-
|
124
|
-
'*centerCrop*' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
|
125
|
-
|
126
|
-
'*centerInside*' - Scales the child so that it fits entirely inside the parent.
|
127
|
-
|
128
|
-
'*fitCenter*' - Scales the child so that it fits entirely inside the parent.
|
129
|
-
|
130
|
-
'*aspectFit*' - Scales the child so that it fits entirely inside the parent.
|
131
|
-
|
132
|
-
'*fitStart*' - Scales the child so that it fits entirely inside the parent.
|
133
|
-
|
134
|
-
'*fitEnd*' - Scales the child so that it fits entirely inside the parent.
|
135
|
-
|
136
|
-
'*fitXY*' - Scales width and height independently, so that the child matches the parent exactly.
|
137
|
-
|
138
|
-
'*fill*' - Scales width and height independently, so that the child matches the parent exactly.
|
139
|
-
|
140
|
-
'*focusCrop*' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
|
141
|
-
|
142
|
-
'*aspectFill*' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
|
143
|
-
|
144
|
-
|
145
|
-
```xml
|
146
|
-
<@nativescript-community/ui-image:Img stretch="centerInside"/>
|
147
|
-
```
|
148
|
-
|
149
|
-
- **fadeDuration**
|
150
|
-
|
151
|
-
Number value used for the fade-in duration. This value is in milliseconds.
|
152
|
-
|
153
|
-
```xml
|
154
|
-
<@nativescript-community/ui-image:Img fadeDuration="3000"/>
|
155
|
-
```
|
156
|
-
|
157
|
-
- **blurRadius**
|
158
|
-
|
159
|
-
Number value greater than zero, used as input for the blur function. Larger value means slower processing. For example a value of `10` means that each pixel in the image will be blurred using all adjacent pixels up to a distance of 10.
|
160
|
-
|
161
|
-
```xml
|
162
|
-
<@nativescript-community/ui-image:Img blurRadius="25"/>
|
163
|
-
```
|
164
|
-
|
165
|
-
- **blurDownSampling** (Android only)
|
166
|
-
|
167
|
-
Number value greater than zero, used to scale the image before applying the blur function. Larger value means faster processing. For example a value of `2` means that the image will be scaled by a factor of two before applying blur.
|
168
|
-
|
169
|
-
```xml
|
170
|
-
<@nativescript-community/ui-image:Img blurDownSampling="2"/>
|
171
|
-
```
|
172
|
-
|
173
|
-
- **aspectRatio**
|
174
|
-
|
175
|
-
Number value used as the aspect ratio of the image. This property is useful when you are working with different aspect ratio images and want to have a fixed Width or Height. The ratio of an image is calculated by dividing its width by its height.
|
176
|
-
|
177
|
-
*Note: In some layout scenarios it is necessary to set the ```verticalAlignment``` of the Img to 'top' or 'bottom' in order to "anchor" the img and achieve dynamic sizing.*
|
178
|
-
|
179
|
-
```xml
|
180
|
-
<@nativescript-community/ui-image:Img aspectRatio="1.33" verticalAlignment="top"/>
|
181
|
-
```
|
182
|
-
|
183
|
-
- **decodeWidth** (downsampling) - make sure to enable downsample (**isDownsampleEnabled**) in the initialize function of the plugin otherwise this property is disregarded.
|
184
|
-
|
185
|
-
Number value used as the downsampled width of the imageModule drawable.
|
186
|
-
|
187
|
-
```xml
|
188
|
-
<@nativescript-community/ui-image:Img decodeWidth="100"/>
|
189
|
-
```
|
190
|
-
|
191
|
-
- **decodeHeight** (downsampling) - make sure to enable downsample (**isDownsampleEnabled**) in the initialize function of the plugin otherwise this property is disregarded.
|
192
|
-
|
193
|
-
Number value used as the downsampled width of the imageModule drawable.
|
194
|
-
|
195
|
-
```xml
|
196
|
-
<@nativescript-community/ui-image:Img decodeHeight="100"/>
|
197
|
-
```
|
198
|
-
|
199
|
-
|
200
|
-
- **progressiveRenderingEnabled**
|
201
|
-
|
202
|
-
Boolean value used for enabling or disabling the streaming of progressive JPEG images. This property is set to 'false' by default. Setting this property to 'true' while loading JPEG images not encoded in progressive format will lead to a standard loading of those images.
|
203
|
-
|
204
|
-
```xml
|
205
|
-
<@nativescript-community/ui-image:Img progressiveRenderingEnabled="true"/>
|
206
|
-
```
|
207
|
-
|
208
|
-
- **showProgressBar** (Android only)
|
209
|
-
|
210
|
-
Boolean value used for showing or hiding the progress bar.
|
211
|
-
|
212
|
-
```xml
|
213
|
-
<@nativescript-community/ui-image:Img showProgressBar="true"/>
|
214
|
-
```
|
215
|
-
|
216
|
-
- **progressBarColor** (Android only)
|
217
|
-
|
218
|
-
String value used for setting the color of the progress bar. You can set it to hex values ("*#FF0000*") and/or predefined colors ("*green*").
|
219
|
-
|
220
|
-
```xml
|
221
|
-
<@nativescript-community/ui-image:Img progressBarColor="blue"/>
|
222
|
-
```
|
223
|
-
|
224
|
-
- **roundAsCircle**
|
225
|
-
|
226
|
-
Boolean value used for determining if the image will be rounded as a circle. Its default value is false. If set to true the image will be rounder to a circle.
|
227
|
-
|
228
|
-
```xml
|
229
|
-
<@nativescript-community/ui-image:Img roundAsCircle="true"/>
|
230
|
-
```
|
231
|
-
|
232
|
-
- **roundTopLeftRadius**
|
233
|
-
|
234
|
-
Radius of the Top Left corner in
|
235
|
-
|
236
|
-
```xml
|
237
|
-
<@nativescript-community/ui-image:Img roundTopLeftRadius="50"/>
|
238
|
-
```
|
239
|
-
|
240
|
-
- **roundTopRightRadius**
|
241
|
-
|
242
|
-
Radius of the Top Right corner in
|
243
|
-
|
244
|
-
```xml
|
245
|
-
<@nativescript-community/ui-image:Img roundTopRightRadius="50"/>
|
246
|
-
```
|
247
|
-
- **roundBottomLeftRadius**
|
248
|
-
|
249
|
-
Radius of the Bottom Left corner in
|
250
|
-
|
251
|
-
```xml
|
252
|
-
<@nativescript-community/ui-image:Img roundBottomLeftRadius="50"/>
|
253
|
-
```
|
254
|
-
- **roundBottomRightRadius**
|
255
|
-
|
256
|
-
Radius of the Bottom Right corner in
|
257
|
-
|
258
|
-
```xml
|
259
|
-
<@nativescript-community/ui-image:Img roundBottomRightRadius="50"/>
|
260
|
-
```
|
261
|
-
|
262
|
-
- **autoPlayAnimations**
|
263
|
-
|
264
|
-
Boolean value used for enabling the automatic playing of animated images. Note that rounding of such images is not supported and will be ignored.
|
265
|
-
|
266
|
-
```xml
|
267
|
-
<@nativescript-community/ui-image:Img autoPlayAnimations="true"/>
|
268
|
-
```
|
269
|
-
|
270
|
-
- **tapToRetryEnabled** (Android only)
|
271
|
-
|
272
|
-
Boolean value used for enabling/disabling a tap to retry action for the download of the Img image.
|
273
|
-
|
274
|
-
```xml
|
275
|
-
<@nativescript-community/ui-image:Img tapToRetryEnabled="true"/>
|
276
|
-
```
|
84
|
+
|
85
|
+
[](#api)
|
86
|
+
|
87
|
+
## API
|
277
88
|
|
278
89
|
### Events
|
279
90
|
|
280
|
-
|
91
|
+
**finalImageSet** - arguments *FinalEventData*
|
281
92
|
|
282
93
|
This event is fired after the final image has been set. When working with animated images you could use this event to start the animation by calling the *FinalEventData.animatable.start()* function.
|
283
94
|
|
@@ -442,10 +253,6 @@ export function onRelease(args: EventData) {
|
|
442
253
|
|
443
254
|
#### Event arguments
|
444
255
|
|
445
|
-
All events exposed by '@nativescript-community/ui-image' provide additional information to their handlers that is needed to properly handle them. Here's a brief description of the event arguments coming with each of the events:
|
446
|
-
|
447
|
-
- **FinalEventData**
|
448
|
-
|
449
256
|
Instances of this class are provided to the handlers of the *finalImageSet*.
|
450
257
|
|
451
258
|
```typescript
|
@@ -501,6 +308,210 @@ export function onSubmit(args: EventData) {
|
|
501
308
|
}
|
502
309
|
```
|
503
310
|
|
311
|
+
|
312
|
+
### Properties
|
313
|
+
|
314
|
+
- **src**
|
315
|
+
|
316
|
+
String value used for the image URI. You can use this property to set the image to be loaded from remote location (http, https), from the resources and local files of your {N} application.
|
317
|
+
|
318
|
+
```xml
|
319
|
+
<@nativescript-community/ui-image:Img src="https://docs.nativescript.org/angular/img/cli-getting-started/angular/chapter0/NativeScript_logo.png"/>
|
320
|
+
```
|
321
|
+
|
322
|
+
- **placeholderImageUri**
|
323
|
+
|
324
|
+
String value used for the placeholder image URI. You can use this property to set a placeholder image loaded from the local and resources files of your {N} application.
|
325
|
+
|
326
|
+
**Note: Currently there are limitations on how many different Images can be set to as 'placeholderImage' before OutOfMemoryError is thrown. For best results its recommended to use a single image for all ```placeholderImageUri``` of your Img instances.*
|
327
|
+
|
328
|
+
```xml
|
329
|
+
<@nativescript-community/ui-image:Img placeholderImageUri="~/placeholder.jpg"/>
|
330
|
+
```
|
331
|
+
|
332
|
+
- **failureImageUri**
|
333
|
+
|
334
|
+
String value used for the failure image URI. You can use this property to set a failure image loaded from the local and resources files of your {N} application that will be shown if the loading of the src is not successful.
|
335
|
+
|
336
|
+
```xml
|
337
|
+
<@nativescript-community/ui-image:Img failureImageUri="~/failure.jpg"/>
|
338
|
+
```
|
339
|
+
|
340
|
+
|
341
|
+
### Advanced *optional* attributes
|
342
|
+
|
343
|
+
There are a couple of *optional* attributes that could be set on the Img instance to achieve advanced behaviors:
|
344
|
+
|
345
|
+
- **backgroundUri** (Android only)
|
346
|
+
|
347
|
+
String value used for the background image URI. Using this property has similar effect as the placeholderImageUri but the image is stretched to the size of the Img.
|
348
|
+
|
349
|
+
**Note: Currently there are limitations on how many different Images can be set to as 'background' before OutOfMemoryError is thrown. For best results its recommended to use a single image for all ```backgroundUri``` of your Img instances.*
|
350
|
+
|
351
|
+
```xml
|
352
|
+
<@nativescript-community/ui-image:Img backgroundUri="~/image.jpg"/>
|
353
|
+
```
|
354
|
+
|
355
|
+
- **stretch**
|
356
|
+
|
357
|
+
String value used by Img image scale type. This property can be set to:
|
358
|
+
|
359
|
+
'*center*' - Performs no scaling.
|
360
|
+
|
361
|
+
'*centerCrop*' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
|
362
|
+
|
363
|
+
'*centerInside*' - Scales the child so that it fits entirely inside the parent.
|
364
|
+
|
365
|
+
'*fitCenter*' - Scales the child so that it fits entirely inside the parent.
|
366
|
+
|
367
|
+
'*aspectFit*' - Scales the child so that it fits entirely inside the parent.
|
368
|
+
|
369
|
+
'*fitStart*' - Scales the child so that it fits entirely inside the parent.
|
370
|
+
|
371
|
+
'*fitEnd*' - Scales the child so that it fits entirely inside the parent.
|
372
|
+
|
373
|
+
'*fitXY*' - Scales width and height independently, so that the child matches the parent exactly.
|
374
|
+
|
375
|
+
'*fill*' - Scales width and height independently, so that the child matches the parent exactly.
|
376
|
+
|
377
|
+
'*focusCrop*' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
|
378
|
+
|
379
|
+
'*aspectFill*' - Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
|
380
|
+
|
381
|
+
|
382
|
+
```xml
|
383
|
+
<@nativescript-community/ui-image:Img stretch="centerInside"/>
|
384
|
+
```
|
385
|
+
|
386
|
+
- **fadeDuration**
|
387
|
+
|
388
|
+
Number value used for the fade-in duration. This value is in milliseconds.
|
389
|
+
|
390
|
+
```xml
|
391
|
+
<@nativescript-community/ui-image:Img fadeDuration="3000"/>
|
392
|
+
```
|
393
|
+
|
394
|
+
- **blurRadius**
|
395
|
+
|
396
|
+
Number value greater than zero, used as input for the blur function. Larger value means slower processing. For example a value of `10` means that each pixel in the image will be blurred using all adjacent pixels up to a distance of 10.
|
397
|
+
|
398
|
+
```xml
|
399
|
+
<@nativescript-community/ui-image:Img blurRadius="25"/>
|
400
|
+
```
|
401
|
+
|
402
|
+
- **blurDownSampling** (Android only)
|
403
|
+
|
404
|
+
Number value greater than zero, used to scale the image before applying the blur function. Larger value means faster processing. For example a value of `2` means that the image will be scaled by a factor of two before applying blur.
|
405
|
+
|
406
|
+
```xml
|
407
|
+
<@nativescript-community/ui-image:Img blurDownSampling="2"/>
|
408
|
+
```
|
409
|
+
|
410
|
+
- **aspectRatio**
|
411
|
+
|
412
|
+
Number value used as the aspect ratio of the image. This property is useful when you are working with different aspect ratio images and want to have a fixed Width or Height. The ratio of an image is calculated by dividing its width by its height.
|
413
|
+
|
414
|
+
*Note: In some layout scenarios it is necessary to set the ```verticalAlignment``` of the Img to 'top' or 'bottom' in order to "anchor" the img and achieve dynamic sizing.*
|
415
|
+
|
416
|
+
```xml
|
417
|
+
<@nativescript-community/ui-image:Img aspectRatio="1.33" verticalAlignment="top"/>
|
418
|
+
```
|
419
|
+
|
420
|
+
- **decodeWidth** (downsampling) - make sure to enable downsample (**isDownsampleEnabled**) in the initialize function of the plugin otherwise this property is disregarded.
|
421
|
+
|
422
|
+
Number value used as the downsampled width of the imageModule drawable.
|
423
|
+
|
424
|
+
```xml
|
425
|
+
<@nativescript-community/ui-image:Img decodeWidth="100"/>
|
426
|
+
```
|
427
|
+
|
428
|
+
- **decodeHeight** (downsampling) - make sure to enable downsample (**isDownsampleEnabled**) in the initialize function of the plugin otherwise this property is disregarded.
|
429
|
+
|
430
|
+
Number value used as the downsampled width of the imageModule drawable.
|
431
|
+
|
432
|
+
```xml
|
433
|
+
<@nativescript-community/ui-image:Img decodeHeight="100"/>
|
434
|
+
```
|
435
|
+
|
436
|
+
|
437
|
+
- **progressiveRenderingEnabled**
|
438
|
+
|
439
|
+
Boolean value used for enabling or disabling the streaming of progressive JPEG images. This property is set to 'false' by default. Setting this property to 'true' while loading JPEG images not encoded in progressive format will lead to a standard loading of those images.
|
440
|
+
|
441
|
+
```xml
|
442
|
+
<@nativescript-community/ui-image:Img progressiveRenderingEnabled="true"/>
|
443
|
+
```
|
444
|
+
|
445
|
+
- **showProgressBar** (Android only)
|
446
|
+
|
447
|
+
Boolean value used for showing or hiding the progress bar.
|
448
|
+
|
449
|
+
```xml
|
450
|
+
<@nativescript-community/ui-image:Img showProgressBar="true"/>
|
451
|
+
```
|
452
|
+
|
453
|
+
- **progressBarColor** (Android only)
|
454
|
+
|
455
|
+
String value used for setting the color of the progress bar. You can set it to hex values ("*#FF0000*") and/or predefined colors ("*green*").
|
456
|
+
|
457
|
+
```xml
|
458
|
+
<@nativescript-community/ui-image:Img progressBarColor="blue"/>
|
459
|
+
```
|
460
|
+
|
461
|
+
- **roundAsCircle**
|
462
|
+
|
463
|
+
Boolean value used for determining if the image will be rounded as a circle. Its default value is false. If set to true the image will be rounder to a circle.
|
464
|
+
|
465
|
+
```xml
|
466
|
+
<@nativescript-community/ui-image:Img roundAsCircle="true"/>
|
467
|
+
```
|
468
|
+
|
469
|
+
- **roundTopLeftRadius**
|
470
|
+
|
471
|
+
Radius of the Top Left corner in
|
472
|
+
|
473
|
+
```xml
|
474
|
+
<@nativescript-community/ui-image:Img roundTopLeftRadius="50"/>
|
475
|
+
```
|
476
|
+
|
477
|
+
- **roundTopRightRadius**
|
478
|
+
|
479
|
+
Radius of the Top Right corner in
|
480
|
+
|
481
|
+
```xml
|
482
|
+
<@nativescript-community/ui-image:Img roundTopRightRadius="50"/>
|
483
|
+
```
|
484
|
+
- **roundBottomLeftRadius**
|
485
|
+
|
486
|
+
Radius of the Bottom Left corner in
|
487
|
+
|
488
|
+
```xml
|
489
|
+
<@nativescript-community/ui-image:Img roundBottomLeftRadius="50"/>
|
490
|
+
```
|
491
|
+
- **roundBottomRightRadius**
|
492
|
+
|
493
|
+
Radius of the Bottom Right corner in
|
494
|
+
|
495
|
+
```xml
|
496
|
+
<@nativescript-community/ui-image:Img roundBottomRightRadius="50"/>
|
497
|
+
```
|
498
|
+
|
499
|
+
- **autoPlayAnimations**
|
500
|
+
|
501
|
+
Boolean value used for enabling the automatic playing of animated images. Note that rounding of such images is not supported and will be ignored.
|
502
|
+
|
503
|
+
```xml
|
504
|
+
<@nativescript-community/ui-image:Img autoPlayAnimations="true"/>
|
505
|
+
```
|
506
|
+
|
507
|
+
- **tapToRetryEnabled** (Android only)
|
508
|
+
|
509
|
+
Boolean value used for enabling/disabling a tap to retry action for the download of the Img image.
|
510
|
+
|
511
|
+
```xml
|
512
|
+
<@nativescript-community/ui-image:Img tapToRetryEnabled="true"/>
|
513
|
+
```
|
514
|
+
|
504
515
|
### Cache
|
505
516
|
The @nativescript-community/ui-image {N} plugin has built-in cache mechanism which handles managing the images in the memory. There are two types of cache mechanisms `memory` and `disk`, you can manually manage both of them with the following functionality.
|
506
517
|
|
@@ -581,22 +592,79 @@ if (app.android) {
|
|
581
592
|
}
|
582
593
|
```
|
583
594
|
|
584
|
-
|
595
|
+
|
596
|
+
[](#flavors)
|
597
|
+
|
598
|
+
## Flavors
|
599
|
+
|
600
|
+
Using core
|
601
|
+
```xml
|
602
|
+
<Page
|
603
|
+
xmlns="http://www.nativescript.org/tns.xsd"
|
604
|
+
xmlns:@nativescript-community/ui-image="@nativescript-community/ui-image">
|
605
|
+
<@nativescript-community/ui-image:Img width="250" height="250"
|
606
|
+
src="<uri-to-a-photo-from-the-web-or-a-local-resource>"/>
|
607
|
+
</Page>
|
608
|
+
```
|
609
|
+
|
610
|
+
Other flavors are presented in the demo apps that you can find under `demo-snippets`
|
611
|
+
|
612
|
+
|
613
|
+
[](#demos)
|
614
|
+
|
615
|
+
## Demos
|
616
|
+
This repository includes Angular, Vue.js demos. In order to run these execute the following in your shell:
|
617
|
+
```shell
|
618
|
+
$ git clone https://github.com/@nativescript-community/ui-image
|
619
|
+
$ cd ui-image
|
620
|
+
$ npm i
|
621
|
+
$ npm run setup
|
622
|
+
$ npm run build # && npm run build.angular
|
623
|
+
$ cd demo-ng # or demo-vue or demo-svelte
|
624
|
+
$ ns run ios|android
|
625
|
+
```
|
626
|
+
|
627
|
+
|
628
|
+
[](#demos-and-development)
|
629
|
+
|
630
|
+
## Demos and Development
|
631
|
+
|
632
|
+
|
633
|
+
### Setup
|
634
|
+
|
635
|
+
To run the demos, you must clone this repo **recursively**.
|
636
|
+
|
637
|
+
```
|
638
|
+
git clone https://github.com/@nativescript-community/ui-image.git --recursive
|
639
|
+
```
|
640
|
+
|
641
|
+
**Install Dependencies:**
|
642
|
+
```bash
|
643
|
+
npm i # or 'yarn install' or 'pnpm install'
|
644
|
+
```
|
645
|
+
|
646
|
+
**Interactive Menu:**
|
585
647
|
|
586
|
-
|
648
|
+
To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.
|
587
649
|
|
588
|
-
|
589
|
-
-------- | ---------
|
590
|
-
 | 
|
650
|
+
### Build
|
591
651
|
|
592
|
-
|
593
|
-
|
594
|
-
 | 
|
652
|
+
```bash
|
653
|
+
npm run build
|
595
654
|
|
596
|
-
|
597
|
-
|
655
|
+
npm run build.angular # or for Angular
|
656
|
+
```
|
598
657
|
|
599
|
-
|
600
|
-
|
658
|
+
### Demos
|
659
|
+
|
660
|
+
```bash
|
661
|
+
npm run demo.[ng|react|svelte|vue].[ios|android]
|
662
|
+
|
663
|
+
npm run demo.svelte.ios # Example
|
664
|
+
```
|
665
|
+
|
666
|
+
[](#questions)
|
667
|
+
|
668
|
+
## Questions
|
601
669
|
|
602
|
-
|
670
|
+
If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
|
package/angular/directives.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as i0 from "@angular/core";
|
2
2
|
export declare class ImgDirective {
|
3
3
|
constructor();
|
4
|
-
static ɵfac: i0.ɵɵ
|
5
|
-
static ɵdir: i0.ɵɵ
|
4
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ImgDirective, never>;
|
5
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ImgDirective, "NSImg", never, {}, {}, never, never, false>;
|
6
6
|
}
|
7
7
|
export declare const NSIMG_DIRECTIVES: (typeof ImgDirective)[];
|