using System.Diagnostics;
using System.Threading.Tasks;
using UnityEngine;
namespace XenseAR {

public class QuestionManager : MonoBehaviour
{
    // Start is called before the first frame update
    public bool isFirstTimeNavigate = true;

    public int navigationCount = 0;

    public Stopwatch stopwatch = new Stopwatch();
    void Start()
    {
        stopwatch.Start();
    }
    
    //QuestionPopUP function that only shows 1 time per app install
    public void QuestionPopUP()
    {
        if (PlayerPrefs.GetInt("QuestionPopUP") == 0)
        {
            PlayerPrefs.SetInt("QuestionPopUP", 1);
            //Show QuestionPopUP
        }
    }

    public async void QuestionPopUpAboutNavigation()
    {
        if(isFirstTimeNavigate)
        {
            isFirstTimeNavigate = false;
            return;
        }
        if(PlayerPrefs.GetInt("QuestionPopUpAboutNavigation") == 0)
        {
            PlayerPrefs.SetInt("QuestionPopUpAboutNavigation", 1);
                //Show QuestionPopUP
                //webViewManager.questionWebViewPrefab.WebView.LoadUrl("https://xensear.vn/frontend/reviewquestion.html?questionID=about-navigation");
                //await webViewManager.questionWebViewPrefab.WebView.WaitForNextPageLoadToFinish();
                //await Task.Delay(1000);
                //webViewManager.OpenWebViewQuestion();
            }
        }

    public async void QuestionPopUpAboutContent()
    {
        if (navigationCount < 3)
        {
            return;
        }
        if (PlayerPrefs.GetInt("QuestionPopUpAboutContent") == 0)
        {
            PlayerPrefs.SetInt("QuestionPopUpAboutContent", 1);
                //Show QuestionPopUP
                //webViewManager.questionWebViewPrefab.WebView.LoadUrl("https://xensear.vn/frontend/reviewquestion.html?questionID=about-content");
                //await webViewManager.questionWebViewPrefab.WebView.WaitForNextPageLoadToFinish();
                //await Task.Delay(1000);
                //webViewManager.OpenWebViewQuestion();

            }
        }

    public async void QuestionPopUpAboutFirstTimeExperience()
    {
        if (stopwatch.Elapsed.TotalMinutes < 10)
        {
            return;
        }
        if (PlayerPrefs.GetInt("QuestionPopUpAboutFirstTimeExperience") == 0)
        {
            PlayerPrefs.SetInt("QuestionPopUpAboutFirstTimeExperience", 1);
                //Show QuestionPopUP
                //webViewManager.questionWebViewPrefab.WebView.LoadUrl("https://xensear.vn/frontend/reviewquestion.html?questionID=first-time-experience");
                //await webViewManager.questionWebViewPrefab.WebView.WaitForNextPageLoadToFinish();
                //await Task.Delay(1000);
                //webViewManager.OpenWebViewQuestion();

                stopwatch.Stop();
        }
    }
}
}
