Files
doneit-web/src/app/services/device.service.ts
T

45 lines
951 B
TypeScript
Raw Normal View History

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