import { Component, OnInit, OnDestroy } from '@angular/core';

@Component({
  selector: 'app-chant-mantras',
  templateUrl: './chant-mantras.page.html',
  styleUrls: ['./chant-mantras.page.scss'],
})
export class ChantMantrasPage implements OnInit, OnDestroy {
  options = {
    current: 100,
    max: 100,
    color: '#fa9900',
    background: '#fce09f',
    stroke: 10,
    semicircle: true,
    rounded: true,
    clockwise: true,
    responsive: true,
    duration: 1000,
    animation: 'easeInOutQuart',
    animationDelay: 0,
  };

  totalTime: number = 100000;
  currentTime: number = 0;
  timerInterval: any;

  constructor() {}
  ngOnDestroy() {
    clearInterval(this.timerInterval);
  }

  ngOnInit() {
    this.currentTime = this.totalTime;
    this.timerInterval = setInterval(() => {
      if (this.currentTime > 0) {
        this.currentTime -= 1000;
        this.options.current = this.currentTime * 100 / this.totalTime;
      } else {
        clearInterval(this.timerInterval);
      }
    }, 1000);
  }
}
