import {Component, inject, OnInit} from '@angular/core'
import {Color} from '../../../models/Color'
import {ModalController} from '@ionic/angular'

@Component({
  selector: 'app-new-label-modal',
  templateUrl: './new-label-modal.component.html',
  styleUrls: ['./new-label-modal.component.scss'],
})
export class NewLabelModalComponent  implements OnInit {
  labelName = ''
  colors: Color[] = Object.values(Color) as Color[]
  selectedColor = this.colors[0]

  #modalController = inject(ModalController)

  constructor() { }

  ngOnInit() {}

  async dismissModal(cancelled: boolean = false) {
    if (cancelled) {
      await this.#modalController.dismiss()
    }
    else {
      await this.#modalController.dismiss({
        name: this.labelName,
        color: this.selectedColor,
      })
    }
  }
}
