Files
doneit-web/src/app/app.component.ts
T
2022-10-11 17:07:51 +01:00

98 lines
3.0 KiB
TypeScript

import { Component, Inject } from '@angular/core';
import { Platform } from '@ionic/angular';
/* import { SplashScreen } from '@ionic-native/splash-screen/ngx'; */
import { StatusBar } from '@ionic-native/status-bar/ngx';
import * as _moment from 'moment';
import * as _rollupMoment from 'moment';
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
const moment = _rollupMoment || _moment;
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
import { StorageService } from 'src/app/services/storage.service';
import { MessageModel } from './models/beast-orm';
import { InativityService } from "src/app/services/inativity.service";
import { ThemeService } from 'src/app/services/theme.service';
const CUSTOM_DATE_FORMATS: NgxMatDateFormats = {
parse: {
dateInput: "YYYY-MMMM-DD HH:mm"
},
display: {
dateInput: "DD MMM YYYY H:mm",
monthYearLabel: "MMM YYYY",
dateA11yLabel: "LL",
monthYearA11yLabel: "MMMM YYYY"
}
}
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
providers: [
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
]
})
export class AppComponent {
constructor(
private platform: Platform,
/* private splashScreen: SplashScreen, */
private statusBar: StatusBar,
private screenOrientation: ScreenOrientation,
private sqliteservice: SqliteService,
private backgroundservice: BackgroundService,
private storageservice: StorageService,
private InativityService: InativityService,
public ThemeService: ThemeService,
) {
// this.createCacheFolder()
this.initializeApp();
}
// async createCacheFolder(){
// await Filesystem.mkdir({
// directory: Directory.Cache,
// path: `CACHED-IMG`
// })
// }
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
/* this.splashScreen.hide(); */
if (this.platform.is("tablet")) {
window.screen.orientation.unlock();
} else if( this.platform.is("mobile")) {
window.screen.orientation.lock('portrait');
// console.log('Orientation locked')
}
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
try {
this.sqliteservice.databaseConn();
} catch (error) {
// console.log("Error creating local database: ", error)
}
}
this.storageservice.get('networkCheckStore').then((network) => {
if(network === 'online') {
// console.log('Network app componente check', network)
this.backgroundservice.online()
} else {
// console.log('Network app componente check', network)
this.backgroundservice.offline();
}
})
});
}
}