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
{{ message }}
This repository was archived by the owner on Nov 17, 2022. It is now read-only.
To persist settings that the user has defined you have to use the local-settings module. The local-settings module is a static singleton hash table that stores key-value pairs for the application. The getter methods have two parameters -- a key and an optional default value to return if the specified key does not exist. The setter methods also have two parameters -- key and value. Here is an example of using the local settings-module and all of its available methods:
7
+
---
8
+
# Application Start
9
+
You are required to call the **start** method of the application module once you are ready with its initialization. This method doesn't do anything for an Android application at the moment but may do in the future. In an iOS application this call will start the UIApplication and will trigger its UI message loop.:
10
10
```JavaScript
11
-
var localSettings =require("local-settings");
12
-
// Event handler for Page "loaded" event attached in main-page.xml
13
-
functionpageLoaded(args) {
14
-
localSettings.setString("Name", "John Doe");
15
-
console.log(localSettings.getString("Name")); // Prints "John Doe"
16
-
localSettings.setBoolean("Married", false);
17
-
console.log(localSettings.getBoolean("Married")); // Prints false
18
-
localSettings.setNumber("Age", 42);
19
-
console.log(localSettings.getNumber("Age")); // Prints 42
20
-
console.log(localSettings.hasKey("Name")); // Prints true
21
-
localSettings.remove("Name"); // Removes the Name entry.
22
-
console.log(localSettings.hasKey("Name")); // Prints false
console.log(localSettings.getString("Name"));// Prints "John Doe"
33
-
localSettings.setBoolean("Married", false);
34
-
console.log(localSettings.getBoolean("Married"));// Prints false
35
-
localSettings.setNumber("Age", 42);
36
-
console.log(localSettings.getNumber("Age"));// Prints 42
37
-
console.log(localSettings.hasKey("Name"));// Prints true
38
-
localSettings.remove("Name");// Removes the Name entry.
39
-
console.log(localSettings.hasKey("Name"));// Prints false
40
-
}
16
+
importapplication=require("application");
17
+
application.mainModule="app/main-page";
18
+
application.start();
41
19
```
42
20
# Using Application Callbacks
43
21
Each NativeScript application has several important lifecycle events. You can use those events to perform all kinds of needed maintanance and housekeeping:
@@ -107,4 +85,38 @@ application.onUncaughtError = function (error: application.NativeScriptError) {
To persist settings that the user has defined you have to use the local-settings module. The local-settings module is a static singleton hash table that stores key-value pairs for the application. The getter methods have two parameters -- a key and an optional default value to return if the specified key does not exist. The setter methods also have two parameters -- key and value. Here is an example of using the local settings-module and all of its available methods:
91
+
```JavaScript
92
+
var localSettings =require("local-settings");
93
+
// Event handler for Page "loaded" event attached in main-page.xml
94
+
functionpageLoaded(args) {
95
+
localSettings.setString("Name", "John Doe");
96
+
console.log(localSettings.getString("Name")); // Prints "John Doe"
97
+
localSettings.setBoolean("Married", false);
98
+
console.log(localSettings.getBoolean("Married")); // Prints false
99
+
localSettings.setNumber("Age", 42);
100
+
console.log(localSettings.getNumber("Age")); // Prints 42
101
+
console.log(localSettings.hasKey("Name")); // Prints true
102
+
localSettings.remove("Name"); // Removes the Name entry.
103
+
console.log(localSettings.hasKey("Name")); // Prints false
104
+
}
105
+
exports.pageLoaded= pageLoaded;
106
+
```
107
+
```TypeScript
108
+
importobservable=require("data/observable");
109
+
importlocalSettings=require("local-settings");
110
+
// Event handler for Page "loaded" event attached in main-page.xml
Copy file name to clipboardExpand all lines: navigation.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,8 @@
2
2
nav-title: "Navigation"
3
3
title: "Navigation"
4
4
description: "Navigation"
5
-
position: 0
5
+
position: 3
6
+
6
7
---
7
8
# Overview
8
9
Each NativeScript application is built upon the concept of pages (represented by the **Page** class). Pages are the different screens that your application offers. Each page has a **content** property which holds the root visual element of the page UI. Navigating between different pages is done with methods of the **Frame** class. The Frame class represents the logical unit that is responsible for navigation between different pages, i.e. going from one page to another, keeping a history stack for going back and so on.
Copy file name to clipboardExpand all lines: ui-views.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,9 @@
1
-
#UI Views
1
+
---
2
+
nav-title: "UI Views"
3
+
title: "UI Views"
4
+
description: "UI Views"
5
+
position: 8
6
+
---
2
7
3
8
NativeScript ships with set of UI Views which can be used for building the UI of a mobile application. Most of these views wrap the corresponding native view for each platform, while providing a common API for working with them. For example the `Button` view renders an `android.widget.Button` on Android and `UIButton` on iOS.
0 commit comments