using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace InABox.Core
{
    public class CoreMenuHeader<T> : ICoreMenuContentItem where T : class
    {
        public string Header { get; set; }
    
        public T? Image { get; set; }
        object? ICoreMenuContentItem.Image { get => Image; set => Image = (T?)value; }
    
        public List<ICoreMenuItem> Items { get; } = new List<ICoreMenuItem>();

        public CoreMenuHeader(string header, T? image = null)
        {
            Header = header;
            Image = image;
        }
    
        public CoreMenuHeader<T> AddItem(string header, T? image, Func<Task<bool>> action)
        {
            var result = new CoreMenuItem<T>(header, image, action);
            Items.Add(result);
            return this;
        }
    
        public CoreMenuHeader<T> AddItem(string header, Func<Task<bool>> action)
        {
            var result = new CoreMenuItem<T>(header, null, action);
            Items.Add(result);
            return this;
        }

        public CoreMenuHeader<T> AddSeparator()
        {
            Items.Add(new CoreMenuSeparator());
            return this;
        }
    
        public CoreMenuHeader<T> AddHeader(CoreMenuHeader<T> header)
        {
            Items.Add(header);
            return this;
        }
    
    }
}