using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace PhilExample.UI.Pages
{
    public class CallbackPage<T> : PhExContentPage
    {
        private readonly TaskCompletionSource<T> _tcs = new TaskCompletionSource<T>();

        public Task<T> PagePoppedTask => _tcs.Task;

        public /* virtual */ void SetPopupResult(T result)
        {
            if (PagePoppedTask.IsCompleted == false)
                _tcs.SetResult(result);
        }

        //protected override void OnAppearing()
        //{
        //    base.OnAppearing();
        //}

        //protected override void OnDisappearing()
        //{
        //    base.OnDisappearing();
        //}

        //TODO:
        //Potentially need something for: protected override bool OnBackButtonPressed() => false;
    }
}
