import { Component, OnInit, ViewChild } from '@angular/core';
import { IonSlides } from '@ionic/angular';

@Component({
    selector: 'app-polls',
    templateUrl: './polls.component.html',
    styleUrls: ['./polls.component.scss'],
})
export class PollsComponent implements OnInit {
    @ViewChild('slides') slides: IonSlides;

    slideOpts = {
        slidesPerView: 1,
        initialSlide: 0,
        centeredSlides: true,
        // simulateTouch: false,
        // followFinger: false,
    };

    showNext: boolean = true;

    pollQuestions: Array<{
        text: string,
        selectedAnswer: number,
        maxUserCount: number,
        options: Array<{
            text: string,
            pollUserCount: number,
        }>
    }> = [];

    constructor() { }

    ngOnInit() {
        this.pollQuestions = [{
            text: 'Who will bat first? (CSK vs KXIP)',
            selectedAnswer: null,
            maxUserCount: 1000,
            options: [{
                text: 'CSK',
                pollUserCount: 304,
            }, {
                text: 'KXIP',
                pollUserCount: 586,
            }, {
                text: 'Match Cancelled',
                pollUserCount: 110
            }]
        }, {
            text: 'Best opener for KXIP',
            selectedAnswer: null,
            maxUserCount: 5090,
            options: [{
                text: 'KL Rahul',
                pollUserCount: 2988,
            }, {
                text: 'N Pooran',
                pollUserCount: 1342,
            }, {
                text: 'C Gayle',
                pollUserCount: 460
            }, {
                text: 'G Maxwell',
                pollUserCount: 300
            }]
        }];
    }

    nextQuestion() {
        console.log(this.slides);
    }

}
