8000 feat: add angular 19 support by edusperoni · Pull Request #143 · NativeScript/angular · GitHub
[go: up one dir, main page]

Skip to content

feat: add angular 19 support #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/nativescript-demo-ng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"devDependencies": {
"@nativescript/android": "~8.8.0",
"@nativescript/ios": "~8.8.0",
"@nativescript/tailwind": "^2.1.0",
"@nativescript/unit-test-runner": "^3.0.1"
}
}
48 changes: 11 additions & 37 deletions apps/nativescript-demo-ng/project.json
8000
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,20 @@
}
}
},
"ios": {
"executor": "@nativescript/nx:build",
"options": {
"platform": "ios"
},
"configurations": {
"build": {
"copyTo": "./dist/build.ipa"
},
"prod": {
"combineWithConfig": "build:prod"
}
}
},
"android": {
"executor": "@nativescript/nx:build",
"debug": {
"executor": "@nativescript/nx:debug",
"options": {
"platform": "android"
"noHmr": true,
"uglify": false,
"release": false,
"forDevice": false,
"prepare": false
},
"configurations": {
"build": {
"copyTo": "./dist/build.apk"
},
"prod": {
"combineWithConfig": "build:prod"
}
}
"dependsOn": ["^build"]
},
"clean": {
"executor": "@nativescript/nx:build",
"options": {
"clean": true
}
"executor": "@nativescript/nx:clean",
"options": {}
},
"lint": {
"executor": "@nx/eslint:lint"
Expand All @@ -74,14 +55,7 @@
"options": {
"coverage": false
},
"configurations": {
"android": {
"platform": "android"
},
"ios": {
"platform": "ios"
}
}
"configurations": {}
}
}
}
18 changes: 14 additions & 4 deletions apps/nativescript-demo-ng/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ In many cases you may want to use the NativeScript core theme instead
of writing your own CSS rules. For a full list of class names in the theme
refer to http://docs.nativescript.org/ui/theme.
*/
@import '@nativescript/theme/css/core.css';
@import '@nativescript/theme/css/default.css';
/* @import '@nativescript/theme/css/core.css';
@import '@nativescript/theme/css/default.css'; */
@tailwind base;
@tailwind components;
@tailwind utilities;

Button {
border: 0;
Expand All @@ -23,11 +26,18 @@ Button {
color: #fff;
}

.h1 {
.h-center {
horizontal-align: center;
}
.h-right {
horizontal-align: right;
}

/* .h1 {
font-weight: bold;
margin: 10 0 0;
}

.c-light-blue {
color: #65ADF1;
}
} */
1 change: 1 addition & 0 deletions apps/nativescript-demo-ng/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Component, ViewContainerRef, OnInit, OnDestroy } from '@angular/core';
selector: 'ns-app',
moduleId: module.id,
templateUrl: './app.component.html',
standalone: false,
})
export class AppComponent implements OnInit, OnDestroy {
constructor(private vcRef: ViewContainerRef) {}
Expand Down
6 changes: 3 additions & 3 deletions apps/nativescript-demo-ng/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import { ModalComponent } from './modal/modal.component';
],
declarations: [
AppComponent,
ItemsComponent,
ItemDetailComponent,
ModalComponent,
// ItemsComponent,
// ItemDetailComponent,
// ModalComponent,
// HomeComponent
],
providers: [],
Expand Down
2 changes: 1 addition & 1 deletion apps/nativescript-demo-ng/src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<MDBottomNavigation selectedIndex="0" (loaded)="loadedTabView($event)" (selectedIndexChange)="onIndexChanged($event)">
<MDTabStrip class="c-tabs">
<MDTabStripItem class="tabstripitem">
<Label [text]="tabItems?.start?.title" class="text-center t-12"></Label>
<Label [text]="tabItems?.start?.title" class="text-center text-sm"></Label>
</MDTabStripItem>
</MDTabStrip>

Expand Down
4 changes: 3 additions & 1 deletion apps/nativescript-demo-ng/src/app/home/home.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Component, NgZone, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { RouterExtensions } from '@nativescript/angular';
import { RouterExtensions, NativeScriptCommonModule } from '@nativescript/angular';
import { Page, TabView } from '@nativescript/core';

