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

namespace InABox.Core
{

    public class CoreMenu<T> where T : class
    {
        public List<ICoreMenuItem> Items { get; } = new List<ICoreMenuItem>();

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

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

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

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