using System;
using Windows.ApplicationModel.Resources;

namespace FoxTube.Classes
{
    public enum InboxItemType { Default, PatchNote }

    public class InboxItem
    {
        public InboxItemType Type { get; set; } = InboxItemType.Default;
        public DateTime TimeStamp { get; set; }
        public string TimeStampString
        {
            get
            {
                if (Type == InboxItemType.PatchNote)
                    return TimeStamp.ToShortDateString();
                else
                    return TimeStamp.ToString();
            }
        }
        
        public string Subject { get; set; }
        public string Content { get; set; }
        public string Id { get; set; }

        private ResourceLoader resources = ResourceLoader.GetForCurrentView("Inbox");
        
        public string Icon
        {
            get
            {
                if (Type == InboxItemType.PatchNote)
                    return "\xE728";
                else
                    return "\xE119";
            }
        }
        public string Subtitle
        {
            get
            {
                if (Type == InboxItemType.PatchNote)
                    return resources.GetString("changelog");
                else
                    return resources.GetString("dev");
            }
        }

        public string Title
        {
            get
            {
                if (Type == InboxItemType.PatchNote)
                    return $"{resources.GetString("whatsnew")}{Id}";
                else
                    return Subject;
            }
        }


        public InboxItem(string version, string content, DateTime timeStamp)
        {
            Type = InboxItemType.PatchNote;
            Content = content;
            TimeStamp = timeStamp;
            Id = version;
        }

        public InboxItem(string title, string content, DateTime timeStamp, string id, string header)
        {
            Type = InboxItemType.Default;
            Content = header + "\n\n" + content;
            Subject = title;
            TimeStamp = timeStamp;
            Id = id;
        }
    }
}
