Skip to content

Commit 4d1e4a1

Browse files
authored
feat: NS7 update (#456)
* chore: migration * fix: @nativescript/core imports * fix: nativescript-angular imports * fix: imports * chore: add skipLibCheck to tsconfig.json * fix: nativeClass * fix: imports and tsconfig update
1 parent 3470b07 commit 4d1e4a1

File tree

139 files changed

+671
-641
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+671
-641
lines changed

app/app.component.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Component, AfterViewInit } from "@angular/core";
2-
import { hasKey, getString, remove } from "tns-core-modules/application-settings";
3-
import { RouterExtensions } from "nativescript-angular/router";
4-
import * as app from "tns-core-modules/application";
2+
import { RouterExtensions } from "@nativescript/angular";
3+
import { Application, ApplicationEventData, ApplicationSettings } from "@nativescript/core";
54
import { DeepLinkData } from "./shared/deep-link-data";
65
@Component({
76
moduleId: module.id,
@@ -13,7 +12,7 @@ export class AppComponent implements AfterViewInit {
1312
constructor(private router: RouterExtensions) { }
1413

1514
ngAfterViewInit() {
16-
app.on(app.resumeEvent, (args: app.ApplicationEventData) => {
15+
Application.on(Application.resumeEvent, (args: ApplicationEventData) => {
1716
if (args.android) {
1817
const dld = new DeepLinkData("", args.android);
1918
this.launchExample();
@@ -23,9 +22,9 @@ export class AppComponent implements AfterViewInit {
2322
});
2423
}
2524
public launchExample() {
26-
if (hasKey("gotoexample")) {
27-
let value = getString("gotoexample");
28-
remove("gotoexample");
25+
if (ApplicationSettings.hasKey("gotoexample")) {
26+
let value = ApplicationSettings.getString("gotoexample");
27+
ApplicationSettings.remove("gotoexample");
2928
this.router.navigate([value]);
3029
}
3130
}

app/app.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// >> ngmodule-config
22
// this import should be first in order to load some required settings (like globals and reflect-metadata)
3-
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
3+
import { NativeScriptModule } from "@nativescript/angular";
44
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
5-
import { NativeScriptRouterModule } from "nativescript-angular/router";
6-
import { NativeScriptFormsModule } from "nativescript-angular/forms";
5+
import { NativeScriptRouterModule } from "@nativescript/angular";
6+
import { NativeScriptFormsModule } from "@nativescript/angular";
77
import { routes } from "./app.routes";
88
import { AppComponent } from "./app.component";
9-
import { ModalDialogService } from "nativescript-angular/modal-dialog";
9+
import { ModalDialogService } from "@nativescript/angular";
1010

1111
@NgModule({
1212
schemas: [NO_ERRORS_SCHEMA],

app/delegate/my-delegate.ios.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { DeepLinkData } from "../shared/deep-link-data";
2-
export class MyDelegate extends UIResponder implements UIApplicationDelegate {
2+
3+
@NativeClass
4+
class MyDelegate extends UIResponder implements UIApplicationDelegate {
35
// tslint:disable-next-line
46
public static ObjCProtocols = [UIApplicationDelegate];
57

@@ -8,3 +10,6 @@ export class MyDelegate extends UIResponder implements UIApplicationDelegate {
810
return true;
911
}
1012
}
13+
14+
export {MyDelegate};
15+

app/directives/example.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Directive } from "@angular/core";
22
import { ActivatedRoute } from "@angular/router";
3-
import { Page } from "tns-core-modules/ui/page";
3+
import { Page } from "@nativescript/core";
44

55
@Directive({
66
selector: "[sdkExampleTitle]"

app/directives/toggle-nav-button.directive.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { ActivatedRoute } from "@angular/router";
22
import { Directive, OnInit } from "@angular/core";
3-
import { EventData } from "tns-core-modules/data/observable";
4-
import { NavigationButton } from "tns-core-modules/ui/action-bar";
5-
import { Page } from "tns-core-modules/ui/page";
6-
import { RouterExtensions } from "nativescript-angular/router";
7-
import * as app from "tns-core-modules/application";
3+
import { EventData, NavigationButton, Page, isAndroid, isIOS } from "@nativescript/core";
4+
import { RouterExtensions } from "@nativescript/angular";
85

96
@Directive({
107
selector: "[sdkToggleNavButton]"
@@ -23,12 +20,12 @@ export class ToggleNavButtonDirective implements OnInit {
2320
let navigationButton = new NavigationButton();
2421
navigationButton.visibility = "visible";
2522

26-
if (app.android) {
23+
if (isAndroid) {
2724
navigationButton.icon = "res://ic_arrow_back_black_24dp";
2825
navigationButton.on("tap", (args: EventData) => {
2926
this.routerExtensions.backToPreviousPage();
3027
});
31-
} else if (app.ios) {
28+
} else if (isIOS) {
3229
navigationButton.text = "";
3330
}
3431

app/examples-list.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2-
import { NativeScriptRouterModule } from "nativescript-angular/router";
3-
import { NativeScriptCommonModule } from "nativescript-angular/common";
2+
import { NativeScriptRouterModule } from "@nativescript/angular";
3+
import { NativeScriptCommonModule } from "@nativescript/angular";
44
import { ExamplesListComponent } from "./examples-list.component";
55
import { TitleAndNavButtonModule } from "./directives/title-and-nav-button.module";
66

app/main.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
1+
import { platformNativeScriptDynamic } from "@nativescript/angular";
22
import { AppModule } from "./app.module";
3-
import { ios } from "tns-core-modules/application";
4-
import { isIOS } from "tns-core-modules/platform";
3+
import { Application } from "@nativescript/core";
4+
import { isIOS } from "@nativescript/core";
55
import { MyDelegate } from "./delegate/my-delegate";
66

77
if (isIOS) {
8-
ios.delegate = MyDelegate;
8+
Application.ios.delegate = MyDelegate;
99
}
1010
platformNativeScriptDynamic().bootstrapModule(AppModule);

app/ng-framework-modules-category/application-settings/application-settings-examples.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2-
import { NativeScriptRouterModule } from "nativescript-angular/router";
3-
import { NativeScriptCommonModule } from "nativescript-angular/common";
2+
import { NativeScriptRouterModule } from "@nativescript/angular";
3+
import { NativeScriptCommonModule } from "@nativescript/angular";
44
import { ApplicationSettingsExamplesComponent } from "./application-settings-examples.component";
55
import { UsageComponent } from "./usage/usage.component";
66
import { TitleAndNavButtonModule } from "../../directives/title-and-nav-button.module";
Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
// >> app-settings-code
22
import { Component } from "@angular/core";
3-
import {
4-
getBoolean,
5-
setBoolean,
6-
getNumber,
7-
setNumber,
8-
getString,
9-
setString,
10-
hasKey,
11-
remove,
12-
clear
13-
} from "tns-core-modules/application-settings";
3+
import { ApplicationSettings } from "@nativescript/core";
144

155
@Component({
166
moduleId: module.id,
@@ -19,27 +9,27 @@ import {
199
export class UsageComponent {
2010

2111
constructor() {
22-
setBoolean("isTurnedOn", true);
23-
setString("username", "Wolfgang");
24-
setNumber("locationX", 54.321);
12+
ApplicationSettings.setBoolean("isTurnedOn", true);
13+
ApplicationSettings.setString("username", "Wolfgang");
14+
ApplicationSettings.setNumber("locationX", 54.321);
2515

26-
const isTurnedOn: boolean = getBoolean("isTurnedOn");
27-
const username: string = getString("username");
28-
const locationX: number = getNumber("locationX");
16+
const isTurnedOn: boolean = ApplicationSettings.getBoolean("isTurnedOn");
17+
const username: string = ApplicationSettings.getString("username");
18+
const locationX: number = ApplicationSettings.getNumber("locationX");
2919

3020
// Will return "No string value" if there is no value for "noSuchKey"
31-
const someKey: string = getString("noSuchKey", "No string value");
21+
const someKey: string = ApplicationSettings.getString("noSuchKey", "No string value");
3222

3323
// Will return false if there is no key with name "noSuchKey"
34-
let isKeExisting: boolean = hasKey("noSuchKey");
24+
let isKeExisting: boolean = ApplicationSettings.hasKey("noSuchKey");
3525
}
3626

3727
onClearß() {
3828
// Removing a single entry via its key name
39-
remove("isTurnedOn");
29+
ApplicationSettings.remove("isTurnedOn");
4030

4131
// Clearing the whole application-settings for this app
42-
clear();
32+
ApplicationSettings.clear();
4333
}
4434
}
4535
// << app-settings-code

app/ng-framework-modules-category/application/app-checking-target/app-checking-target.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// >> app-check-target-code
22
import { Component } from "@angular/core";
3-
import { android as androidApp, ios as iosApp } from "tns-core-modules/application";
3+
import { isAndroid, isIOS } from "@nativescript/core";
44

55
@Component({
66
moduleId: module.id,
@@ -10,10 +10,10 @@ export class AppCheckingTargetExampleComponent {
1010
public isItemVisible: boolean;
1111

1212
constructor() {
13-
if (androidApp) {
13+
if (isAndroid) {
1414
console.log("We are running on Android device!");
1515
this.isItemVisible = true;
16-
} else if (iosApp) {
16+
} else if (isIOS) {
1717
console.log("We are running on iOS device");
1818
this.isItemVisible = false;
1919
}

0 commit comments

Comments
 (0)