<?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="Views.View_DetailAnimal">
    <VerticalStackLayout>
        <!-- Pet image -->
        <Image Source="{Binding Image}"
                   MaximumWidthRequest="300"
                   HorizontalOptions="Center"/>

        <!-- To add or change the image -->
        <Button Text="Ajouter photo" 
                    VerticalOptions="Center"
                    HorizontalOptions="End"
                    Clicked="TakePhoto"/>

        <!-- Display and change pet name -->
        <HorizontalStackLayout HorizontalOptions="Center">
            <Label Text="Nom"
                       VerticalOptions="Center"/>
            <Entry Text="{Binding Nom}"
                       Margin="20,0,0,0">

                <!-- To change the background if there is a name -->
                <Entry.Triggers>
                    <DataTrigger TargetType="Entry"
                                     Binding="{Binding NomIsValid}"
                                     Value="false">
                        <Setter Property="BackgroundColor" Value="{StaticResource Error}" />
                    </DataTrigger>
                    <DataTrigger TargetType="Entry"
                                     Binding="{Binding NomIsValid}"
                                     Value="true">
                        <Setter Property="BackgroundColor" Value="Transparent" />
                    </DataTrigger>
                </Entry.Triggers>
            </Entry>
        </HorizontalStackLayout>


        <Border VerticalOptions="Start"
                    Grid.Column="1"
                    Margin="0, 10, 0, 10">
            <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto"
                      ColumnDefinitions="*, *"
                      RowSpacing="8">
                <!-- Display and change date of birth -->
                <Label Text="Date de naissance"/>
                <DatePicker Date="{Binding DateNaissance}"/>

                <!-- Display and change gender -->
                <Label Grid.Row="1"
                           Text="Sexe"/>
                <Picker Grid.Row="1"
                                SelectedItem="{Binding Sexe}"
                                SelectedIndexChanged="SexeClick">
                    <Picker.Items>
                        <x:String>Femelle</x:String>
                        <x:String>Male</x:String>
                    </Picker.Items>
                </Picker>

                <!-- Display and change date of adoption -->
                <Label Grid.Row="2"
                       Text="Date d'adoption"/>
                <DatePicker Grid.Row="2"
                            Date="{Binding DateAdoption}"/>

                <!-- Display and change size -->
                <Label Grid.Row="3"
                           Text="Taille"/>
                <HorizontalStackLayout Grid.Column="1" 
                                       Grid.Row="3"
                                       HorizontalOptions="End">
                    <Entry Text="{Binding Taille}"/>
                    <Label Text=" cm" 
                           VerticalOptions="Center"
                           FontFamily="Raleway"
                           FontAttributes="None"/>
                </HorizontalStackLayout>

                <!-- Display and change weight -->
                <Label Grid.Row="4"
                           Text="Poids"/>
                <HorizontalStackLayout Grid.Column="2" 
                                       Grid.Row="4"
                                       HorizontalOptions="End">
                    <Entry Text="{Binding Poids}"/>
                    <Label Text=" kg" 
                               VerticalOptions="Center"
                               FontFamily="Raleway"
                               FontAttributes="None"/>
                </HorizontalStackLayout>

                <!-- Display and change power supply -->
                <Label Grid.Row="5"
                           Text="Alimentation"/>
                <Entry Grid.Row="5"
                           Text="{Binding Alimentation}"/>

                <!-- Display and change species -->
                <Label Grid.Row="6"
                           Text="Espèce"/>
                <Grid Grid.Row="6"
                          Grid.Column="1"
                          ColumnDefinitions="*"
                          RowDefinitions="Auto, Auto">
                    <Label Text="{Binding Espece}"
                               VerticalOptions="Start"
                               HorizontalOptions="End"
                               FontFamily="Raleway"
                               FontAttributes="None"/>
                    <Picker x:Name="Picker_especes"
                                Grid.Row="1"
                                ItemsSource="{Binding ListeEspeces}"
                                ItemDisplayBinding="{Binding Nom}"
                                SelectedIndexChanged="EspeceClic">
                    </Picker>
                </Grid>

                <!-- Display and change breed -->
                <Label Grid.Row="7"
                           Text="Race"/>
                <Grid Grid.Row="7"
                          Grid.Column="1"
                          ColumnDefinitions="*"
                          RowDefinitions="Auto, Auto">
                    <Label Text="{Binding Race}"
                               VerticalOptions="Start"
                               HorizontalOptions="End"
                               FontFamily="Raleway"
                               FontAttributes="None"/>
                    <Picker Grid.Row="1"
                                ItemsSource="{Binding Espece.ListeRaces}"
                                ItemDisplayBinding="{Binding Nom}"
                                SelectedIndexChanged="RaceClic">
                    </Picker>
                </Grid>
            </Grid>
        </Border>


        <!-- Display and change petsitter -->
        <VerticalStackLayout Margin="0, 10, 0, 10">
            <Label Text="Petsitter"
                       FontSize="Large"/>
            <Border>
                <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
                          ColumnDefinitions="*, *">
                    <!-- Display and change petsitter's name -->
                    <Label Text="Nom"/>
                    <Entry Text="{Binding Petsitter.Nom}"/>

                    <!-- Display and change petsitter's address -->
                    <Label Grid.Row="1"
                               Text="Adresse"/>
                    <Entry Grid.Row="1"
                               Text="{Binding Petsitter.Adresse}"/>

                    <!-- Display and change petsitter's zip code -->
                    <Label Grid.Row="2"
                               Text="Code postal"/>
                    <Entry Grid.Row="2"
                           Text="{Binding Petsitter.CodePostal}"/>

                    <!-- Display and change petsitter's city -->
                    <Label Grid.Row="3"
                               Text="Ville"/>
                    <Entry Grid.Row="3"
                               Text="{Binding Petsitter.Ville}"/>

                    <!-- Display and change petsitter's phone number -->
                    <Label Grid.Row="4"
                               Text="Numéro de téléphone"/>
                    <Entry Grid.Row="4"
                               Text="{Binding Petsitter.NumTel}"/>
                </Grid>
            </Border>
        </VerticalStackLayout>

        <!-- Display and change kennel -->
        <VerticalStackLayout Margin="0, 10, 0, 10">
            <Label Text="Chenil"
                       FontSize="Large"/>
            <Border>
                <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
                          ColumnDefinitions="*, *">
                    <!-- Display and change kennel's name -->
                    <Label Text="Nom"/>
                    <Entry Text="{Binding Chenil.Nom}"/>

                    <!-- Display and change kennel's address -->
                    <Label Grid.Row="1"
                               Text="Adresse"/>
                    <Entry Grid.Row="1"
                               Text="{Binding Chenil.Adresse}"/>

                    <!-- Display and change kennel's zip code -->
                    <Label Grid.Row="2"
                               Text="Code postal"/>
                    <Entry Grid.Row="2"
                               Text="{Binding Chenil.CodePostal}"/>

                    <!-- Display and change kennel's city -->
                    <Label Grid.Row="3"
                               Text="Ville"/>
                    <Entry Grid.Row="3"
                               Text="{Binding Chenil.Ville}"/>

                    <!-- Display and change kennel's phone number -->
                    <Label Grid.Row="4"
                               Text="Numéro de téléphone"/>
                    <Entry Grid.Row="4"
                               Text="{Binding Chenil.NumTel}"/>
                </Grid>
            </Border>
        </VerticalStackLayout>

        <!-- Display and change veterinarian -->
        <VerticalStackLayout Margin="0, 10, 0, 10">
            <Label Text="Vétérinaire"
                       FontSize="Large"/>
            <Border>
                <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto"
                          ColumnDefinitions="*, *">
                    <!-- Display and change vet's name -->
                    <Label Text="Nom"/>
                    <Entry Text="{Binding Veterinaire.Nom}"/>

                    <!-- Display and change vet's clinic -->
                    <Label Grid.Row="1"
                               Text="Clinique"/>
                    <Entry Grid.Row="1"
                               Text="{Binding Veterinaire.Clinique}"/>

                    <!-- Display and change vet's address -->
                    <Label Grid.Row="2"
                               Text="Adresse"/>
                    <Entry Grid.Row="2"
                               Text="{Binding Veterinaire.Adresse}"/>

                    <!-- Display and change vet's zip code -->
                    <Label Grid.Row="3"
                               Text="Code postal"/>
                    <Entry Grid.Row="3"
                               Text="{Binding Veterinaire.CodePostal}"/>

                    <!-- Display and change vet's city -->
                    <Label Grid.Row="4"
                               Text="Ville"/>
                    <Entry Grid.Row="4"
                               Text="{Binding Veterinaire.Ville}"/>

                    <!-- Display and change vet's phone number -->
                    <Label Grid.Row="5"
                               Text="Numéro de téléphone"/>
                    <Entry Grid.Row="5"
                               Text="{Binding Veterinaire.NumTel}"/>
                </Grid>
            </Border>
        </VerticalStackLayout>

        <!-- Display and change food store -->
        <VerticalStackLayout Margin="0, 10, 0, 10">
            <Label Text="Magasin alimentaire"
                       FontSize="Large"/>
            <Border>
                <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
                          ColumnDefinitions="*, *">
                    <!-- Display and change food store name -->
                    <Label Text="Nom"/>
                    <Entry Text="{Binding MagasinAlimentaire.Nom}"/>

                    <!-- Display and change food store address -->
                    <Label Grid.Row="1"
                               Text="Adresse"/>
                    <Entry Text="{Binding MagasinAlimentaire.Adresse}"/>

                    <!-- Display and change food store zip code -->
                    <Label Grid.Row="2"
                               Text="Code postal"/>
                    <Entry Grid.Row="2"
                               Text="{Binding MagasinAlimentaire.CodePostal}"/>

                    <!-- Display and change food store city -->
                    <Label Grid.Row="3"
                               Text="Ville"/>
                    <Entry Grid.Row="3"
                               Text="{Binding MagasinAlimentaire.Ville}"/>

                    <!-- Display and change food store phone number -->
                    <Label Grid.Row="4"
                               Text="Numéro de téléphone"/>
                    <Entry Grid.Row="4"
                               Text="{Binding MagasinAlimentaire.NumTel}"/>
                </Grid>
            </Border>
        </VerticalStackLayout>

        <!-- Display and change provenance -->
        <VerticalStackLayout Margin="0, 10, 0, 10">
            <Label Text="Refuge, élevage, chenil de provenance"
                       FontSize="Large"/>
            <Border>
                <Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto"
                          ColumnDefinitions="*, *">
                    <!-- Display and change provenance's name -->
                    <Label Text="Nom"/>
                    <Entry Text="{Binding Provenance.Nom}"/>

                    <!-- Display and change provenance's address -->
                    <Label Grid.Row="1"
                               Text="Adresse"/>
                    <Entry Grid.Row="1"
                               Text="{Binding Provenance.Adresse}"/>

                    <!-- Display and change provenance's zip code -->
                    <Label Grid.Row="2"
                               Text="Code postal"/>
                    <Entry Grid.Row="2"
                               Text="{Binding Provenance.CodePostal}"/>

                    <!-- Display and change provenance's city -->
                    <Label Grid.Row="3"
                               Text="Ville"/>
                    <Entry Grid.Row="3"
                               Text="{Binding Provenance.Ville}"/>

                    <!-- Display and change provenance's phone number -->
                    <Label Grid.Row="4"
                               Text="Numéro de téléphone"/>
                    <Entry Grid.Row="4"
                               Text="{Binding Provenance.NumTel}"/>
                </Grid>
            </Border>
        </VerticalStackLayout>
    </VerticalStackLayout>
</ContentView>
