Files
doneit-web/src/app/app.component.ts
T

72 lines
2.0 KiB
TypeScript
Raw Normal View History

2021-07-08 10:43:40 +01:00
import { Component, Inject } from '@angular/core';
2020-08-05 15:39:16 +01:00
import { Platform } from '@ionic/angular';
2021-02-25 11:50:32 +01:00
/* import { SplashScreen } from '@ionic-native/splash-screen/ngx'; */
2020-08-05 15:39:16 +01:00
import { StatusBar } from '@ionic-native/status-bar/ngx';
2021-06-24 11:08:17 +01:00
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';
2021-10-28 09:30:28 +01:00
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
2021-06-24 11:08:17 +01:00
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"
}
}
2021-02-25 11:50:32 +01:00
2020-08-05 15:39:16 +01:00
@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
2021-06-24 11:08:17 +01:00
styleUrls: ['app.component.scss'],
providers: [
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
]
2020-08-05 15:39:16 +01:00
})
export class AppComponent {
constructor(
private platform: Platform,
2021-02-25 11:50:32 +01:00
/* private splashScreen: SplashScreen, */
2021-10-28 09:30:28 +01:00
private statusBar: StatusBar,
private screenOrientation: ScreenOrientation,
private sqliteservice: SqliteService
2020-08-05 15:39:16 +01:00
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
2021-02-25 11:50:32 +01:00
this.statusBar.styleDefault();
/* this.splashScreen.hide(); */
2021-10-28 09:30:28 +01:00
if (this.platform.is("tablet")) {
this.screenOrientation.unlock();
} else if( this.platform.is("mobile")) {
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT_PRIMARY);
console.log('Orientation locked')
2021-10-28 09:30:28 +01:00
}
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
} else {
try {
this.sqliteservice.databaseConn();
} catch (error) {
console.log("Error creating local database: ", error)
}
}
2020-08-05 15:39:16 +01:00
});
}
}