@deepkit/desktop-ui
Version:
Library for desktop UI widgets in Angular 10+
91 lines (78 loc) • 2.52 kB
text/typescript
/*
* Deepkit Framework
* Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the MIT License.
*
* You should have received a copy of the MIT License along with this program.
*/
import { ChangeDetectorRef, Component, Input, OnChanges, OnDestroy } from '@angular/core';
import { ProgressTracker } from '@deepkit/core-rxjs';
import { Subscription } from 'rxjs';
export class IndicatorComponent {
step: number = 0;
}
export class ProgressIndicatorComponent implements OnChanges, OnDestroy {
progressTracker?: ProgressTracker;
display: 'horizontal' | 'vertical' = 'horizontal';
step: number = 0;
sub?: Subscription;
constructor(private cd: ChangeDetectorRef) {
}
ngOnChanges(): void {
if (this.sub) this.sub.unsubscribe();
if (this.progressTracker) {
this.sub = this.progressTracker.subscribe(v => {
this.step = this.progressTracker!.progress;
this.cd.detectChanges();
});
}
}
ngOnDestroy(): void {
if (this.sub) this.sub.unsubscribe();
}
}