-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
306 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/app/features/camera-battery/camera-battery.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CommonModule, isPlatformBrowser } from '@angular/common'; | ||
import { | ||
Component, | ||
DestroyRef, | ||
inject, | ||
PLATFORM_ID, | ||
signal, | ||
} from '@angular/core'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { interval, map } from 'rxjs'; | ||
|
||
const initialDate = new Date().setHours(0, 0, 0, 0); | ||
|
||
@Component({ | ||
selector: 'app-camera-battery', | ||
standalone: true, | ||
imports: [CommonModule, MatIconModule], | ||
template: ` | ||
@if (batterySignal()) { | ||
<mat-icon fontIcon="battery_5_bar"></mat-icon> | ||
} @else { | ||
<mat-icon fontIcon="battery_4_bar"></mat-icon> | ||
} | ||
`, | ||
styles: ` | ||
mat-icon { | ||
transform: scale(4); | ||
} | ||
`, | ||
}) | ||
export class CameraBatteryComponent { | ||
private readonly destroyRef = inject(DestroyRef); | ||
private readonly platformId = inject(PLATFORM_ID); | ||
|
||
protected readonly batterySignal = signal<boolean>(true); | ||
|
||
ngOnInit() { | ||
// Run on browser; | ||
if (isPlatformBrowser(this.platformId)) { | ||
const date = new Date(Date.UTC(2024, 0, 1, 0, 0, 0, 0)); | ||
|
||
interval(1000) | ||
.pipe( | ||
map(timer => timer % 2 === 0), | ||
takeUntilDestroyed(this.destroyRef), | ||
) | ||
.subscribe(timer => { | ||
this.batterySignal.update(() => timer); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { CommonModule, isPlatformBrowser } from '@angular/common'; | ||
import { | ||
Component, | ||
DestroyRef, | ||
inject, | ||
PLATFORM_ID, | ||
signal, | ||
} from '@angular/core'; | ||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
import { interval, map, scan } from 'rxjs'; | ||
|
||
const initialDate = new Date().setHours(0, 0, 0, 0); | ||
|
||
@Component({ | ||
selector: 'app-camera-timer', | ||
standalone: true, | ||
imports: [CommonModule], | ||
template: ` | ||
{{ timerSignal() | date: 'HH:mm:ss:SSS' }} | ||
`, | ||
styles: ` | ||
:host { | ||
font-size: 40px; | ||
font-weight: 900; | ||
} | ||
`, | ||
}) | ||
export class CameraTimerComponent { | ||
private readonly destroyRef = inject(DestroyRef); | ||
private readonly platformId = inject(PLATFORM_ID); | ||
|
||
protected readonly timerSignal = signal('2024-12-31T00:00:00.000Z'); | ||
|
||
ngOnInit() { | ||
// Run on browser; | ||
if (isPlatformBrowser(this.platformId)) { | ||
const date = new Date(Date.UTC(2024, 0, 1, 0, 0, 0, 0)); | ||
|
||
interval(1) | ||
.pipe( | ||
scan((acc, curr) => { | ||
acc.setMilliseconds(acc.getMilliseconds() + 1); | ||
return acc; | ||
}, date), | ||
map(timer => timer.toISOString().slice(0, 23)), | ||
takeUntilDestroyed(this.destroyRef), | ||
) | ||
.subscribe(timer => { | ||
this.timerSignal.update(() => timer); | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.