Skip to content
Snippets Groups Projects
Commit dc27dfd1 authored by jojohoch's avatar jojohoch
Browse files

[player] Rename properties in `PlayerStateComponent`

parent 722c18c1
No related branches found
No related tags found
No related merge requests found
<div *ngIf="!running" class='stopped-overlay'></div>
<div fxLayout="row">
<mat-tab-group *ngIf="hasScrollPages" [fxFlex]="pageWidth" [(selectedIndex)]="currentIndex"
<mat-tab-group *ngIf="hasScrollPages"
[fxFlex]="pageWidth"
[(selectedIndex)]="currentPlayerPageIndex"
(selectedIndexChange)="onSelectedIndexChange()"
mat-align-tabs="start">
<ng-container *ngFor="let page of pages; let i = index">
<mat-tab *ngIf="!page.alwaysVisible" label="{{'pageIndication' | translate: {index: pageIndices[i] + 1} }}">
<app-page class="page" [parentArrayIndex]="i" [parentForm]="parenForm" [page]="page"></app-page>
<mat-tab *ngIf="!page.alwaysVisible"
label="{{'pageIndication' | translate: {index: playerPageIndices[i] + 1} }}">
<app-page class="page"
[parentArrayIndex]="i"
[parentForm]="parenForm"
[page]="page">
</app-page>
</mat-tab>
</ng-container>
</mat-tab-group>
<div *ngIf="alwaysVisiblePage" [fxFlex]="pageWidth">
<div class="mat-tab-label">{{'alwaysVisiblePage' | translate}}</div>
<app-page class="page" [parentArrayIndex]="alwaysVisiblePageIndex" [parentForm]="parenForm" [page]="alwaysVisiblePage"></app-page>
<app-page class="page"
[parentArrayIndex]="alwaysVisibleUnitPageIndex"
[parentForm]="parenForm"
[page]="alwaysVisiblePage">
</app-page>
</div>
</div>
......@@ -22,14 +22,14 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
@Input() parenForm!: FormGroup;
@Input() pages!: UnitPage[];
currentIndex: number = 0;
pageIndices!: number[];
currentPlayerPageIndex: number = 0;
playerPageIndices!: number[];
scrollPages!: UnitPage[];
hasScrollPages!: boolean;
pageWidth!: number;
validPages!: Record<string, string> [];
alwaysVisiblePage!: UnitPage | undefined;
alwaysVisiblePageIndex!: number;
alwaysVisibleUnitPageIndex!: number;
running: boolean = true;
private ngUnsubscribe = new Subject<void>();
......@@ -61,19 +61,19 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
}
private initPageState() {
this.alwaysVisiblePageIndex = this.pages.findIndex((page: UnitPage): boolean => page.alwaysVisible);
this.alwaysVisiblePage = this.pages[this.alwaysVisiblePageIndex];
this.alwaysVisibleUnitPageIndex = this.pages.findIndex((page: UnitPage): boolean => page.alwaysVisible);
this.alwaysVisiblePage = this.pages[this.alwaysVisibleUnitPageIndex];
this.scrollPages = this.pages.filter((page: UnitPage): boolean => !page.alwaysVisible);
this.hasScrollPages = this.scrollPages && this.scrollPages.length > 0;
this.pageWidth = !this.alwaysVisiblePage || !this.hasScrollPages ? 100 : 50;
this.validPages = this.scrollPages.map((page: UnitPage, index: number): Record<string, string> => (
{ [page.id]: `${this.translateService.instant('pageIndication', { index: index + 1 })}` }));
this.pageIndices = this.pages.map(
this.playerPageIndices = this.pages.map(
(page: UnitPage, index: number): number => {
if (index === this.alwaysVisiblePageIndex) {
if (index === this.alwaysVisibleUnitPageIndex) {
return this.pages.length - 1;
}
return (this.alwaysVisiblePageIndex < 0 || index < this.alwaysVisiblePageIndex) ? index : index - 1;
return (this.alwaysVisibleUnitPageIndex < 0 || index < this.alwaysVisibleUnitPageIndex) ? index : index - 1;
}
);
}
......@@ -112,13 +112,13 @@ export class PlayerStateComponent implements OnInit, OnDestroy {
private onPageNavigation(message: VopPageNavigationCommand): void {
// eslint-disable-next-line no-console
console.log('player: onPageNavigation', message);
this.currentIndex = parseInt(message.target, 10);
this.currentPlayerPageIndex = parseInt(message.target, 10);
}
private sendVopStateChangedNotification(): void {
const playerState: PlayerState = {
state: this.state,
currentPage: this.currentIndex.toString(10),
currentPage: this.currentPlayerPageIndex.toString(10),
validPages: this.validPages
};
this.veronaPostService.sendVopStateChangedNotification({ playerState });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment