using Model.Stub;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace Model;

public class CustomTitle : Title, INotifyPropertyChanged
{

    public string Path
    {
        get => path;

        set
        {
            if (value != null && value.Length < Manager.MAX_DESCRIPTION_LENGTH)
            {
                path = value;
            }
            OnPropertyChanged();
        }
    }

    private string path = Manager.DEFAULT_URL;

    public bool IsSubMenuVisible
    {
        get => isSubMenuVisible;
        set
        {
            if (isSubMenuVisible != value)
            {
                isSubMenuVisible = value;
            }
            OnPropertyChanged();
        }
    }

    private bool isSubMenuVisible = false;

    public bool IsPlaylistMenuVisible
    {
        get => isPlaylistMenuVisible;
        set
        {
            if (isPlaylistMenuVisible != value)
            {
                isPlaylistMenuVisible = value;
            }
            OnPropertyChanged();
        }
    }

    private bool isPlaylistMenuVisible = false;

    public bool IsNewPlaylistMenuVisible
    {
        get => isNewPlaylistMenuVisible;
        set
        {
            if (isNewPlaylistMenuVisible != value)
            {
                isNewPlaylistMenuVisible = value;
            }
            OnPropertyChanged();
        }
    }

    private bool isNewPlaylistMenuVisible = false;

    public CustomTitle(string name, string imageURL, string information, string path) : base(name, imageURL, information)
    {
        Path = path;
    }

    public CustomTitle() : base(Manager.DEFAULT_NAME, Manager.DEFAULT_URL, Manager.DEFAULT_DESC) { }

    public bool Equals(CustomTitle? other)
        => Path.Equals(other?.Path);

    public override bool Equals(object? obj)
    {
        if (ReferenceEquals(obj, null)) return false;
        if (ReferenceEquals(this, obj)) return true;
        if (GetType() != obj.GetType()) return false;
        return Equals(obj as CustomTitle);
    }

    public override int GetHashCode()
    {
        return ImageURL.GetHashCode();
    }

    public override string ToString()
    {
        return $"Name : {Name}, Path : {Path}";
    }
}