@Component({
moduleId: module.id,
selector: 'demo-home',
templateUrl: './home.component.html',
imports: [NativeScriptCommonModule],
standalone: true,
})
export class HomeComponent implements OnInit {
tabItems: { [key: string]: { index: number; title?: string; iconSource?: string; textTransform?: string } } = {};
Expand Down
10 changes: 7 additions & 3 deletions apps/nativescript-demo-ng/src/app/item/item-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { Component, NO_ERRORS_SCHEMA, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { Item } from './item';
import { ItemService } from './item.service';
import { NativeScriptCommonModule } from '@nativescript/angular';

@Component({
selector: 'ns-details',
moduleId: module.id,
templateUrl: './item-detail.component.html'
templateUrl: './item-detail.component.html',
imports: [NativeScriptCommonModule],
standalone: true,
schemas: [NO_ERRORS_SCHEMA]
})
export class ItemDetailComponent implements OnInit {
item: Item;

constructor(
private itemService: ItemService,
private route: ActivatedRoute
private route: ActivatedRoute,
) {}

ngOnInit(): void {
Expand Down
14 changes: 7 additions & 7 deletions apps/nativescript-demo-ng/src/app/item/items.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
class names available for styling your app at https://docs.nativescript.org/ui/theme.
-->
<GridLayout rows="auto,,*" class="page">
<StackLayout row="0" padding="10">
<Label [text]="message" class="h1 text-center c-light-blue"></Label>
<Label [text]="'NativeScript loves you.'" class="h2 text-center c-light-blue" marginTop="20" marginBottom="5"></Label>
<Image src="https://angular.io/assets/images/logos/angular/angular.png" horizontalAlignment="center" width="120" verticalAlignment="top"></Image>
<Button (tap)="openModal()" text="Open Modal" class="-btn -primary"></Button>
<Button (tap)="fetchTodos()" text="Make Http Call" class="-btn -primary"></Button>
<StackLayout row="0" class="p-4">
<Label [text]="message" class="text-3xl font-bold text-center text-blue-500"></Label>
<Label [text]="'NativeScript loves you.'" class="text-2xl mt-5 text-center text-blue-500"></Label>
<Image src="https://angular.io/assets/images/logos/angular/angular.png" class="align-top h-center mt-4 w-[120]"></Image>
<Button (tap)="openModal()" text="Open Modal" class="rounded-full bg-blue-500 text-white p-2"></Button>
<Button (tap)="fetchTodos()" text="Make Http Call" class="mt-2 rounded-full bg-blue-500 text-white p-2"></Button>
</StackLayout>
<ListView row="1" [items]="items" class="list-group" backgroundColor="#efefef">
<ng-template let-item="item">
<StackLayout [nsRouterLink]="['/item2/item', item.id]" padding="10">
<StackLayout [nsRouterLink]="['/item2/item', item.id]" class="p-2">
<Label [text]="item.name" class="list-group-item"></Label>
</StackLayout>
</ng-template>
Expand Down
9 changes: 6 additions & 3 deletions apps/nativescript-demo-ng/src/app/item/items.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, NO_ERRORS_SCHEMA } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Item } from './item';
import { ItemService } from './item.service';
import { ModalComponent } from '../modal/modal.component';
import { ModalDialogService, NativeDialogService } from '@nativescript/angular';
import { ModalDialogService, NativeDialogService, NativeScriptCommonModule } from '@nativescript/angular';

@Component({
selector: 'ns-items',
moduleId: module.id,
templateUrl: './items.component.html',
imports: [NativeScriptCommonModule],
standalone: true,
schemas: [NO_ERRORS_SCHEMA]
})
export class ItemsComponent implements OnInit, OnDestroy {
message = 'Hello Angular 18!';
message = 'Hello Angular 19!';
items: Array<Item>;

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<Button text="GO BACK!" (tap)="goBack()"></Button>
</FlexboxLayout> -->

<GridLayout class="page" rows="auto,*" padding="10">
<GridLayout class="page" rows="auto,*" class="p-2">
<!-- <Label marginTop="20" fontSize="18" textAlignment="center" [text]="item.name"></Label> -->
<GridLayout row="1" rows="auto,auto" columns="">
<Label marginTop="20" fontSize="45" text="Congrats to the Angular Team!" class="c-light-blue" textWrap="true" textAlignment="center" fontWeight="bold"></Label>
<Label row="1" marginTop="20" fontSize="35" text="👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏" class="c-light-blue" textWrap="true" textAlignment="center" textWrap="true"></Label>
<Label text="Congrats to the Angular Team!" textWrap="true" class="text-center mt-5 font-bold text-3xl text-blue-500"></Label>
<Label row="1" text="👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏" textWrap="true" class="text-blue-500 text-center mt-5 text-3xl"></Label>
</GridLayout>
</GridLayout>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, NO_ERRORS_SCHEMA } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { RouterExtensions } from '@nativescript/angular';
import { NativeScriptCommonModule, RouterExtensions } from '@nativescript/angular';

import { Item } from '../item/item';
import { ItemService } from '../item/item.service';
Expand All @@ -9,6 +9,9 @@ import { ItemService } from '../item/item.service';
selector: 'ns-details2',
moduleId: module.id,
templateUrl: './item-detail2.component.html',
imports: [NativeScriptCommonModule],
standalone: true,
schemas: [NO_ERRORS_SCHEMA]
})
export class ItemDetailComponent implements OnInit, OnDestroy {
item: Item;
Expand Down
2 changes: 1 addition & 1 deletion apps/nativescript-demo-ng/src/app/item2/item2.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Items2RoutingModule } from './item2-routing.module';

