using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace InABox.Mobile
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class MobileAccordion
    {
        
        public MobileAccordionItem SelectedItem => Items.FirstOrDefault(x => x.Visible);
        
        public event EventHandler SelectionChanged;
        
        public IList<MobileAccordionItem> Items { get; private set; }
        
        public MobileAccordion()
        {
            Items = new ObservableCollection<MobileAccordionItem>();
            InitializeComponent();
            BindableLayout.SetItemsSource(_stack, Items);
        }
        
        private void Header_Clicked(object sender, MobileButtonClickEventArgs args)
        {
            foreach (var item in Items)
                item.Visible = (item == args.Tag);
            SelectionChanged?.Invoke(this, EventArgs.Empty);
        }
        
    }
}