<?xml version="1.0" encoding="utf-8"?>

<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="Qwirkle.Views.TileView"
             xmlns:conv="clr-namespace:Qwirkle.Converters"
             x:Name="Root"
             xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
    <ContentView.Resources>
        <conv:Int2ColorConverter x:Key="Int2ColorConverter"/>
        <conv:RhombusToVisibilityConverter x:Key="RhombusToVisibilityConverter"/>
        <conv:RoundToVisibilityConverter x:Key="RoundToVisibilityConverter"/>
        <conv:SquareToVisibilityConverter x:Key="SquareToVisibilityConverter"/>
        <conv:ClubToVisibilityConverter x:Key="ClubToVisibilityConverter"/>
        <conv:ShurikenToVisibilityConverter x:Key="ShurikenToVisibilityConverter"/>
        <conv:StarToVisibilityConverter x:Key="StarToVisibilityConverter"/>
    </ContentView.Resources>
    <Grid>

            <!-- Étoile / Star -->
        <Grid
            IsVisible="{Binding Shape, Source={x:Reference Root}, Converter={StaticResource StarToVisibilityConverter}}">
            <Ellipse HeightRequest="10"
                     WidthRequest="50"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     Grid.Row="0"
                     Grid.Column="0" />
            <Ellipse HeightRequest="10"
                     WidthRequest="50"
                     Rotation="45"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     Grid.Row="0"
                     Grid.Column="0"/>
            <Ellipse HeightRequest="10"
                     WidthRequest="50"
                     Rotation="90"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     Grid.Row="0"
                     Grid.Column="0" />
            <Ellipse HeightRequest="10"
                     WidthRequest="50"
                     Rotation="135"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     Grid.Row="0"
                     Grid.Column="0" />
        </Grid>

            <!-- Shuriken -->
        <Grid
            IsVisible="{Binding Shape, Source={x:Reference Root}, Converter={StaticResource ShurikenToVisibilityConverter}}">
            <Ellipse HeightRequest="10"
                     WidthRequest="50"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     Grid.Row="0"
                     Grid.Column="0" />
            <Ellipse HeightRequest="10"
                     WidthRequest="50"
                     Rotation="90"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     Grid.Row="0"
                     Grid.Column="0" />
        </Grid>
        
            <!-- Trèfle / Club -->
        <Grid
            RowDefinitions="60"
            ColumnDefinitions="60"
            Padding="5, 5, 0, 0"
            IsVisible="{Binding Shape, Source={x:Reference Root}, Converter={StaticResource ClubToVisibilityConverter}}">
            <Ellipse HeightRequest="26"
                     WidthRequest="26"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     HorizontalOptions="Start" 
                     VerticalOptions="Center"
                     Grid.Column="0"
                     Grid.Row="0"/>
            <Ellipse HeightRequest="26"
                     WidthRequest="26"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     HorizontalOptions="End"
                     VerticalOptions="Center"
                     Grid.Column="0"
                     Grid.Row="0" />
            <Ellipse HeightRequest="26"
                     WidthRequest="26"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     VerticalOptions="End"
                     HorizontalOptions="Center"
                     Grid.Column="0"
                     Grid.Row="0" />
            <Ellipse HeightRequest="26"
                     WidthRequest="26"
                     Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
                     VerticalOptions="Start"
                     HorizontalOptions="Center"
                     Grid.Column="0"
                     Grid.Row="0"/>
            <Rectangle HeightRequest="20"
                       WidthRequest="20"
                       StrokeThickness="0"
                       VerticalOptions="Center"
                       HorizontalOptions="Center"
                       Grid.Column="0"
                       Grid.Row="0"
                       Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}" />
        </Grid>
        
        <Rectangle HeightRequest="70"
        Grid.Row="0"
        Grid.Column="0"
        WidthRequest="70"
        VerticalOptions="Center"
        HorizontalOptions="Center"
        BackgroundColor="Transparent"/>

            <!--Rond / round-->
        <Ellipse HeightRequest="50"
            WidthRequest="50"
            Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
            VerticalOptions="Center"
            HorizontalOptions="Center"
            IsVisible="{Binding Shape, Source={x:Reference Root}, Converter={StaticResource RoundToVisibilityConverter}}" />

            <!--Losange / Rhombus-->
        <Rectangle HeightRequest="35"
            Grid.Row="0"
            Grid.Column="0"
            Rotation="45"
            StrokeThickness="0"
            WidthRequest="35"
            VerticalOptions="Center"
            HorizontalOptions="Center"
            Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
            IsVisible="{Binding Shape, Source={x:Reference Root}, Converter={StaticResource RhombusToVisibilityConverter}}" />

            <!--Carre / Square-->
        <Rectangle HeightRequest="40"
            Grid.Row="0"
            Grid.Column="0"
            WidthRequest="40"
            StrokeThickness="0"
            VerticalOptions="Center"
            HorizontalOptions="Center"
            Fill="{Binding Color, Source={x:Reference Root}, Converter={StaticResource Int2ColorConverter}}"
            IsVisible="{Binding Shape, Source={x:Reference Root}, Converter={StaticResource SquareToVisibilityConverter}}" />
        
    </Grid>
</ContentView>