<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiAppStock.Views.MouvementStockHistoryPage"
             Title="Historique des Mouvements">
    <Grid RowDefinitions="Auto,*">
        <VerticalStackLayout Grid.Row="0" Spacing="10" Padding="20">
            <Label Text="Historique des Mouvements de Stock" 
                   SemanticProperties.HeadingLevel="Level1"
                   FontSize="24"
                   HorizontalOptions="Center" />
            
            <Picker x:Name="FilterPicker"
                    Title="Filtrer par type"
                    SelectedIndexChanged="OnFilterChanged">
                <Picker.Items>
                    <x:String>Tous</x:String>
                    <x:String>Entrée Stock</x:String>
                    <x:String>Sortie Réparation</x:String>
                </Picker.Items>
            </Picker>
        </VerticalStackLayout>

        <CollectionView Grid.Row="1" 
                       x:Name="MouvementsCollection"
                       SelectionMode="None">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <Frame Margin="10" Padding="10">
                        <Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto,Auto">
                            <Label Text="{Binding NomPiece}" 
                                   FontSize="16" 
                                   FontAttributes="Bold"
                                   Grid.Column="0" 
                                   Grid.Row="0"/>
                            
                            <Label Text="{Binding DateMouvement, StringFormat='{0:dd/MM/yyyy HH:mm}'}"
                                   Grid.Column="1" 
                                   Grid.Row="0"/>
                            
                            <Label Text="{Binding Type, StringFormat='Type: {0}'}"
                                   Grid.Column="0" 
                                   Grid.Row="1"/>
                            
                            <Label Text="{Binding Quantite, StringFormat='Quantité: {0}'}"
                                   Grid.Column="1" 
                                   Grid.Row="1"/>
                            
                            <Label Text="{Binding Commentaire}"
                                   Grid.Column="0" 
                                   Grid.ColumnSpan="2"
                                   Grid.Row="2"
                                   IsVisible="{Binding HasComment}"/>
                        </Grid>
                    </Frame>
                </DataTemplate>
            </CollectionView.ItemTemplate>
        </CollectionView>
    </Grid>
</ContentPage> 