using Telerik.Maui.Controls.Chat;

namespace MauiApp6
{
    public class SimpleChatItemConverter : IChatItemConverter
    {
        public ChatItem ConvertToChatItem(object dataItem, ChatItemConverterContext context)
        {
            SimpleChatItem item = (SimpleChatItem)dataItem;
            TextMessage textMessage = new TextMessage()
            {
                Data = dataItem,
                Author = item.Author,
                Text = item.Text
            };
            return textMessage;
        }
        public object ConvertToDataItem(object message, ChatItemConverterContext context)
        {
            ChatViewModel vm = (ChatViewModel)context.Chat.BindingContext;
            return new SimpleChatItem { Author = vm.AuthorMe, Text = (string)message, Category = MessageCategory.Normal };
        }
    }


    public enum MessageCategory
    {
        Important,
        Normal
    }
    public class SimpleChatItem
    {
        public Author Author { get; set; }
        public string Text { get; set; }
        public MessageCategory Category { get; set; }
    }
}
