feat: upgrade to capacitor 5.0

This commit is contained in:
2023-10-19 11:19:04 +02:00
committed by Rainer Killinger
parent a02190fe5a
commit 066e374462
55 changed files with 2458 additions and 1765 deletions

View File

@@ -19,11 +19,10 @@ import {Platform, ToastController} from '@ionic/angular';
import {SettingsProvider} from './modules/settings/settings.provider';
import {AuthHelperService} from './modules/auth/auth-helper.service';
import {environment} from '../environments/environment';
import {StatusBar, Style} from '@capacitor/status-bar';
import {Capacitor} from '@capacitor/core';
import {ScheduleSyncService} from './modules/background/schedule/schedule-sync.service';
import {NavigationBar} from '@hugotomazi/capacitor-navigation-bar';
import {Keyboard, KeyboardResize} from '@capacitor/keyboard';
import {SplashScreen} from '@capacitor/splash-screen';
/**
* TODO
@@ -52,15 +51,6 @@ export class AppComponent implements AfterContentInit {
*/
ommitedEventSources = ['ion-input', 'ion-searchbar'];
/**
*
* @param platform TODO
* @param settingsProvider TODO
* @param router The angular router
* @param zone The angular zone
* @param authHelper Helper service for OAuth providers
* @param toastController Toast controller
*/
constructor(
private readonly platform: Platform,
private readonly settingsProvider: SettingsProvider,
@@ -73,9 +63,23 @@ export class AppComponent implements AfterContentInit {
void this.initializeApp();
}
ngAfterContentInit(): void {
ngAfterContentInit() {
this.scheduleSyncService.init();
void this.scheduleSyncService.enable();
if (document.readyState === 'complete') {
requestIdleCallback(this.hideSplash.bind(this));
} else {
document.addEventListener('readystatechange', () => {
if (document.readyState === 'complete') requestIdleCallback(this.hideSplash.bind(this));
});
}
}
async hideSplash() {
if (Capacitor.isNativePlatform()) {
void SplashScreen.hide();
}
}
/**
@@ -93,23 +97,7 @@ export class AppComponent implements AfterContentInit {
});
});
this.platform.ready().then(async () => {
if (Capacitor.isNativePlatform()) {
await StatusBar.setStyle({style: Style.Dark});
if (Capacitor.getPlatform() === 'android') {
await StatusBar.setBackgroundColor({
color: getComputedStyle(document.documentElement).getPropertyValue('--ion-color-primary').trim(),
});
await StatusBar.setOverlaysWebView({overlay: false});
await NavigationBar.setColor({
color: getComputedStyle(document.documentElement)
.getPropertyValue('--ion-background-color')
.trim(),
darkButtons: true,
});
}
}
await this.authNotificationsInit();
// set order of categories in settings
this.settingsProvider.setCategoriesOrder(['profile', 'privacy', 'credentials', 'others']);
});

View File

@@ -12,12 +12,21 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Component, DestroyRef, ElementRef, inject, NgZone, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {
AfterViewInit,
Component,
DestroyRef,
ElementRef,
inject,
NgZone,
OnDestroy,
OnInit,
ViewChild,
} from '@angular/core';
import {Router} from '@angular/router';
import {Location} from '@angular/common';
import moment from 'moment';
import {SCDateSeries, SCUuid} from '@openstapps/core';
import {SplashScreen} from '@capacitor/splash-screen';
import {DataRoutingService} from '../data/data-routing.service';
import {ScheduleProvider} from '../calendar/schedule.provider';
import {AnimationController, IonContent} from '@ionic/angular';
@@ -30,7 +39,7 @@ import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss', '/dashboard.collapse.component.scss'],
})
export class DashboardComponent implements OnInit, OnDestroy {
export class DashboardComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild('toolbar', {read: ElementRef}) toolbarRef: ElementRef;
@ViewChild('schedule', {read: ElementRef}) scheduleRef: ElementRef;
@@ -49,18 +58,6 @@ export class DashboardComponent implements OnInit, OnDestroy {
*/
nextEvent: SCDateSeries | undefined;
/**
* Slider options
*/
quickNavigationOptions = {
slidesPerView: 'auto',
spaceBetween: 12,
freeMode: {
enabled: true,
sticky: true,
},
};
destroy$ = inject(DestroyRef);
constructor(
@@ -85,8 +82,9 @@ export class DashboardComponent implements OnInit, OnDestroy {
this.eventUuids = result;
await this.loadNextEvent();
});
await SplashScreen.hide();
}
async ngAfterViewInit() {
this.collapseAnimation = new DashboardCollapse(
this.animationControl,
this.zone,

View File

@@ -16,7 +16,6 @@ import {Component, OnInit} from '@angular/core';
import {IonRefresher} from '@ionic/angular';
import {SCMessage, SCSearchFilter, SCSearchValueFilter, SCSetting} from '@openstapps/core';
import {NewsProvider} from '../news.provider';
import {SplashScreen} from '@capacitor/splash-screen';
/**
* News page component
@@ -70,8 +69,6 @@ export class NewsPageComponent implements OnInit {
async fetchNews() {
this.from = this.pageSize;
this.news = await this.newsProvider.getList(this.pageSize, 0, [...this.filters]);
await SplashScreen.hide();
}
/**