@NgModule({
imports: [NativeScriptCommonModule, Items2RoutingModule],
declarations: [ItemDetailComponent],
// declarations: [ItemDetailComponent],
exports: [Items2RoutingModule],
schemas: [NO_ERRORS_SCHEMA],
})
Expand Down
4 changes: 2 additions & 2 deletions apps/nativescript-demo-ng/src/app/item3/item3.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { NativeScriptCommonModule } from '@nativescript/angular';
import { ItemsComponent } from './items.component';
// import { ItemsComponent } from './items.component';
import { Items2RoutingModule } from './item3-routing.module';

@NgModule({
imports: [NativeScriptCommonModule, Items2RoutingModule],
declarations: [ItemsComponent],
// declarations: [ItemsComponent],
exports: [Items2RoutingModule],
schemas: [NO_ERRORS_SCHEMA],
})
Expand Down
16 changes: 8 additions & 8 deletions apps/nativescript-demo-ng/src/app/item3/items.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
class names available for styling your app at https://docs.nativescript.org/ui/theme.
-->
<GridLayout rows="auto,,*" class="page">
<StackLayout row="0" padding="10">
<Label [text]="message" class="h1 text-center c-light-blue"></Label>
<Image src="~/assets/angular.png" horizontalAlignment="center" width="200" verticalAlignment="top" marginBottom="10"></Image>
<StackLayout row="0" class="p-4">
<Label [text]="message" class="text-3xl font-bold text-center text-blue-500"></Label>
<Image src="~/assets/angular.png" class="w-[200] h-center mb-2 align-top"></Image>
<!-- <Button (tap)="openModal()" text="Taste the Rainbow 🌈" [borderRadius]="borderRadius" [fontSize]="fontSize" backgroundColor="#00d2ff" color="#fff" margin="0" width="100%" fontWeight="bold" height="50"></Button> -->
<Button (tap)="openModal()" text="Open Modal" [borderRadius]="borderRadius" [fontSize]="fontSize" backgroundColor="#00d2ff" color="#fff" margin="0" width="100%" fontWeight="bold" height="50"></Button>
<Button (tap)="fetchTodos()" text="Make a native Http networking request" [borderRadius]="borderRadius" [fontSize]="fontSize" padding="0" backgroundColor="#00d2ff" color="#fff" marginTop="10" width="100%" fontWeight="bold" height="50"></Button>
<Button (tap)="openModal()" text="Open Modal" [borderRadius]="borderRadius" [fontSize]="fontSize" backgroundColor="#00d2ff" class="text-white w-full font-bold h-[50]"></Button>
<Button (tap)="fetchTodos()" text="Make a native Http networking request" [borderRadius]="borderRadius" [fontSize]="fontSize" padding="0" backgroundColor="#00d2ff" class="text-white mt-2 w-full font-bold h-[50]"></Button>
</StackLayout>
<ListView row="1" [items]="items" class="list-group" backgroundColor="#efefef">
<ListView row="1" [items]="items" backgroundColor="#efefef">
<ng-template let-item="item">
<StackLayout [nsRouterLink]="['/item2', item.id]" padding="10">
<Label [text]="item.name" class="list-group-item" fontSize="18" textAlignment="center"></Label>
<StackLayout [nsRouterLink]="['/item2', item.id]" class="p-4">
<Label [text]="item.name" class="text-lg text-center"></Label>
</StackLayout>
</ng-template>
</ListView>
Expand Down
9 changes: 6 additions & 3 deletions apps/nativescript-demo-ng/src/app/item3/items.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, NO_ERRORS_SCHEMA } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Item } from '../item/item';
import { ItemService } from '../item/item.service';
import { ModalComponent } from '../modal/modal.component';
import { ModalDialogService, NativeDialogService } from '@nativescript/angular';
import { ModalDialogService, NativeDialogService, NativeScriptCommonModule, NativeScriptRouterModule } from '@nativescript/angular';

