import { ChangeDetectionStrategy, Component } from '@angular/core';
import { ConfigService } from '../../config.service';
import { CircleButtonTypes, ListingMode, ListingModes, ListingService } from '@iqser/common-ui';
import { File } from '@red/domain';

@Component({
    selector: 'redaction-view-mode-selection',
    templateUrl: './view-mode-selection.component.html',
    styleUrls: ['./view-mode-selection.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ViewModeSelectionComponent {
    readonly listingModes = ListingModes;
    readonly circleButtonTypes = CircleButtonTypes;

    constructor(readonly configService: ConfigService, private readonly _listingService: ListingService<File>) {}

    setListingMode(listingMode: ListingMode): void {
        if (listingMode === this.configService.listingMode) {
            return;
        }

        this.configService.listingMode = listingMode;
        this._listingService.setSelected([]);
    }
}
