You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: advanced-concepts.md
+52-20
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,19 @@ For the Objective-C/Swift symbols to be accessible by the Nativescript runtimes
14
14
15
15
The first task is done by the NativeScript CLI by adding the source files to the generated _.xcodeproj_. For the second one the Metadata Generator needs to find a [module.modulemap](https://clang.llvm.org/docs/Modules.html) of the compiled modules.
16
16
17
-
**Note:** For _.swift_ files _module.modulemap_ is not required.
17
+
::: warning Note
18
+
For _.swift_ files _module.modulemap_ is not required.
19
+
:::
18
20
19
21
In order to satisfy the above constraints the developer has to:
20
22
21
23
**1)** Place the source files in _App_Resources/iOS/src/_
22
24
23
25
**2)** Create a modulemap for the Objective-C files
24
26
25
-
**Note:** Swift classes need to be accessible from the Objective-C runtime in order to be used from NativeScript. This can be done by using the _@objc_ attribute or by inheriting _NSObject_.
27
+
::: warning Note
28
+
Swift classes need to be accessible from the Objective-C runtime in order to be used from NativeScript. This can be done by using the _@objc_ attribute or by inheriting _NSObject_.
29
+
:::
26
30
27
31
For a detailed walkthrough on how to use native iOS source code in NativeScript [here](https://www.nativescript.org/blog/adding-objective-c-code-to-a-nativescript-app).
> Note: Keep in mind that `CGFloat` is architecture dependent. On 32-bit devices, we need to use `Float32Array` and `Float64Array` -- on 64-bit ones. A straightforward way to verify the device/emulator architecture is to check the pointer size via `interop.sizeof(interop.types.id)`. The return value for the pointer size will be 4 bytes for 32-bit architectures and 8 bytes - for 64-bit ones. For further info, check out [CGFloat's documentation](https://developer.apple.com/documentation/coregraphics/cgfloat).
245
+
::: warning Note
246
+
Keep in mind that `CGFloat` is architecture dependent. On 32-bit devices, we need to use `Float32Array` and `Float64Array` -- on 64-bit ones. A straightforward way to verify the device/emulator architecture is to check the pointer size via `interop.sizeof(interop.types.id)`. The return value for the pointer size will be 4 bytes for 32-bit architectures and 8 bytes - for 64-bit ones. For further info, check out [CGFloat's documentation](https://developer.apple.com/documentation/coregraphics/cgfloat).
247
+
:::
242
248
243
249
### Primitive Exceptions
244
250
@@ -499,34 +505,38 @@ var myObject = new MyObject()
499
505
myObject.myMethod(10) // myMethod(int) will be called.
500
506
```
501
507
502
-
> **Note:** If there is no myMethod(int) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
508
+
::: warning Note
509
+
If there is no myMethod(int) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
510
+
:::
503
511
504
512
- Implicit **floating-point** conversion:
505
513
506
514
```javascript
507
515
myObject.myMethod(10.5) // myMethod(double) will be called.
508
516
```
509
517
510
-
> **Note:** If there is no myMethod(double) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
518
+
::: warning Note
519
+
If there is no myMethod(double) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
520
+
:::
511
521
512
522
- Explicitly call an overload: <br/>
513
523
To enable developers call a specific method overload, the Runtime exposes the following functions directly in the global context:
514
524
515
525
* byte(number) → Java primitive byte
516
526
517
-
>The number value will be truncated and only its first byte of the whole part will be used.
527
+
>The number value will be truncated and only its first byte of the whole part will be used.
518
528
519
529
* short(number) → Java primitive short
520
530
521
-
>The number value will be truncated and only its first 2 bytes of the whole part will be used.
531
+
>The number value will be truncated and only its first 2 bytes of the whole part will be used.
522
532
523
533
* float(number) → Java primitive float
524
534
525
-
>The number value will be converted (with a possible precision loss) to a 2^32 floating-point value.
535
+
>The number value will be converted (with a possible precision loss) to a 2^32 floating-point value.
526
536
527
537
* long(number) → Java primitive long (in case the number literal fits JavaScript 2^53 limit)
528
538
529
-
>The number value's whole part will be taken only.
539
+
>The number value's whole part will be taken only.
530
540
531
541
* long("number") → Java primitive long (in case the number literal doesn't fit JavaScript 2^53 limit)
532
542
@@ -538,7 +548,9 @@ myObject.myMethod(long(10)) // will call myMethod(long)
538
548
myObject.myMethod(long('123456')) // will convert "123456" to Java long and will call myMethod(long)
539
549
```
540
550
541
-
> **Note:** When an explicit cast function is called and there is no such implementation found, the Runtime will directly fail, without trying to find a matching overload.
551
+
::: warning Note
552
+
When an explicit cast function is called and there is no such implementation found, the Runtime will directly fail, without trying to find a matching overload.
553
+
:::
542
554
543
555
#### Array
544
556
@@ -621,15 +633,19 @@ var myObject = new MyObject()
621
633
myObject.myMethod(10) // myMethod(Int) will be called.
622
634
```
623
635
624
-
> **Note:** If there is no myMethod(Int) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
636
+
::: warning Note
637
+
If there is no myMethod(Int) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
638
+
:::
625
639
626
640
- Implicit **floating-point** conversion:
627
641
628
642
```javascript
629
643
myObject.myMethod(10.5) // myMethod(Double) will be called.
630
644
```
631
645
632
-
> **Note:** If there is no myMethod(Double) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
646
+
::: warning Note
647
+
If there is no myMethod(Double) implementation, the Runtime will try to choose the best possible overload with least conversion loss. If no such method is found an exception will be raised.
648
+
:::
633
649
634
650
- Explicitly call an overload: <br/>
635
651
To enable developers call a specific method overload, the Runtime exposes the following functions directly in the global context:
@@ -660,7 +676,9 @@ myObject.myMethod(long(10)) // will call myMethod(Long)
660
676
myObject.myMethod(long('123456')) // will convert "123456" to Kotlin Long and will call myMethod(Long)
661
677
```
662
678
663
-
> **Note:** When an explicit cast function is called and there is no such implementation found, the Runtime will directly fail, without trying to find a matching overload.
679
+
::: warning Note
680
+
When an explicit cast function is called and there is no such implementation found, the Runtime will directly fail, without trying to find a matching overload.
681
+
:::
664
682
665
683
#### Array
666
684
@@ -789,7 +807,9 @@ var files = directory.listFiles() // files is a special object as described abov
789
807
var singleFile = files[0] // the indexed getter callback is triggered and a proxy object over the java.io.File is returned
790
808
```
791
809
792
-
> **Note:** A Java Array is intentionally not converted to a JavaScript [Array](http://www.w3schools.com/jsref/jsref_obj_array.asp) for the sake of performance, especially when it comes to large arrays.
810
+
::: warning Note
811
+
A Java Array is intentionally not converted to a JavaScript [Array](http://www.w3schools.com/jsref/jsref_obj_array.asp) for the sake of performance, especially when it comes to large arrays.
812
+
:::
793
813
794
814
#### Array of Objects
795
815
@@ -1082,7 +1102,9 @@ class KotlinClassWithStringArrayProperty {
1082
1102
}
1083
1103
```
1084
1104
1085
-
> **Note:** A Kotlin Array is intentionally not converted to a JavaScript [Array](http://www.w3schools.com/jsref/jsref_obj_array.asp) for the sake of performance, especially when it comes to large arrays.
1105
+
::: warning Note
1106
+
A Kotlin Array is intentionally not converted to a JavaScript [Array](http://www.w3schools.com/jsref/jsref_obj_array.asp) for the sake of performance, especially when it comes to large arrays.
1107
+
:::
1086
1108
1087
1109
#### Creating arrays
1088
1110
@@ -1281,7 +1303,9 @@ Workers API in NativeScript is loosely based on the [Dedicated Web Workers API](
> Note: In order to use `console`'s methods, setTimeout/setInterval, or other functionality coming from the core-modules package, the `globals` module needs to be imported manually to bootstrap the infrastructure on the new worker thread.
1306
+
::: warning Note
1307
+
In order to use `console`'s methods, setTimeout/setInterval, or other functionality coming from the core-modules package, the `globals` module needs to be imported manually to bootstrap the infrastructure on the new worker thread.
1308
+
:::
1285
1309
1286
1310
main-view-model.js
1287
1311
@@ -1431,7 +1455,9 @@ if (android.os.Build.VERSION.SDK_INT >= 21) {
1431
1455
1432
1456
One of NativeScript's strongest capabilities is the access to Android (also referred to as **'Java/Kotlin'** or **'native'**) APIs inside JavaScript/TypeScript. That's possible thanks to build-time generated [Metadata](./overview.md) chunks which hold the information about the public classes from the Android SDK, Android support libraries, and any other Android libraries which may be imported into your Android NativeScript project.
1433
1457
1434
-
> Note: 'Android classes' and 'Java/Kotlin classes' are used interchangeably throughout the article to refer to classes in the Java/Kotlin programming language.
1458
+
::: warning Note
1459
+
'Android classes' and 'Java/Kotlin classes' are used interchangeably throughout the article to refer to classes in the Java/Kotlin programming language.
1460
+
:::
1435
1461
1436
1462
#### Access Android Packages
1437
1463
@@ -1464,11 +1490,17 @@ To find out the package name of an Android class, refer to the [Android SDK Refe
1464
1490
1465
1491
For example, if you need to work with the Google API for Google Maps, after following the installation guide, you may need to access packages from the plugin like `com.google.android.gms.maps`, which you can find a reference for at [Google APIs for Android Reference](https://developers.google.com/android/reference/com/google/android/gms/maps/package-summary)
1466
1492
1467
-
> **Note:** To have access and Intellisense for the native APIs with **NativeScript + TypeScript** or **NativeScript + Angular** projects, you have to add a dev dependency to `@nativescript/types`. More details about accessing native APIs with TypeScript can be found [here]({% slug access-native-apis %}#intellisense-and-access-to-native-apis-via-typescript).
1493
+
::: warning Note
1494
+
To have access and Intellisense for the native APIs with **NativeScript + TypeScript** or **NativeScript + Angular** projects, you have to add a dev dependency to `@nativescript/types`. More details about accessing native APIs with TypeScript can be found [here]({% slug access-native-apis %}#intellisense-and-access-to-native-apis-via-typescript).
1495
+
:::
1468
1496
1469
-
> **Note:****(Experimental)** Alternatively, to get Intellisense for the native APIs based on the available Android Platform SDK and imported Android Support packages (added by default to your Android project), supply the `--androidTypings` flag with your `tns run | build android` command. The resulting `android.d.ts` file can then be used to provide auto-completion.
1497
+
::: warning Note
1498
+
**(Experimental)** Alternatively, to get Intellisense for the native APIs based on the available Android Platform SDK and imported Android Support packages (added by default to your Android project), supply the `--androidTypings` flag with your `tns run | build android` command. The resulting `android.d.ts` file can then be used to provide auto-completion.
1499
+
:::
1470
1500
1471
-
> **Note:** You cannot use APIs that are not present in the metadata. By default, if `--compileSdk` argument isn't provided while building, metadata will be built against the latest Android [Platform SDK](https://developer.android.com/about/versions/nougat/index.html) installed on the workstation. See [metadata limitations](./overview.md).
1501
+
::: warning Note
1502
+
You cannot use APIs that are not present in the metadata. By default, if `--compileSdk` argument isn't provided while building, metadata will be built against the latest Android [Platform SDK](https://developer.android.com/about/versions/nougat/index.html) installed on the workstation. See [metadata limitations](./overview.md).
Copy file name to clipboardExpand all lines: interaction.md
+6-2
Original file line number
Diff line number
Diff line change
@@ -286,7 +286,9 @@ In some scenarios, you would want to disable the user interaction or to create m
286
286
287
287
-`isPassThroughParentEnabled` - Gets or sets a value indicating whether touch events should pass through to a parent view of the layout container in case an interactive child view did not handle the event. Does not affect the appearance of the view. The default value is `false`.
288
288
289
-
> **Note: **: There is a conceptual difference in how `isEnabled` is acting on Android and iOS. On Android, the `isEnabled` set to `false` (e.g., on Button) won't allow any events to pass through even when `isPassThroughParentEnabled` is set to `true` for its parent. On the contrary on iOS, the same setup will pass through the event to the parent.
289
+
::: warning Note
290
+
There is a conceptual difference in how `isEnabled` is acting on Android and iOS. On Android, the `isEnabled` set to `false` (e.g., on Button) won't allow any events to pass through even when `isPassThroughParentEnabled` is set to `true` for its parent. On the contrary on iOS, the same setup will pass through the event to the parent.
291
+
:::
290
292
291
293
Playground application demonstrating the usage of the three properties can be found [here](https://play.nativescript.org/?template=play-tsc&id=6c9GA0).
292
294
@@ -1018,7 +1020,9 @@ view.animate({
1018
1020
});
1019
1021
```
1020
1022
1021
-
> Note: The properties `origenX` and `origenY` are JavaScript properties and can be assigned via code-behind only via a given `View` reference. We can still use them along with CSS animations, but the values for `origenX` and `origenY` must be set in the code-behind logic.
1023
+
::: warning Note
1024
+
The properties `origenX` and `origenY` are JavaScript properties and can be assigned via code-behind only via a given `View` reference. We can still use them along with CSS animations, but the values for `origenX` and `origenY` must be set in the code-behind logic.
> Note: By default the file will be saved in Documents folder.
110
+
::: warning Note
111
+
By default the file will be saved in Documents folder.
112
+
:::
111
113
112
114
In the `getFile` method we could also specify the path, where the file to be saved. This scenario is demonstrated in the example below, where the image file will be kept in the current application folder.
Copy file name to clipboardExpand all lines: performance.md
+10-4
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,9 @@ In contrast, when using `ImageSource` or Base64 encoded string, the Bitmap is tr
30
30
31
31
As an additional feature for Android, NativeScript supports `decodeWidth` and `decodeHeight`. These properties will **downsample** your image so that it will take less memory. The goal is to avoid as much as possible out of memory exceptions caused by images being loaded into memory and at the same time display crispy images.
32
32
33
-
> **Note:** Use `decodeWidth` and `decodeHeight` only when working with large photos and there are `Out of Memory` exceptions issues. With NativeScript 3.x.x and above, image optimizations were implemented and in the common scenarios, you should not worry about hitting OOM.
33
+
::: warning Note
34
+
Use `decodeWidth` and `decodeHeight` only when working with large photos and there are `Out of Memory` exceptions issues. With NativeScript 3.x.x and above, image optimizations were implemented and in the common scenarios, you should not worry about hitting OOM.
35
+
:::
34
36
35
37
When working with the decode properties, the following considerations should be taken:
36
38
@@ -42,7 +44,7 @@ When working with the decode properties, the following considerations should be
42
44
43
45
- Image caching now takes into account the `decodeWidth` and `decodeHeight` values. Identical images with different decode property values will now be retrieved and saved separately in the cache. This results in better quality images. If you have a small version of the image in a master list and want to decode it with 100 x 100 DP, and then want to display it in 1000 x 1000 DP on the detail page, the detailed image will now not be blurry. This also means you can now control caching - using the same image with the same decode parameter values will still get the image from the cache.
44
46
45
-
> **Important**: The `decodeWidth` and `decodeHeight` properties will work only for Android. Setting them for our iOS images will not change the application behaviour in any way.
47
+
> **Important**: The `decodeWidth` and `decodeHeight` properties will work only for Android. Setting them for our iOS images will not change the application behavior in any way.
46
48
47
49
### Using `loadMode` property
48
50
@@ -57,13 +59,17 @@ With [loadMode](/api-reference/modules/_ui_image_.html#loadmode) set to `async`,
57
59
</StackLayout>
58
60
```
59
61
60
-
> **Note**: When the `src` value starts with `http` it will be loaded asynchronously no matter what value is set to `loadMode`.
62
+
::: warning Note
63
+
When the `src` value starts with `http` it will be loaded asynchronously no matter what value is set to `loadMode`.
64
+
:::
61
65
62
66
### Using `useCache` property
63
67
64
68
The `Image` module will use internal memory and disk cache, so when loaded the module stores the images in the memory cache, and when they are not needed anymore, the `Image` module saves the images in the disk cache. This way the next time the application needs the same image NativeScript will load it from memory or the disk cache. Setting property `useCache` to `false` could be used to bypass image cache and load the image as it is on the first request to the specified URL.
65
69
66
-
> **Note**: The property `useCache` will work only for Android. Setting it for our iOS images will not change the application behaviour in any way.
70
+
::: tip Tip
71
+
The property `useCache` will work only for Android. Setting it for our iOS images will not change the application behavior in any way.
Copy file name to clipboardExpand all lines: plugins/background-http.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -154,7 +154,9 @@ node server 8080
154
154
155
155
The above commands will start a server listening on port 8080. Remember to update the URL in your app to match the address/port where the server is running.
156
156
157
-
> Note: If you are using the iOS simulator then `http://localhost:8080` should be used to upload to the demo server. If you are using an Android emulator, `http://10.0.2.2:8080` should be used instead.
157
+
::: warning Note
158
+
If you are using the iOS simulator then `http://localhost:8080` should be used to upload to the demo server. If you are using an Android emulator, `http://10.0.2.2:8080` should be used instead.
0 commit comments