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
To ensure that your app doesn't have memory leak caused by handlers that are no longer needed, use the [addWeakEventListener](#addweakeventlistener) function:
74
+
To ensure that your app doesn't have memory leak caused by handlers that are no longer needed, use the [addWeakEventListener](#addweakeventlistener) function.
75
75
76
76
<!-- TODO: Add a working example -->
77
77
@@ -144,21 +144,28 @@ Adds a one-time listener for the specified event.
Copy file name to clipboardExpand all lines: content/guide/extending-classes-and-implementing-interfaces-android.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -282,7 +282,7 @@ This approach will not work if `application.android.ts` requires external module
282
282
283
283
@nativescript/core ships with a default `androidx.appcompat.app.AppCompatActivity` implementation, that bootstraps the NativeScript application, without forcing users to declare their custom Activity in every project. In some cases you may need to implement a custom Android Activity.
284
284
285
-
Create a new `activity.android.ts` or `activity.android.js` when using plain JS.
285
+
Create a new `./src/activity.android.ts` or `./src/activity.android.js` when using plain JS.
286
286
287
287
::: info Note
288
288
Note the `.android` suffix - we only want this file on Android.
@@ -493,9 +493,10 @@ To include the new Activity in the build, make sure it's added to the `webpack.c
@@ -4,67 +4,143 @@ description: Navigation using modals - detached from the current backstack.
4
4
contributos:
5
5
- Ombuweb
6
6
- rigor789
7
+
- flipperlite
7
8
---
8
9
9
10
## Showing a modal
10
11
11
12
To show a modal, call the [showModal](https://docs.nativescript.org/api/class/ViewCommon#showmodal) method on a [View](https://docs.nativescript.org/api/class/View) instance and pass it the path to the modal view file:
12
13
14
+
<!-- note: we need a "Open In StackBlitz" button, and also put these in an official NativeScript collection to link on the docs. -->
15
+
<!-- A strongly typed, working, Typescript application can be [found here](https://stackblitz.com/edit/nativescript-stackblitz-templates-3bvo1g?file=app%2Fdetails-page.ts,app%2Fdetails-page.xml,app%2Fmain-page.ts). -->
If your modal does not appear when tapping the button, confirm you set the correct path and the modal page exists. `showModal` does not throw an error when the provided path doesn't exist.
35
+
:::
36
+
24
37
## Closing a modal
25
38
26
-
To close a modal, call the `closeModal` method of any `View` from the modal. Optionally pass it data you want to access in the parent page:
39
+
To close a modal, call the `closeModal` method of any `View` from the modal.
40
+
41
+
For passing data back to the parent, see [Passing Data](#passing-data).
27
42
28
43
```xml
29
-
<Buttontext="Close"tap="onTap"/>
44
+
<Buttontext="Close a Modal"tap="onCloseModal"/>
30
45
```
31
46
32
47
```ts
33
-
onTap(args: EventData) {
34
-
const button =args.objectasButton
35
-
button.closeModal({
36
-
name: 'John Doe - EDITED',
37
-
})
48
+
exportfunction onCloseModal(args:EventData) {
49
+
const view =args.objectasView
50
+
view.closeModal()
38
51
}
39
52
```
40
53
41
-
## Passing data to and from a modal
54
+
## Passing data {#passing-data}
55
+
56
+
Modals are often used for prompting the user for input, this requires passing data between the parent and the modal.
42
57
43
-
Passing data can be done by passing a `context` in the `showModal` options parameter.
58
+
### From parent to modal
59
+
60
+
To pass data to the modal, provide it in the `context` field of the ShowModalOptions:
0 commit comments