@Component({
selector: 'ns-items',
moduleId: module.id,
templateUrl: './items.component.html',
imports: [NativeScriptCommonModule, NativeScriptRouterModule],
standalone: true,
schemas: [NO_ERRORS_SCHEMA]
})
export class ItemsComponent implements OnInit, OnDestroy {
message = 'Hello Angular 18';
message = 'Hello Angular 19';
items: Array<Item>;
borderRadius: number;
fontSize: number;
Expand Down
6 changes: 3 additions & 3 deletions apps/nativescript-demo-ng/src/app/modal/modal.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<GridLayout [backgroundColor]="'#d63681'" rows="*,auto,auto" padding="0" width="100%" height="100%">
<GridLayout [backgroundColor]="'#d63681'" rows="*,auto,auto">
<!-- <Image [src]="logo" stretch="aspectFit" width="200" marginTop="50" /> -->
<Image src="~/assets/ng-18.png" stretch="aspectFit" width="100%" marginTop="0" (loaded)="loadedImg($event)" />
<Image src="~/assets/ng-18.png" stretch="aspectFit" (loaded)="loadedImg($event)" class="w-full" />

<!-- @if (this.itemService.currentFlavor + 1 !== this.itemService.flavors.length) {
<Button row="1" (tap)="openNewModal()" text="Taste Another" fontSize="20" borderRadius="25"></Button>
} -->
<Button row="2" [nativeDialogClose]="'thanks for clicking modal ' + id" text="Close" fontSize="20" marginTop="30" borderRadius="25"></Button>
<Button row="2" [nativeDialogClose]="'thanks for clicking modal ' + id" text="Close" class="text-lg mt-8 rounded-3xl"></Button>
</GridLayout>
26 changes: 15 additions & 11 deletions apps/nativescript-demo-ng/src/app/modal/modal.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Component, OnDestroy, OnInit, Optional, ViewContainerRef, inject } from '@angular/core';
import { ModalDialogService, NativeDialogRef, NativeDialogService } from '@nativescript/angular';
import { Component, NO_ERRORS_SCHEMA, OnDestroy, OnInit, Optional, ViewContainerRef, inject } from '@angular/core';
import { ModalDialogService, NativeDialogModule, NativeDialogRef, NativeDialogService, NativeScriptCommonModule } from '@nativescript/angular';
import { ItemService } from '../item/item.service';
import { View } from '@nativescript/core';

@Component({
selector: 'ns-modal',
templateUrl: `./modal.component.html`,
imports: [NativeScriptCommonModule, NativeDialogModule],
standalone: true,
schemas: [NO_ERRORS_SCHEMA]
})
export class ModalComponent implements OnInit, OnDestroy {
id = Math.floor(Math.random() * 1000);
Expand Down Expand Up @@ -46,15 +49,16 @@ export class ModalComponent implements OnInit, OnDestroy {
loadedImg(args) {
this.img = args.object as View;
const scaleImage = (up: boolean) => {
this.img.animate({
scale: { x: up ? 1.5 : 1.0, y: up ? 1.5 : 1.0},
translate: { x: up ? -100 : 0, y: 0},
duration: 1000,

}).then(() => {
scaleImage(up ? false : true);
})
}
this.img
.animate({
scale: { x: up ? 1.5 : 1.0, y: up ? 1.5 : 1.0 },
translate: { x: up ? -100 : 0, y: 0 },
duration: 1000,
})
.then(() => {
scaleImage(up ? false : true);
});
};
scaleImage(true);
}
}
Loading
Loading
0