mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
45 lines
951 B
TypeScript
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();
|
|
}
|
|
|
|
}
|