Files
doneit-web/src/app/services/device.service.ts
T
Peter Maquiran 7583bf5306 viewer rotation
2024-02-22 11:40:06 +01:00

45 lines
951 B
TypeScript

import { Injectable } from '@angular/core';
import { Platform } from '@ionic/angular';
// import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
import { ScreenOrientation, OrientationType } from '@capawesome/capacitor-screen-orientation';
@Injectable({
providedIn: 'root'
})
export class DeviceService {
currentOrientation: 'portrait' | 'landscape';
constructor( private platform: Platform) {
}
ngOnInit() {
this.detectOrientation();
}
isTableDivice() {
return this.platform.is("tablet");
}
isDesktop() {
return this.platform.is('desktop');
}
private detectOrientation() {
this.currentOrientation = this.platform.isPortrait() ? 'portrait' : 'landscape';
}
isTableLandscape() {
this.detectOrientation()
return this.isTableDivice() && this.currentOrientation == 'landscape' ;
}
get visionDesktop () {
return this.isDesktop() || this.isTableLandscape();
}
}