diff --git a/app/app.component.ts b/app/app.component.ts index ae9a39d6..4d9ed32c 100644 --- a/app/app.component.ts +++ b/app/app.component.ts @@ -1,7 +1,6 @@ import { Component, AfterViewInit } from "@angular/core"; -import { hasKey, getString, remove } from "tns-core-modules/application-settings"; -import { RouterExtensions } from "nativescript-angular/router"; -import * as app from "tns-core-modules/application"; +import { RouterExtensions } from "@nativescript/angular"; +import { Application, ApplicationEventData, ApplicationSettings } from "@nativescript/core"; import { DeepLinkData } from "./shared/deep-link-data"; @Component({ moduleId: module.id, @@ -13,7 +12,7 @@ export class AppComponent implements AfterViewInit { constructor(private router: RouterExtensions) { } ngAfterViewInit() { - app.on(app.resumeEvent, (args: app.ApplicationEventData) => { + Application.on(Application.resumeEvent, (args: ApplicationEventData) => { if (args.android) { const dld = new DeepLinkData("", args.android); this.launchExample(); @@ -23,9 +22,9 @@ export class AppComponent implements AfterViewInit { }); } public launchExample() { - if (hasKey("gotoexample")) { - let value = getString("gotoexample"); - remove("gotoexample"); + if (ApplicationSettings.hasKey("gotoexample")) { + let value = ApplicationSettings.getString("gotoexample"); + ApplicationSettings.remove("gotoexample"); this.router.navigate([value]); } } diff --git a/app/app.module.ts b/app/app.module.ts index a9885a32..dea8d3dd 100644 --- a/app/app.module.ts +++ b/app/app.module.ts @@ -1,12 +1,12 @@ // >> ngmodule-config // this import should be first in order to load some required settings (like globals and reflect-metadata) -import { NativeScriptModule } from "nativescript-angular/nativescript.module"; +import { NativeScriptModule } from "@nativescript/angular"; import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptFormsModule } from "nativescript-angular/forms"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptFormsModule } from "@nativescript/angular"; import { routes } from "./app.routes"; import { AppComponent } from "./app.component"; -import { ModalDialogService } from "nativescript-angular/modal-dialog"; +import { ModalDialogService } from "@nativescript/angular"; @NgModule({ schemas: [NO_ERRORS_SCHEMA], diff --git a/app/delegate/my-delegate.ios.ts b/app/delegate/my-delegate.ios.ts index d11c0e7d..bc0f9f75 100644 --- a/app/delegate/my-delegate.ios.ts +++ b/app/delegate/my-delegate.ios.ts @@ -1,5 +1,7 @@ import { DeepLinkData } from "../shared/deep-link-data"; -export class MyDelegate extends UIResponder implements UIApplicationDelegate { + +@NativeClass +class MyDelegate extends UIResponder implements UIApplicationDelegate { // tslint:disable-next-line public static ObjCProtocols = [UIApplicationDelegate]; @@ -8,3 +10,6 @@ export class MyDelegate extends UIResponder implements UIApplicationDelegate { return true; } } + +export {MyDelegate}; + diff --git a/app/directives/example.directive.ts b/app/directives/example.directive.ts index ee253927..9f81ac77 100644 --- a/app/directives/example.directive.ts +++ b/app/directives/example.directive.ts @@ -1,6 +1,6 @@ import { Directive } from "@angular/core"; import { ActivatedRoute } from "@angular/router"; -import { Page } from "tns-core-modules/ui/page"; +import { Page } from "@nativescript/core"; @Directive({ selector: "[sdkExampleTitle]" diff --git a/app/directives/toggle-nav-button.directive.ts b/app/directives/toggle-nav-button.directive.ts index 74d9653c..95da98b9 100644 --- a/app/directives/toggle-nav-button.directive.ts +++ b/app/directives/toggle-nav-button.directive.ts @@ -1,10 +1,7 @@ import { ActivatedRoute } from "@angular/router"; import { Directive, OnInit } from "@angular/core"; -import { EventData } from "tns-core-modules/data/observable"; -import { NavigationButton } from "tns-core-modules/ui/action-bar"; -import { Page } from "tns-core-modules/ui/page"; -import { RouterExtensions } from "nativescript-angular/router"; -import * as app from "tns-core-modules/application"; +import { EventData, NavigationButton, Page, isAndroid, isIOS } from "@nativescript/core"; +import { RouterExtensions } from "@nativescript/angular"; @Directive({ selector: "[sdkToggleNavButton]" @@ -23,12 +20,12 @@ export class ToggleNavButtonDirective implements OnInit { let navigationButton = new NavigationButton(); navigationButton.visibility = "visible"; - if (app.android) { + if (isAndroid) { navigationButton.icon = "res://ic_arrow_back_black_24dp"; navigationButton.on("tap", (args: EventData) => { this.routerExtensions.backToPreviousPage(); }); - } else if (app.ios) { + } else if (isIOS) { navigationButton.text = ""; } diff --git a/app/examples-list.module.ts b/app/examples-list.module.ts index b9377623..a6234523 100644 --- a/app/examples-list.module.ts +++ b/app/examples-list.module.ts @@ -1,6 +1,6 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; import { ExamplesListComponent } from "./examples-list.component"; import { TitleAndNavButtonModule } from "./directives/title-and-nav-button.module"; diff --git a/app/main.ts b/app/main.ts index c8530f25..1b72a6f1 100644 --- a/app/main.ts +++ b/app/main.ts @@ -1,10 +1,10 @@ -import { platformNativeScriptDynamic } from "nativescript-angular/platform"; +import { platformNativeScriptDynamic } from "@nativescript/angular"; import { AppModule } from "./app.module"; -import { ios } from "tns-core-modules/application"; -import { isIOS } from "tns-core-modules/platform"; +import { Application } from "@nativescript/core"; +import { isIOS } from "@nativescript/core"; import { MyDelegate } from "./delegate/my-delegate"; if (isIOS) { - ios.delegate = MyDelegate; + Application.ios.delegate = MyDelegate; } platformNativeScriptDynamic().bootstrapModule(AppModule); diff --git a/app/ng-framework-modules-category/application-settings/application-settings-examples.module.ts b/app/ng-framework-modules-category/application-settings/application-settings-examples.module.ts index 7fd5b0f4..215e6573 100644 --- a/app/ng-framework-modules-category/application-settings/application-settings-examples.module.ts +++ b/app/ng-framework-modules-category/application-settings/application-settings-examples.module.ts @@ -1,6 +1,6 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; import { ApplicationSettingsExamplesComponent } from "./application-settings-examples.component"; import { UsageComponent } from "./usage/usage.component"; import { TitleAndNavButtonModule } from "../../directives/title-and-nav-button.module"; diff --git a/app/ng-framework-modules-category/application-settings/usage/usage.component.ts b/app/ng-framework-modules-category/application-settings/usage/usage.component.ts index e4b2c62b..b547bcf4 100644 --- a/app/ng-framework-modules-category/application-settings/usage/usage.component.ts +++ b/app/ng-framework-modules-category/application-settings/usage/usage.component.ts @@ -1,16 +1,6 @@ // >> app-settings-code import { Component } from "@angular/core"; -import { - getBoolean, - setBoolean, - getNumber, - setNumber, - getString, - setString, - hasKey, - remove, - clear -} from "tns-core-modules/application-settings"; +import { ApplicationSettings } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -19,27 +9,27 @@ import { export class UsageComponent { constructor() { - setBoolean("isTurnedOn", true); - setString("username", "Wolfgang"); - setNumber("locationX", 54.321); + ApplicationSettings.setBoolean("isTurnedOn", true); + ApplicationSettings.setString("username", "Wolfgang"); + ApplicationSettings.setNumber("locationX", 54.321); - const isTurnedOn: boolean = getBoolean("isTurnedOn"); - const username: string = getString("username"); - const locationX: number = getNumber("locationX"); + const isTurnedOn: boolean = ApplicationSettings.getBoolean("isTurnedOn"); + const username: string = ApplicationSettings.getString("username"); + const locationX: number = ApplicationSettings.getNumber("locationX"); // Will return "No string value" if there is no value for "noSuchKey" - const someKey: string = getString("noSuchKey", "No string value"); + const someKey: string = ApplicationSettings.getString("noSuchKey", "No string value"); // Will return false if there is no key with name "noSuchKey" - let isKeExisting: boolean = hasKey("noSuchKey"); + let isKeExisting: boolean = ApplicationSettings.hasKey("noSuchKey"); } onClearß() { // Removing a single entry via its key name - remove("isTurnedOn"); + ApplicationSettings.remove("isTurnedOn"); // Clearing the whole application-settings for this app - clear(); + ApplicationSettings.clear(); } } // << app-settings-code diff --git a/app/ng-framework-modules-category/application/app-checking-target/app-checking-target.component.ts b/app/ng-framework-modules-category/application/app-checking-target/app-checking-target.component.ts index d274ffae..93a3269a 100644 --- a/app/ng-framework-modules-category/application/app-checking-target/app-checking-target.component.ts +++ b/app/ng-framework-modules-category/application/app-checking-target/app-checking-target.component.ts @@ -1,6 +1,6 @@ // >> app-check-target-code import { Component } from "@angular/core"; -import { android as androidApp, ios as iosApp } from "tns-core-modules/application"; +import { isAndroid, isIOS } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -10,10 +10,10 @@ export class AppCheckingTargetExampleComponent { public isItemVisible: boolean; constructor() { - if (androidApp) { + if (isAndroid) { console.log("We are running on Android device!"); this.isItemVisible = true; - } else if (iosApp) { + } else if (isIOS) { console.log("We are running on iOS device"); this.isItemVisible = false; } diff --git a/app/ng-framework-modules-category/application/app-using-android-specifics/app-using-android-specifics.component.ts b/app/ng-framework-modules-category/application/app-using-android-specifics/app-using-android-specifics.component.ts index 8595eb77..0af48b46 100644 --- a/app/ng-framework-modules-category/application/app-using-android-specifics/app-using-android-specifics.component.ts +++ b/app/ng-framework-modules-category/application/app-using-android-specifics/app-using-android-specifics.component.ts @@ -1,5 +1,5 @@ import { Component } from "@angular/core"; -import { android as androidApp, ios as iosApp } from "tns-core-modules/application"; +import { Application, isAndroid, isIOS } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -16,22 +16,22 @@ export class AppUsingAndroidExampleComponent { public batteryLife: string; constructor() { - if (androidApp) { + if (isAndroid) { console.log("We are running on Android device!"); this.isItemVisible = true; // >> app-class-properties - // import { android as androidApp } from "tns-core-modules/application"; - let isPaused = androidApp.paused; // e.g. false - let packageName = androidApp.packageName; // The package ID e.g. org.nativescript.nativescriptsdkexamplesng - let nativeApp = androidApp.nativeApp; // The native APplication reference - let foregroundActivity = androidApp.foregroundActivity; // The current Activity reference - let context = androidApp.context; console.log(context); // The current Android context + // import { Application } from "@nativescript/core"; + let isPaused = Application.android.paused; // e.g. false + let packageName = Application.android.packageName; // The package ID e.g. org.nativescript.nativescriptsdkexamplesng + let nativeApp = Application.android.nativeApp; // The native Application reference + let foregroundActivity = Application.android.foregroundActivity; // The current Activity reference + let context = Application.android.context; console.log(context); // The current Android context // << app-class-properties // >> app-android-dirs-code this.fileList = []; - this.appContext = androidApp.context; + this.appContext = Application.android.context; // https://developer.android.com/reference/android/content/Context.html#getFilesDir() this.filesDir = this.appContext.getFilesDir(); @@ -51,7 +51,7 @@ export class AppUsingAndroidExampleComponent { let that = this; // Broadcast Receiver https://developer.android.com/reference/android/content/BroadcastReceiver - androidApp.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED, + Application.android.registerBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED, function onReceiveCallback(androidContext: android.content.Context, intent: android.content.Intent) { let level = intent.getIntExtra(android.os.BatteryManager.EXTRA_LEVEL, -1); let scale = intent.getIntExtra(android.os.BatteryManager.EXTRA_SCALE, -1); @@ -60,7 +60,7 @@ export class AppUsingAndroidExampleComponent { that.batteryLife = percent.toString(); }); // << app-android-broadcast-code - } else if (iosApp) { + } else if (isIOS) { console.log("We are running on iOS device"); this.isItemVisible = false; } @@ -68,7 +68,7 @@ export class AppUsingAndroidExampleComponent { unregister() { // >> app-android-broadcast-unregister-code - androidApp.unregisterBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED); + Application.android.unregisterBroadcastReceiver(android.content.Intent.ACTION_BATTERY_CHANGED); // << app-android-broadcast-unregister-code } } diff --git a/app/ng-framework-modules-category/application/app-using-ios-specifics/app-using-ios-specifics.component.ts b/app/ng-framework-modules-category/application/app-using-ios-specifics/app-using-ios-specifics.component.ts index c3dc5f52..b5677c0e 100644 --- a/app/ng-framework-modules-category/application/app-using-ios-specifics/app-using-ios-specifics.component.ts +++ b/app/ng-framework-modules-category/application/app-using-ios-specifics/app-using-ios-specifics.component.ts @@ -1,5 +1,5 @@ import { Component } from "@angular/core"; -import { android as androidApp, ios as iosApp } from "tns-core-modules/application"; +import { Application, isAndroid, isIOS } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -13,19 +13,19 @@ export class AppUsingIosExampleComponent { constructor() { - if (iosApp) { + if (isIOS) { // >> app-class-properties-ios - // import { ios as iosApp } from "tns-core-modules/application"; + // import { Application } from "@nativescript/core"; // https://developer.apple.com/documentation/uikit/uiapplicationdelegate?language=objc - let delegate = iosApp.delegate; // the iOS application delegate + let delegate = Application.ios.delegate; // the iOS application delegate - let nativeApp = iosApp.nativeApp; // The native iOS app + let nativeApp = Application.ios.nativeApp; // The native iOS app // https://developer.apple.com/documentation/uikit/uiwindow/1621581-rootviewcontroller?language=objc - let rootController = iosApp.rootController; // the iOS rootViewController + let rootController = Application.ios.rootController; // the iOS rootViewController - let window = iosApp.window; // UIWindow + let window = Application.ios.window; // UIWindow // << app-class-properties-ios this.isItemVisible = true; @@ -36,7 +36,7 @@ export class AppUsingIosExampleComponent { this.batteryLife = +(UIDevice.currentDevice.batteryLevel * 100); let that = this; - let observer = iosApp.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification, + let observer = Application.ios.addNotificationObserver(UIDeviceBatteryLevelDidChangeNotification, function onReceiveCallback(notification: NSNotification) { that.batteryLife = +(UIDevice.currentDevice.batteryLevel * 100); }); @@ -45,10 +45,10 @@ export class AppUsingIosExampleComponent { if (this.goodToRemove) { // >> app-ios-observer-remove-code // When no longer needed, remove the notification observer - iosApp.removeNotificationObserver(observer, UIDeviceBatteryLevelDidChangeNotification); + Application.ios.removeNotificationObserver(observer, UIDeviceBatteryLevelDidChangeNotification); // << app-ios-observer-remove-code } - } else if (androidApp) { + } else if (isAndroid) { this.isItemVisible = false; } } diff --git a/app/ng-framework-modules-category/application/application-events/application-events.component.ts b/app/ng-framework-modules-category/application/application-events/application-events.component.ts index ccecf2fc..9b088440 100644 --- a/app/ng-framework-modules-category/application/application-events/application-events.component.ts +++ b/app/ng-framework-modules-category/application/application-events/application-events.component.ts @@ -1,16 +1,11 @@ import { Component } from "@angular/core"; import { - on, + Application, ApplicationEventData, - launchEvent, LaunchEventData, - resumeEvent, - exitEvent, - uncaughtErrorEvent, UnhandledErrorEventData, - displayedEvent, - lowMemoryEvent, - orientationChangedEvent, OrientationChangedEventData, - suspendEvent -} from "tns-core-modules/application"; + LaunchEventData, + OrientationChangedEventData, + UnhandledErrorEventData +} from "@nativescript/core"; let launchListener, suspendListener, @@ -33,35 +28,35 @@ export class ApplicationEventsComponent { launchListener = (args: LaunchEventData) => { console.log("The appication was launched!"); }; - on(launchEvent, launchListener); + Application.on(Application.launchEvent, launchListener); // << application-events-launch-ng // >> application-events-suspend-ng suspendListener = (args: ApplicationEventData) => { console.log("The appication was suspended!"); }; - on(suspendEvent, suspendListener); + Application.on(Application.suspendEvent, suspendListener); // << application-events-suspend-ng // >> application-events-resume-ng resumeListener = (args: ApplicationEventData) => { console.log("The appication was resumed!"); }; - on(resumeEvent, resumeListener); + Application.on(Application.resumeEvent, resumeListener); // << application-events-resume-ng // >> application-events-exit-ng exitListener = (args: ApplicationEventData) => { console.log("The appication was closed!"); }; - on(exitEvent, exitListener); + Application.on(Application.exitEvent, exitListener); // << application-events-exit-ng // >> application-events-displayed-ng displayedListener = (args: ApplicationEventData) => { console.log("NativeScript displayedEvent!"); }; - on(displayedEvent, displayedListener); + Application.on(Application.displayedEvent, displayedListener); // << application-events-displayed-ng // >> application-events-low-memory-ng @@ -69,7 +64,7 @@ export class ApplicationEventsComponent { // the instance that has raised the event console.log("Instance: ", args.object); }; - on(lowMemoryEvent, lowMemoryListener); + Application.on(Application.lowMemoryEvent, lowMemoryListener); // << application-events-low-memory-ng // >> application-events-orientation-ng @@ -77,7 +72,7 @@ export class ApplicationEventsComponent { // orientationChangedEventData.newValue: "portrait" | "landscape" | "unknown" console.log("Orientation: ", args.newValue); }; - on(orientationChangedEvent, orientationChangedListener); + Application.on(Application.orientationChangedEvent, orientationChangedListener); // << application-events-orientation-ng // >> application-events-error-ng @@ -85,7 +80,7 @@ export class ApplicationEventsComponent { // UnhandledErrorEventData.error: NativeScriptError console.log("NativeScript Error: ", args.error); }; - on(uncaughtErrorEvent, uncaughtErrorListener); + Application.on(Application.uncaughtErrorEvent, uncaughtErrorListener); // << application-events-error-ng } } diff --git a/app/ng-framework-modules-category/application/application-examples.module.ts b/app/ng-framework-modules-category/application/application-examples.module.ts index 9433333e..cc7032b1 100644 --- a/app/ng-framework-modules-category/application/application-examples.module.ts +++ b/app/ng-framework-modules-category/application/application-examples.module.ts @@ -1,6 +1,6 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; import { ApplicationExamplesComponent } from "./application-examples.component"; import { AppCheckingTargetExampleComponent } from "./app-checking-target/app-checking-target.component"; import { AppUsingAndroidExampleComponent } from "./app-using-android-specifics/app-using-android-specifics.component"; diff --git a/app/ng-framework-modules-category/color/color-examples.module.ts b/app/ng-framework-modules-category/color/color-examples.module.ts index 1681965b..07f0ad33 100644 --- a/app/ng-framework-modules-category/color/color-examples.module.ts +++ b/app/ng-framework-modules-category/color/color-examples.module.ts @@ -1,7 +1,7 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; -import { NativeScriptFormsModule } from "nativescript-angular/forms"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; +import { NativeScriptFormsModule } from "@nativescript/angular"; import { ColorExamplesComponent } from "./color-examples.component"; import { UsageComponent } from "./usage/usage.component"; import { TitleAndNavButtonModule } from "../../directives/title-and-nav-button.module"; diff --git a/app/ng-framework-modules-category/color/usage/usage.component.ts b/app/ng-framework-modules-category/color/usage/usage.component.ts index a8a24d92..66a57d05 100644 --- a/app/ng-framework-modules-category/color/usage/usage.component.ts +++ b/app/ng-framework-modules-category/color/usage/usage.component.ts @@ -1,9 +1,8 @@ // tslint:disable:no-bitwise // >> creating-colors-code import { Component } from "@angular/core"; -import { Color } from "tns-core-modules/color"; -import * as colors from "tns-core-modules/color/known-colors"; -import { isKnownName } from "tns-core-modules/color/known-colors"; +import { OrangeRed, isKnownName } from "@nativescript/core/color/known-colors"; +import { Color } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -31,7 +30,7 @@ export class UsageComponent { } // Using supported known colors from tns-core-modules/color/known-colors - let colorKnownName = new Color(colors.OrangeRed); + let colorKnownName = new Color(OrangeRed); } } // << creating-colors-code diff --git a/app/ng-framework-modules-category/connectivity/connectivity-examples.module.ts b/app/ng-framework-modules-category/connectivity/connectivity-examples.module.ts index 3703d689..e0e1b4d3 100644 --- a/app/ng-framework-modules-category/connectivity/connectivity-examples.module.ts +++ b/app/ng-framework-modules-category/connectivity/connectivity-examples.module.ts @@ -1,6 +1,6 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; import { ConnectivityExamplesComponent } from "./connectivity-examples.component"; import { UsageComponent } from "./usage/usage.component"; import { TitleAndNavButtonModule } from "../../directives/title-and-nav-button.module"; diff --git a/app/ng-framework-modules-category/connectivity/usage/usage.component.ts b/app/ng-framework-modules-category/connectivity/usage/usage.component.ts index 609d86f7..54fc925e 100644 --- a/app/ng-framework-modules-category/connectivity/usage/usage.component.ts +++ b/app/ng-framework-modules-category/connectivity/usage/usage.component.ts @@ -1,11 +1,6 @@ // >> connectivity-start-code import { Component, OnInit, OnDestroy } from "@angular/core"; -import { - getConnectionType, - startMonitoring, - stopMonitoring -} from "tns-core-modules/connectivity"; -import * as connectivityModule from "tns-core-modules/connectivity"; +import { Connectivity } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -16,19 +11,19 @@ export class UsageComponent implements OnInit, OnDestroy { connectionType: string; constructor() { - let type = getConnectionType(); + let type = Connectivity.getConnectionType(); switch (type) { - case connectivityModule.connectionType.none: + case Connectivity.connectionType.none: this.connectionType = "None"; break; - case connectivityModule.connectionType.wifi: + case Connectivity.connectionType.wifi: this.connectionType = "Wi-Fi"; break; - case connectivityModule.connectionType.mobile: + case Connectivity.connectionType.mobile: this.connectionType = "Mobile"; break; - case connectivityModule.connectionType.bluetooth: + case Connectivity.connectionType.bluetooth: this.connectionType = "Bluetooth"; break; default: @@ -37,21 +32,21 @@ export class UsageComponent implements OnInit, OnDestroy { } ngOnInit() { - startMonitoring((type) => { + Connectivity.startMonitoring((type) => { switch (type) { - case connectivityModule.connectionType.none: + case Connectivity.connectionType.none: this.connectionType = "None"; console.log("Connection type changed to none."); break; - case connectivityModule.connectionType.wifi: + case Connectivity.connectionType.wifi: this.connectionType = "Wi-Fi"; console.log("Connection type changed to WiFi."); break; - case connectivityModule.connectionType.mobile: + case Connectivity.connectionType.mobile: this.connectionType = "Mobile"; console.log("Connection type changed to mobile."); break; - case connectivityModule.connectionType.bluetooth: + case Connectivity.connectionType.bluetooth: this.connectionType = "Bluetooth"; console.log("Connection type changed to Bluetooth."); break; @@ -63,7 +58,7 @@ export class UsageComponent implements OnInit, OnDestroy { ngOnDestroy() { // Stoping the connection monitoring - stopMonitoring(); + Connectivity.stopMonitoring(); } } // << connectivity-start-code diff --git a/app/ng-framework-modules-category/file-system/delete/delete.component.ts b/app/ng-framework-modules-category/file-system/delete/delete.component.ts index 6444b49a..cb2d3528 100644 --- a/app/ng-framework-modules-category/file-system/delete/delete.component.ts +++ b/app/ng-framework-modules-category/file-system/delete/delete.component.ts @@ -1,6 +1,6 @@ import { Component } from "@angular/core"; // >> fs-delete-import-code -import { File, Folder, knownFolders } from "tns-core-modules/file-system"; +import { File, Folder, knownFolders } from "@nativescript/core"; // << fs-delete-import-code @Component({ moduleId: module.id, diff --git a/app/ng-framework-modules-category/file-system/file-system-examples.module.ts b/app/ng-framework-modules-category/file-system/file-system-examples.module.ts index 67e64f8e..b7daff3e 100644 --- a/app/ng-framework-modules-category/file-system/file-system-examples.module.ts +++ b/app/ng-framework-modules-category/file-system/file-system-examples.module.ts @@ -1,6 +1,6 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; import { FileSystemExamplesComponent } from "./file-system-examples.component"; import { CreateExampleComponent } from "./usage/usage.component"; import { DeleteExampleComponent } from "./delete/delete.component"; diff --git a/app/ng-framework-modules-category/file-system/paths/paths.component.ts b/app/ng-framework-modules-category/file-system/paths/paths.component.ts index c4f5f720..0f7229cc 100644 --- a/app/ng-framework-modules-category/file-system/paths/paths.component.ts +++ b/app/ng-framework-modules-category/file-system/paths/paths.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from "@angular/core"; // >> fs-paths-import-code -import { knownFolders, path, File, Folder } from "tns-core-modules/file-system"; +import { knownFolders, path, File, Folder } from "@nativescript/core"; // << fs-paths-import-code @Component({ diff --git a/app/ng-framework-modules-category/file-system/read/read.component.ts b/app/ng-framework-modules-category/file-system/read/read.component.ts index 4078311d..ac3356bf 100644 --- a/app/ng-framework-modules-category/file-system/read/read.component.ts +++ b/app/ng-framework-modules-category/file-system/read/read.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from "@angular/core"; -import * as imageSource from "tns-core-modules/image-source"; +import { ImageSource } from "@nativescript/core"; // >> fs-read-import-code -import { knownFolders, path, File, Folder } from "tns-core-modules/file-system"; +import { knownFolders, path, File, Folder } from "@nativescript/core"; // << fs-read-import-code @Component({ @@ -81,7 +81,7 @@ export class ReadExampleComponent implements OnInit { public onReadSync() { // >> fs-read-sync-code - let image = imageSource.fromResource("icon"); + let image = ImageSource.fromResourceSync("icon"); let folder = knownFolders.documents(); let myPath = path.join(folder.path, "Test.png"); let saved = image.saveToFile(myPath, "png"); diff --git a/app/ng-framework-modules-category/file-system/update/update.component.ts b/app/ng-framework-modules-category/file-system/update/update.component.ts index 90d535df..8f9f75ae 100644 --- a/app/ng-framework-modules-category/file-system/update/update.component.ts +++ b/app/ng-framework-modules-category/file-system/update/update.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from "@angular/core"; // >> fs-update-import-code -import { knownFolders, path, File, Folder } from "tns-core-modules/file-system"; +import { knownFolders, path, File, Folder } from "@nativescript/core"; // << fs-update-import-code @Component({ moduleId: module.id, diff --git a/app/ng-framework-modules-category/file-system/usage/usage.component.ts b/app/ng-framework-modules-category/file-system/usage/usage.component.ts index c4643040..1349c6de 100644 --- a/app/ng-framework-modules-category/file-system/usage/usage.component.ts +++ b/app/ng-framework-modules-category/file-system/usage/usage.component.ts @@ -1,6 +1,6 @@ import { Component } from "@angular/core"; // >> fs-create-import-code -import { knownFolders, path, File, Folder } from "tns-core-modules/file-system"; +import { knownFolders, path, File, Folder } from "@nativescript/core"; // << fs-create-import-code @Component({ diff --git a/app/ng-framework-modules-category/fps-meter/fps-meter-examples.module.ts b/app/ng-framework-modules-category/fps-meter/fps-meter-examples.module.ts index 76262ce7..bd06ca63 100644 --- a/app/ng-framework-modules-category/fps-meter/fps-meter-examples.module.ts +++ b/app/ng-framework-modules-category/fps-meter/fps-meter-examples.module.ts @@ -1,7 +1,7 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; -import { NativeScriptFormsModule } from "nativescript-angular/forms"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; +import { NativeScriptFormsModule } from "@nativescript/angular"; import { FpsExamplesComponent } from "./fps-meter-examples.component"; diff --git a/app/ng-framework-modules-category/fps-meter/usage/usage.component.ts b/app/ng-framework-modules-category/fps-meter/usage/usage.component.ts index acdb1a6d..6250ff45 100644 --- a/app/ng-framework-modules-category/fps-meter/usage/usage.component.ts +++ b/app/ng-framework-modules-category/fps-meter/usage/usage.component.ts @@ -1,6 +1,6 @@ // >> fps-meter-module-usage import { Component, NgZone } from "@angular/core"; -import { start, removeCallback, addCallback, stop } from "tns-core-modules/fps-meter"; +import { start, removeCallback, addCallback, stop } from "@nativescript/core/fps-meter"; @Component({ moduleId: module.id, diff --git a/app/ng-framework-modules-category/http/http-examples.module.ts b/app/ng-framework-modules-category/http/http-examples.module.ts index ebfb0fd4..cbb02268 100644 --- a/app/ng-framework-modules-category/http/http-examples.module.ts +++ b/app/ng-framework-modules-category/http/http-examples.module.ts @@ -1,8 +1,8 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; -import { NativeScriptFormsModule } from "nativescript-angular/forms"; -import { NativeScriptHttpClientModule } from "nativescript-angular/http-client"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; +import { NativeScriptFormsModule } from "@nativescript/angular"; +import { NativeScriptHttpClientModule } from "@nativescript/angular"; import { HttpExamplesComponent } from "./http-examples.component"; diff --git a/app/ng-framework-modules-category/http/overview.md b/app/ng-framework-modules-category/http/overview.md index 566548e8..305a1f64 100644 --- a/app/ng-framework-modules-category/http/overview.md +++ b/app/ng-framework-modules-category/http/overview.md @@ -1,7 +1,7 @@ In order to use the Angular's `HttpClient` module the first thing to do is to import our NativeScript wrapper in the respective module file. ```TypeScript -import { NativeScriptHttpClientModule } from "nativescript-angular/http-client"; +import { NativeScriptHttpClientModule } from "@nativescript/angular"; @NgModule({ imports: [ @@ -9,4 +9,4 @@ import { NativeScriptHttpClientModule } from "nativescript-angular/http-client"; ] ``` -> **Note:** The `HttpClient` is Angular module that comes from `@angular/common/http`. However, you will need to import the NativeScript wrapper (`NativeScriptHttpClientModule`) to be able to work with the `HttpClient` module. \ No newline at end of file +> **Note:** The `HttpClient` is Angular module that comes from `@angular/common/http`. However, you will need to import the NativeScript wrapper (`NativeScriptHttpClientModule`) to be able to work with the `HttpClient` module. diff --git a/app/ng-framework-modules-category/platform/platform-examples.module.ts b/app/ng-framework-modules-category/platform/platform-examples.module.ts index e8aa439f..81ae195d 100644 --- a/app/ng-framework-modules-category/platform/platform-examples.module.ts +++ b/app/ng-framework-modules-category/platform/platform-examples.module.ts @@ -1,6 +1,6 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; import { PlatformExamplesComponent } from "./platform-examples.component"; import { PlatformModuleExampleComponent } from "./usage/platform-module-example"; import { TitleAndNavButtonModule } from "../../directives/title-and-nav-button.module"; diff --git a/app/ng-framework-modules-category/platform/usage/platform-module-example.ts b/app/ng-framework-modules-category/platform/usage/platform-module-example.ts index 221dc9ed..19008349 100644 --- a/app/ng-framework-modules-category/platform/usage/platform-module-example.ts +++ b/app/ng-framework-modules-category/platform/usage/platform-module-example.ts @@ -1,7 +1,7 @@ // tslint:disable:max-line-length // >> import-platform-module import { Component } from "@angular/core"; -import { isAndroid, isIOS, device, screen } from "tns-core-modules/platform"; +import { isAndroid, isIOS, Device, Screen } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -13,21 +13,21 @@ export class PlatformModuleExampleComponent { console.log(`Running on Android? ${isAndroid}`); console.log(`Running on iOS? ${isIOS}`); - console.log(`device.model ${device.model}`); // For example: "Nexus 5" or "iPhone". - console.log(`device.deviceType ${device.deviceType}`); // "Phone" | "Tablet" - console.log(`device.os ${device.os}`); // For example: "Android" or "iOS". - console.log(`device.osVersion ${device.osVersion}`); // For example: 4.4.4(android), 8.1(ios) - console.log(`device.sdkVersion ${device.sdkVersion}`); // For example: 19(android), 8.1(ios). - console.log(`device.language ${device.language}`); // For example "en" or "en-US". - console.log(`device.manufacturer ${device.manufacturer}`); // For example: "Apple" or "HTC" or "Samsung". - console.log(`device.uuid ${device.uuid}`); // The unique identification number - console.log(`device.region ${device.region}`); // For example "US". + console.log(`device.model ${Device.model}`); // For example: "Nexus 5" or "iPhone". + console.log(`device.deviceType ${Device.deviceType}`); // "Phone" | "Tablet" + console.log(`device.os ${Device.os}`); // For example: "Android" or "iOS". + console.log(`device.osVersion ${Device.osVersion}`); // For example: 4.4.4(android), 8.1(ios) + console.log(`device.sdkVersion ${Device.sdkVersion}`); // For example: 19(android), 8.1(ios). + console.log(`device.language ${Device.language}`); // For example "en" or "en-US". + console.log(`device.manufacturer ${Device.manufacturer}`); // For example: "Apple" or "HTC" or "Samsung". + console.log(`device.uuid ${Device.uuid}`); // The unique identification number + console.log(`device.region ${Device.region}`); // For example "US". - console.log(`screen.mainScreen.heightDIPs ${screen.mainScreen.heightDIPs}`); // The absolute height of the screen in density independent pixels. - console.log(`screen.mainScreen.heightPixels ${screen.mainScreen.heightPixels}`); // The absolute height of the screen in pixels. - console.log(`screen.mainScreen.scale ${screen.mainScreen.scale}`); // The logical density of the display. - console.log(`screen.mainScreen.widthDIPs ${screen.mainScreen.widthDIPs}`); // The absolute width of the screen in density independent pixels. - console.log(`screen.mainScreen.widthPixels ${screen.mainScreen.widthPixels}`); // The absolute width of the screen in pixel + console.log(`screen.mainScreen.heightDIPs ${Screen.mainScreen.heightDIPs}`); // The absolute height of the screen in density independent pixels. + console.log(`screen.mainScreen.heightPixels ${Screen.mainScreen.heightPixels}`); // The absolute height of the screen in pixels. + console.log(`screen.mainScreen.scale ${Screen.mainScreen.scale}`); // The logical density of the display. + console.log(`screen.mainScreen.widthDIPs ${Screen.mainScreen.widthDIPs}`); // The absolute width of the screen in density independent pixels. + console.log(`screen.mainScreen.widthPixels ${Screen.mainScreen.widthPixels}`); // The absolute width of the screen in pixel } } // << import-platform-module diff --git a/app/ng-framework-modules-category/routing/routing-examples.module.ts b/app/ng-framework-modules-category/routing/routing-examples.module.ts index 914ececf..286d6329 100644 --- a/app/ng-framework-modules-category/routing/routing-examples.module.ts +++ b/app/ng-framework-modules-category/routing/routing-examples.module.ts @@ -1,7 +1,7 @@ import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core"; -import { NativeScriptRouterModule } from "nativescript-angular/router"; -import { NativeScriptCommonModule } from "nativescript-angular/common"; -import { NativeScriptFormsModule } from "nativescript-angular/forms"; +import { NativeScriptRouterModule } from "@nativescript/angular"; +import { NativeScriptCommonModule } from "@nativescript/angular"; +import { NativeScriptFormsModule } from "@nativescript/angular"; import { RoutingExamplesComponent } from "./routing-examples.component"; import { NestedRoutersComponent } from "./nested-routers/nested-routers.component"; diff --git a/app/ng-framework-modules-category/timer/set-interval/setinterval-example.ts b/app/ng-framework-modules-category/timer/set-interval/setinterval-example.ts index 1caba399..7f2c5585 100644 --- a/app/ng-framework-modules-category/timer/set-interval/setinterval-example.ts +++ b/app/ng-framework-modules-category/timer/set-interval/setinterval-example.ts @@ -1,6 +1,6 @@ import { Component } from "@angular/core"; -import { setInterval, clearInterval } from "tns-core-modules/timer"; +import { Utils } from "@nativescript/core"; @Component({ moduleId: module.id, @@ -19,7 +19,7 @@ export class SetIntervalComponent { let that = this; // >> set-interval-example - this.id = setInterval(() => { + this.id = Utils.setInterval(() => { let randNumber = Math.floor(Math.random() * (that.color.length)); that.buttoncolor = that.color[randNumber]; }, 1000); @@ -28,13 +28,13 @@ export class SetIntervalComponent { public onButtonTap(args) { if (this.status) { - clearInterval(this.id); + Utils.clearInterval(this.id); this.status = false; this.buttonText = "Enable color change"; } else { let that = this; - this.id = setInterval(() => { + this.id = Utils.setInterval(() => { let randNumber = Math.floor(Math.random() * (that.color.length)); that.buttoncolor = that.color[randNumber]; }, 1000); diff --git a/app/ng-framework-modules-category/timer/set-timeout/settimeout-example.ts b/app/ng-framework-modules-category/timer/set-timeout/settimeout-example.ts index 18926410..509167db 100644 --- a/app/ng-framework-modules-category/timer/set-timeout/settimeout-example.ts +++ b/app/ng-framework-modules-category/timer/set-timeout/settimeout-example.ts @@ -1,9 +1,5 @@ - import { Component } from "@angular/core"; -import { EventData } from "tns-core-modules/data/observable"; -import { setTimeout } from "tns-core-modules/timer"; -import { Color } from "tns-core-modules/color"; -import { Button } from "tns-core-modules/ui/button"; +import { Button, Color, EventData, Utils } from "@nativescript/core"; @Component({ moduleId: module.id, styleUrls: ["./settimeout-example.css"], @@ -16,7 +12,7 @@ export class SetTimeoutComponent { let button =