Base view

This commit is contained in:
2022-11-29 19:21:24 +01:00
parent 7fb5badf30
commit 48bd1e93a4
23 changed files with 4443 additions and 3901 deletions

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { DataService } from './data.service';
describe('DataService', () => {
let service: DataService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DataService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,13 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { User } from '../models/user';
@Injectable({
providedIn: 'root'
})
export class DataService {
currentUser?: User;
public showLoader: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
constructor() { }
}

View File

@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { DeviceService } from './device.service';
describe('DeviceService', () => {
let service: DeviceService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(DeviceService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});

View File

@@ -0,0 +1,50 @@
import { MediaMatcher } from '@angular/cdk/layout';
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class DeviceService {
private TABLET_WIDTH = 1000;
private DESKTOP_WIDTH = 1400;
public orientation?: "landscape" | "portraid";
public flipPhone: boolean = false;
public width?: number;
constructor(
private mediaMacher: MediaMatcher
) {
this.checkScreen();
window.addEventListener("resize", () => {
this.checkScreen();
});
}
checkScreen() {
const isPortrait = window.outerWidth < window.outerHeight;
if (
isPortrait &&
window.outerWidth <this.TABLET_WIDTH
) {
this.flipPhone = true;
} else {
this.flipPhone = false;
}
this.orientation = isPortrait ? "portraid" : "landscape";
this.width = window.outerWidth;
}
isMobile(): boolean {
return window.outerWidth < this.TABLET_WIDTH;
}
isTablet(): boolean {
return window.outerWidth > this.TABLET_WIDTH && window.outerWidth < this.DESKTOP_WIDTH;
}
isDesktop(): boolean {
return window.outerWidth > this.DESKTOP_WIDTH;
}
toString() {
return `Orientation: ${this.orientation}, Width: ${this.width}, Flip: ${this.flipPhone}, IsMobile: ${this.isMobile()}
IsTablet: ${this.isTablet()}, IsDesktop: ${this.isDesktop()}`;
}
}