Upgrade: Angular 18, Ionic 8, Capacitor 6

Modernizacion completa del frontend:

- Angular 8 -> 18.2.14
- Ionic 4 -> 8.7.17
- Capacitor 6.x (migracion desde Cordova/@ionic-native)
- TypeScript 5.4.5
- Swiper 11 con Web Components API

Cambios principales:
- Migrar NativeStorage a @capacitor/preferences
- Migrar InAppBrowser a @capacitor/browser
- Migrar Camera a @capacitor/camera
- Migrar Geolocation a @capacitor/geolocation
- Migrar StatusBar/SplashScreen a Capacitor
- Migrar Facebook/Google login a plugins Capacitor
- Actualizar lazy loading syntax (Angular 12+)
- Configurar buildOptimizer: false para Ionic 8
- Limpiar package.json de dependencias obsoletas
- Agregar README con guia de instalacion

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
CarlosTorres
2026-01-17 22:03:31 +00:00
parent a9508bd34a
commit dfcb1168b9
397 changed files with 19732 additions and 23677 deletions

95
src/app/app.component.ts Normal file → Executable file
View File

@@ -1,14 +1,14 @@
import { Component } from '@angular/core';
import { Platform, NavController, LoadingController, AlertController, Events } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { Platform, NavController, LoadingController } from '@ionic/angular';
import { EventService } from './services/event.service';
import { StatusBar, Style } from '@capacitor/status-bar';
import { SplashScreen } from '@capacitor/splash-screen';
import { Browser } from '@capacitor/browser';
import { AuthService } from './services/auth.service';
import { LanguageService } from './services/language.service';
import { AlertService } from './services/alert.service';
import { TranslateService } from '@ngx-translate/core';
import { User } from 'src/app/models/user';
import { OneSignal, OSNotificationPayload } from '@ionic-native/onesignal/ngx';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { Capacitor } from '@capacitor/core';
@Component({
selector: 'app-root',
@@ -16,22 +16,18 @@ import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
})
export class AppComponent {
private loading;
private loading: any;
public appPages = [];
public appPages: any[] = [];
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private authService: AuthService,
private languageService: LanguageService,
private translateService: TranslateService,
private navCtrl: NavController,
private events: Events,
private events: EventService,
private alertService: AlertService,
private oneSignal: OneSignal,
private iab: InAppBrowser,
private loadingCtrl: LoadingController,
) {
this.initializeApp();
@@ -100,31 +96,31 @@ export class AppComponent {
}
});
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleLightContent();
this.statusBar.overlaysWebView(false);
// set status bar to white
this.statusBar.backgroundColorByHexString('#0080ff');
// Commenting splashScreen Hide, so it won't hide splashScreen before auth check
//this.splashScreen.hide();
this.languageService.getDefaultLanguage();
this.authService.getToken();
this.handlerNotifications();
async initializeApp() {
await this.platform.ready();
});
// Solo ejecutar plugins nativos en dispositivos móviles
if (Capacitor.isNativePlatform()) {
await StatusBar.setStyle({ style: Style.Light });
await StatusBar.setOverlaysWebView({ overlay: false });
await StatusBar.setBackgroundColor({ color: '#0080ff' });
// TODO: Implement OneSignal with Capacitor plugin
// this.handlerNotifications();
}
this.languageService.getDefaultLanguage();
this.authService.getToken();
}
// When Logout Button is pressed
logout() {
this.loadingCtrl.create().then((overlay) => {
this.loading = overlay;
this.loading.present();
});
async logout() {
this.loading = await this.loadingCtrl.create();
await this.loading.present();
this.authService.logout().subscribe(
data => {
this.alertService.presentToast(this.translateService.instant('alerts.logout'));
this.oneSignal.sendTag("iChamba_ID", null);
// TODO: Implement OneSignal tag clearing with Capacitor
},
error => {
this.loading.dismiss();
@@ -137,39 +133,10 @@ export class AppComponent {
);
}
openUrl(url) {
this.iab.create(url, '_system')
async openUrl(url: string) {
await Browser.open({ url });
}
private handlerNotifications(){
this.oneSignal.startInit('00d23dae-1209-42cc-bea7-e1f17cee27fa', '679874302148');
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.handleNotificationReceived().subscribe(data => this.onPushReceived(data.payload));
this.oneSignal.handleNotificationOpened().subscribe(data => this.onPushOpened(data.notification.payload));
this.oneSignal.endInit();
}
private onPushReceived(payload: OSNotificationPayload) {
this.alertService.presentAlert(payload.title, payload.body, ['OK']);
if (payload.title == 'Proveedor: hay nueva postulación' || payload.title == 'Hero: there is a new postulation') {
this.navCtrl.navigateRoot('/postulations');
this.events.publish('refreshpostulations', 'data');
} else if (payload.title == 'Búsqueda Finalizada' || payload.title == 'Search finished') {
this.navCtrl.navigateRoot('/contracts');
} else if (payload.title == 'Usuario: el proveedor ha iniciado el servicio' || payload.title == 'User: the Hero has started the service') {
this.navCtrl.navigateRoot('/contracts');
}
}
private onPushOpened(payload: OSNotificationPayload) {
if (payload.title == 'Proveedor: hay nueva postulación' || payload.title == 'Hero: there is a new postulation') {
this.navCtrl.navigateRoot('/postulations');
this.events.publish('refreshpostulations', 'data');
} else if (payload.title == 'Búsqueda Finalizada' || payload.title == 'Search finished') {
this.navCtrl.navigateRoot('/contracts');
} else if (payload.title == 'Usuario: el proveedor ha iniciado el servicio' || payload.title == 'User: the Hero has started the service') {
this.navCtrl.navigateRoot('/contracts');
}
}
// TODO: Re-implement push notifications with OneSignal Capacitor plugin
// private handlerNotifications() { ... }
}