using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using iElection.Models.Entities;
using Xamarin.Essentials;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace iElection.Views.Controllers
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class PostItemTemplate : ContentView
    {
        public PostItemTemplate()
        {
            InitializeComponent();
        }

        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            if (BindingContext is Activity activity)
            {
                if (activity.ActivityType == ActivityType.Clip)
                    clipButton.IsVisible = true;
                else
                    clipButton.IsVisible = false;
            }
        }
        

        private void PlayVideo_OnTapped(object sender, EventArgs e)
        {
            Launcher.OpenAsync((BindingContext as Activity).ClipUrl);
        }
    }
}