using Avalonia.Controls;
using Avalonia.Media;
using Млаумчерб.Клиент.классы;

namespace Млаумчерб.Клиент.видимое;

public partial class VersionItemView : ListBoxItem
{
    public GameVersionProps Props { get; }
    private SolidColorBrush _avaliableColor = new(Color.FromRgb(30, 130, 40));
    private SolidColorBrush _unavaliableColor = new(Color.FromRgb(170, 70, 70));

    public VersionItemView()
    {
        throw new NotImplementedException();
    }
    
    public VersionItemView(GameVersionProps props)
    {
        Props = props;
        InitializeComponent();
        text.Text = props.Name;
        props.DownloadCompleted += UpdateBackground;
        UpdateBackground();
    }

    private void UpdateBackground()
    {
        Background = Props.IsDownloaded ? _avaliableColor : _unavaliableColor;
    }
}