<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:local="using:Ryujinx.Ava.Utilities.Compat"
             xmlns:helpers="using:Ryujinx.Ava.UI.Helpers"
             xmlns:ext="using:Ryujinx.Ava.Common.Markup"
             xmlns:ui="using:FluentAvalonia.UI.Controls"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="Ryujinx.Ava.Utilities.Compat.CompatibilityList"
             x:DataType="local:CompatibilityViewModel">
    <UserControl.DataContext>
        <local:CompatibilityViewModel />
    </UserControl.DataContext>
    <Grid RowDefinitions="*,Auto,*">
        <Grid 
            Grid.Row="0"
            HorizontalAlignment="Center"
            ColumnDefinitions="Auto,*"
            Margin="0 0 0 10">
            <ui:FontIcon
                Grid.Column="0"
                Margin="0"
                HorizontalAlignment="Stretch"
                FontFamily="avares://FluentAvalonia/Fonts#Symbols"
                Glyph="{helpers:GlyphValueConverter Important}" />
            <!-- NOTE: aligning to bottom for better visual alignment with glyph -->
            <TextBlock
                Grid.Column="1"
                Margin="5, 0, 0, 0"
                FontStyle="Italic"
                VerticalAlignment="Center"
                TextWrapping="Wrap"
                Text="{ext:Locale CompatibilityListWarning}" />
        </Grid>
        <Grid Grid.Row="1" ColumnDefinitions="*,Auto,Auto">
            <TextBox Grid.Column="0" HorizontalAlignment="Stretch" Watermark="{ext:Locale CompatibilityListSearchBoxWatermark}" TextChanged="TextBox_OnTextChanged" />
            <CheckBox Grid.Column="1" Margin="7, 0, 0, 0" IsChecked="{Binding OnlyShowOwnedGames}" />
            <TextBlock Grid.Column="2" Margin="-10, 0, 0, 0" Text="{ext:Locale CompatibilityListOnlyShowOwnedGames}" />
        </Grid>
        <ScrollViewer Grid.Row="2">
                <ListBox Margin="0,5, 0, 0"
                         Background="Transparent"
                         ItemsSource="{Binding CurrentEntries}">
                    <ListBox.ItemTemplate>
                        <DataTemplate DataType="{x:Type local:CompatibilityEntry}">
                            <Grid Width="750"
                                  Margin="5"
                                  ColumnDefinitions="Auto,Auto,Auto,*"
                                  Background="Transparent"
                                  ToolTip.Tip="{Binding  LocalizedLastUpdated}">
                                <TextBlock Grid.Column="0"
                                           Text="{Binding GameName}"
                                           Width="320"
                                           TextWrapping="Wrap" />
                                <TextBlock Grid.Column="1"
                                           Width="135"
                                           Padding="7, 0, 0, 0"
                                           FontFamily="{StaticResource JetBrainsMono}"
                                           Text="{Binding FormattedTitleId}"
                                           TextWrapping="Wrap" />
                                <TextBlock Grid.Column="2"
                                           Padding="7, 0"
                                           VerticalAlignment="Center"
                                           Text="{Binding LocalizedStatus}"
                                           Width="85"
                                           Foreground="{Binding Status, Converter={x:Static helpers:PlayabilityStatusConverter.Shared}}"
                                           TextWrapping="NoWrap" />
                                <TextBlock Grid.Column="3"
                                           VerticalAlignment="Center"
                                           Text="{Binding FormattedIssueLabels}"
                                           TextWrapping="WrapWithOverflow" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
        </ScrollViewer>
    </Grid>
</UserControl>
