mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Added connectivity module.
This commit is contained in:
3
apps/connectivity-demo/app.ts
Normal file
3
apps/connectivity-demo/app.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import application = require("application");
|
||||
application.mainModule = "main-page";
|
||||
application.start();
|
||||
16
apps/connectivity-demo/main-page.ts
Normal file
16
apps/connectivity-demo/main-page.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import connectivity = require("connectivity");
|
||||
|
||||
export function onGetConnectionType(args) {
|
||||
var connectionType = connectivity.getConnectionType();
|
||||
switch (connectionType) {
|
||||
case connectivity.connectionType.none:
|
||||
args.object.text = "No connection";
|
||||
break;
|
||||
case connectivity.connectionType.wifi:
|
||||
args.object.text = "WiFi connection";
|
||||
break;
|
||||
case connectivity.connectionType.mobile:
|
||||
args.object.text = "Mobile connection";
|
||||
break;
|
||||
}
|
||||
}
|
||||
5
apps/connectivity-demo/main-page.xml
Normal file
5
apps/connectivity-demo/main-page.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<Page xmlns="http://www.nativescript.org/tns.xsd" navigatedTo="onNavigatedTo">
|
||||
<StackLayout>
|
||||
<Button text="Get Connection Type" tap="onGetConnectionType" style.fontSize="30"/>
|
||||
</StackLayout>
|
||||
</Page>
|
||||
2
apps/connectivity-demo/package.json
Normal file
2
apps/connectivity-demo/package.json
Normal file
@@ -0,0 +1,2 @@
|
||||
{ "name" : "connectivity-demo",
|
||||
"main" : "app.js" }
|
||||
27
apps/tests/connectivity-tests.ts
Normal file
27
apps/tests/connectivity-tests.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
// <snippet module="connectivity" title="connectivity">
|
||||
// # Connectivity
|
||||
// Obtaining connectivity information requires the "connectivity" module.
|
||||
// ``` JavaScript
|
||||
import connectivity = require("connectivity");
|
||||
// ```
|
||||
// </snippet>
|
||||
|
||||
export var test_DummyTestForSnippetOnly0 = function () {
|
||||
// <snippet module="connectivity" title="connectivity">
|
||||
// ### Getting connection type
|
||||
// ``` JavaScript
|
||||
var connectionType = connectivity.getConnectionType();
|
||||
switch (connectionType) {
|
||||
case connectivity.connectionType.none:
|
||||
////console.log("No connection");
|
||||
break;
|
||||
case connectivity.connectionType.wifi:
|
||||
////console.log("WiFi connection");
|
||||
break;
|
||||
case connectivity.connectionType.mobile:
|
||||
////console.log("Mobile connection");
|
||||
break;
|
||||
}
|
||||
// ```
|
||||
// </snippet>
|
||||
}
|
||||
@@ -76,6 +76,7 @@ allTests["HTML-VIEW"] = require("./ui/html-view/html-view-tests");
|
||||
allTests["WEAK-EVENTS"] = require("./weak-event-listener-tests");
|
||||
allTests["REPEATER"] = require("./ui/repeater/repeater-tests");
|
||||
allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests');
|
||||
allTests["CONNECTIVITY"] = require("./connectivity-tests");
|
||||
|
||||
if (!isRunningOnEmulator()) {
|
||||
allTests["LOCATION"] = require("./location-tests");
|
||||
|
||||
Reference in New Issue
Block a user