import { AfterViewInit, Component, ElementRef, Input } from '@angular/core';
import {
  MatCheckboxDefaultOptions, MAT_CHECKBOX_DEFAULT_OPTIONS
} from '@angular/material/checkbox';
import { DriveFile } from '../drive-file';

@Component({
  selector: 'app-file-block-view',
  templateUrl: './file-block-view.component.html',
  styleUrls: ['./file-block-view.component.scss'],
  providers: [
    {
      provide: MAT_CHECKBOX_DEFAULT_OPTIONS,
      useValue: { clickAction: 'noop' } as MatCheckboxDefaultOptions,
    },
  ],
})
export class FileBlockViewComponent implements AfterViewInit {
  @Input() file: DriveFile;
  @Input() selected: boolean = false;
  @Input() focus: boolean = false;
  @Input() isSelectingMode: boolean = false;

  constructor(private el: ElementRef) {}

  ngAfterViewInit() {
    if (this.focus) {
      this.el.nativeElement.querySelectorAll('.file-name').forEach((el) => {
        el.scrollIntoView({
          // behavior: 'smooth',
          block: 'center',
        });
      });
    }
  }
}
