From d601df6c31aa24a318326ed3ebb46e63ce3b3190 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Wed, 14 Jan 2015 12:06:15 +0200 Subject: [PATCH] Fixed the ordering. --- README.md | 2 +- application-management.md | 74 +++++++++++++++++++++++---------------- layouts.md | 2 +- location.md | 2 +- navigation.md | 3 +- styling.md | 2 +- ui-dialogs.md | 2 +- ui-views.md | 7 +++- ui-with-xml.md | 2 +- 9 files changed, 57 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index a8cadbcc3..bc8136d77 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ Use the [NativeScript CLI](http://www.telerik.com/forums/using-the-cli-to-build- Read the advanced topics below or refer to the [Api Reference](ApiReference/) to build a powerful NativeScript application: - [Application](application-management.md) -- [Layouts](layouts.md) - [Navigation](navigation.md) +- [Layouts](layouts.md) - [Styling](styling.md) - [Binding](bindings.md) - [UI with XML](ui-with-xml.md) diff --git a/application-management.md b/application-management.md index 79004e9fa..27b533a56 100644 --- a/application-management.md +++ b/application-management.md @@ -3,41 +3,19 @@ nav-title: "Application Management" title: "Application Management" description: "Application Management" position: 2 ---- -# Persist and Restore Application Settings -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: +--- +# Application Start +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.: ``` JavaScript -var localSettings = require("local-settings"); -// Event handler for Page "loaded" event attached in main-page.xml -function pageLoaded(args) { - localSettings.setString("Name", "John Doe"); - console.log(localSettings.getString("Name")); // Prints "John Doe" - localSettings.setBoolean("Married", false); - console.log(localSettings.getBoolean("Married")); // Prints false - localSettings.setNumber("Age", 42); - console.log(localSettings.getNumber("Age")); // Prints 42 - console.log(localSettings.hasKey("Name")); // Prints true - localSettings.remove("Name"); // Removes the Name entry. - console.log(localSettings.hasKey("Name")); // Prints false -} -exports.pageLoaded = pageLoaded; +var application = require("application"); +application.mainModule = "app/template-settings/main-page"; +application.start(); ``` ``` TypeScript -import observable = require("data/observable"); -import localSettings = require("local-settings"); -// Event handler for Page "loaded" event attached in main-page.xml -export function pageLoaded(args: observable.EventData) { - localSettings.setString("Name", "John Doe"); - console.log(localSettings.getString("Name"));// Prints "John Doe" - localSettings.setBoolean("Married", false); - console.log(localSettings.getBoolean("Married"));// Prints false - localSettings.setNumber("Age", 42); - console.log(localSettings.getNumber("Age"));// Prints 42 - console.log(localSettings.hasKey("Name"));// Prints true - localSettings.remove("Name");// Removes the Name entry. - console.log(localSettings.hasKey("Name"));// Prints false -} +import application = require("application"); +application.mainModule = "app/main-page"; +application.start(); ``` # Using Application Callbacks 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) { console.log("Application error: " + error.name + "; " + error.message + "; " + error.nativeError); } application.start(); +``` +# Persist and Restore Application Settings +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: +``` JavaScript +var localSettings = require("local-settings"); +// Event handler for Page "loaded" event attached in main-page.xml +function pageLoaded(args) { + localSettings.setString("Name", "John Doe"); + console.log(localSettings.getString("Name")); // Prints "John Doe" + localSettings.setBoolean("Married", false); + console.log(localSettings.getBoolean("Married")); // Prints false + localSettings.setNumber("Age", 42); + console.log(localSettings.getNumber("Age")); // Prints 42 + console.log(localSettings.hasKey("Name")); // Prints true + localSettings.remove("Name"); // Removes the Name entry. + console.log(localSettings.hasKey("Name")); // Prints false +} +exports.pageLoaded = pageLoaded; +``` +``` TypeScript +import observable = require("data/observable"); +import localSettings = require("local-settings"); +// Event handler for Page "loaded" event attached in main-page.xml +export function pageLoaded(args: observable.EventData) { + localSettings.setString("Name", "John Doe"); + console.log(localSettings.getString("Name"));// Prints "John Doe" + localSettings.setBoolean("Married", false); + console.log(localSettings.getBoolean("Married"));// Prints false + localSettings.setNumber("Age", 42); + console.log(localSettings.getNumber("Age"));// Prints 42 + console.log(localSettings.hasKey("Name"));// Prints true + localSettings.remove("Name");// Removes the Name entry. + console.log(localSettings.hasKey("Name"));// Prints false +} ``` \ No newline at end of file diff --git a/layouts.md b/layouts.md index 7132a2641..7b2900498 100644 --- a/layouts.md +++ b/layouts.md @@ -2,7 +2,7 @@ nav-title: "NativeScript Layouts" title: "Layouts" description: "NativeScript Documentation: Layouts" -position: 3 +position: 4 --- # Layouts diff --git a/location.md b/location.md index df091076f..5e6fb4220 100644 --- a/location.md +++ b/location.md @@ -2,7 +2,7 @@ nav-title: "Location" title: "Location" description: "NativeScript Documentation: Location" -position: 8 +position: 10 --- # Location diff --git a/navigation.md b/navigation.md index 387e47c7c..adc4afb82 100644 --- a/navigation.md +++ b/navigation.md @@ -2,7 +2,8 @@ nav-title: "Navigation" title: "Navigation" description: "Navigation" -position: 0 +position: 3 + --- # Overview 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. diff --git a/styling.md b/styling.md index a7534c04f..202907480 100644 --- a/styling.md +++ b/styling.md @@ -2,7 +2,7 @@ nav-title: "NativeScript Styling" title: "Styling" description: "NativeScript Documentation: Styling" -position: 7 +position: 5 --- # Styling diff --git a/ui-dialogs.md b/ui-dialogs.md index 9d0561960..67632176a 100644 --- a/ui-dialogs.md +++ b/ui-dialogs.md @@ -2,7 +2,7 @@ nav-title: "UI Dialogs" title: "UI Dialogs" description: "NativeScript Documentation: UI Dialogs" -position: 101 +position: 9 --- # UI Dialogs diff --git a/ui-views.md b/ui-views.md index 839f22b0c..d77dadcdc 100644 --- a/ui-views.md +++ b/ui-views.md @@ -1,4 +1,9 @@ -#UI Views +--- +nav-title: "UI Views" +title: "UI Views" +description: "UI Views" +position: 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. diff --git a/ui-with-xml.md b/ui-with-xml.md index b1585fb81..9480cf54f 100644 --- a/ui-with-xml.md +++ b/ui-with-xml.md @@ -2,7 +2,7 @@ nav-title: "UI with XML" title: "UI with XML" description: "NativeScript Documentation: UI with XML" -position: 5 +position: 7 --- # UI with XML