<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:tabs="clr-namespace:Artemis.UI.Screens.Workshop.Library.Tabs"
             xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia"
             xmlns:converters="clr-namespace:Artemis.UI.Converters"
             xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="Artemis.UI.Screens.Workshop.Library.Tabs.InstalledTabItemView"
             x:DataType="tabs:InstalledTabItemViewModel">
    <UserControl.Resources>
        <converters:EntryIconUriConverter x:Key="EntryIconUriConverter" />
        <converters:DateTimeConverter x:Key="DateTimeConverter" />
    </UserControl.Resources>
    <Button MinHeight="65"
            MaxHeight="110"
            Padding="6"
            Margin="0 0 0 5"
            HorizontalAlignment="Stretch"
            HorizontalContentAlignment="Stretch"
            Command="{CompiledBinding ViewWorkshopPage}">
        <Grid ColumnDefinitions="Auto,2*,*,*,*,Auto">
            <Border Grid.Column="0"
                    CornerRadius="6"
                    VerticalAlignment="Center"
                    Margin="0 0 10 0"
                    Width="50"
                    Height="50"
                    ClipToBounds="True">
                <Image Stretch="UniformToFill" asyncImageLoader:ImageLoader.Source="{CompiledBinding InstalledEntry.EntryId, Converter={StaticResource EntryIconUriConverter}, Mode=OneWay}" />
            </Border>

            <StackPanel Grid.Column="1" VerticalAlignment="Center">
                <TextBlock TextTrimming="CharacterEllipsis"
                           Text="{CompiledBinding InstalledEntry.Name, FallbackValue=Title}" />
                <TextBlock Classes="subtitle"
                           TextWrapping="Wrap"
                           TextTrimming="CharacterEllipsis"
                           Text="{CompiledBinding InstalledEntry.Author, FallbackValue=Summary}">
                </TextBlock>
            </StackPanel>
            
            <TextBlock Grid.Column="2" VerticalAlignment="Center" Text="{CompiledBinding InstalledEntry.EntryType}"></TextBlock>
            <TextBlock Grid.Column="3" VerticalAlignment="Center" Text="{CompiledBinding InstalledEntry.ReleaseVersion}"></TextBlock>
            <TextBlock Grid.Column="4" VerticalAlignment="Center">
                <Run>Installed</Run>
                <Run Text="{CompiledBinding InstalledEntry.InstalledAt, FallbackValue=01-01-1337, Mode=OneWay, Converter={StaticResource DateTimeConverter}}" />
            </TextBlock>
            
            <StackPanel Grid.Column="5" VerticalAlignment="Center" Orientation="Horizontal" Spacing="6">
                <Button Command="{CompiledBinding ViewLocal}">Open</Button>
                <Button Command="{CompiledBinding Uninstall}" Theme="{StaticResource TransparentButton}" Height="32">
                    <avalonia:MaterialIcon Kind="Trash"/>
                </Button>
            </StackPanel>
        </Grid>
    </Button>
</UserControl>