<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:artina="clr-namespace:UXDivers.Artina.Shared;assembly=UXDivers.Artina.Shared"            
             x:Class="inutralia.Views.ShoppingListView"
             x:Name="shoppingListView" 
             Title="Lista de la Compra"
             BackgroundColor="{DynamicResource BasePageColor}">

    <ContentPage.ToolbarItems>
        <ToolbarItem Icon="icon_info.png" artina:Theme.Name="Info" Clicked="InfoButtonClicked"/>
    </ContentPage.ToolbarItems>

    <ContentPage.Content>
        <StackLayout Margin="10,10"  VerticalOptions="FillAndExpand" IsVisible="{Binding isBusy}">

            <ListView ItemsSource="{Binding ShoppingList}"
                      ItemTapped="ItemTapped"           
                      IsPullToRefreshEnabled="True"
                      RefreshCommand="{Binding RefreshShoppingListCommand}"
                      IsRefreshing="{Binding IsBusy, Mode=OneWay}"
                      BackgroundColor="Transparent"
                      Footer=""
                      CachingStrategy="RecycleElement"         
                      HasUnevenRows="False"
                      Margin="10,20"              
                      x:Name="ListView">

                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <Grid Margin="0,10,0,10" VerticalOptions="CenterAndExpand">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>

                                <StackLayout >
                                    <Label Text="{Binding Text}" FontSize="Medium"/>
                                </StackLayout>

                                <Switch IsToggled="{Binding Select}" Grid.Column="1" />
                            </Grid>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

            <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" >
                <!--button 1-->
                <artina:Button x:Name="addButton"
                               HorizontalOptions="FillAndExpand"
                               VerticalOptions="Center"
						       Clicked="OnAddButtonClicked"                        
						       Style="{DynamicResource PrimaryActionButtonStyle}"                         
						       Text= "Añadir    productos"
                               FontSize="Medium"/>

                <artina:Button x:Name="addDelSuperButton"
                               HorizontalOptions="FillAndExpand"
                               VerticalOptions="Center"
						       Clicked="OnAddDelSuperButtonClicked"                        
					           Style="{DynamicResource PrimaryActionButtonStyle}" 
                               BackgroundColor="#3b5998"
						       Text= "Comprar    en    DELSUPER"
                               FontSize="Medium"/>
            </StackLayout>

            <StackLayout Orientation="Horizontal">
                <!--button 2-->
                <artina:Button x:Name="deleteButton"
                               HorizontalOptions="FillAndExpand" 
                               VerticalOptions="Center"
						       Clicked="OnDeleteButtonClicked"                        
						       Style="{DynamicResource DeleteButtonStyle}"                       
						       Text ="Borrar    marcados" 
                               FontSize="Small"/>

                <!--button 3-->
                <artina:Button x:Name="deleteAllButton"
                               HorizontalOptions="FillAndExpand"
                               VerticalOptions="Center"
						       Clicked="OnDeleteAllButtonClicked"                       
						       Style="{DynamicResource DeleteButtonStyle}"                     
						       Text="Borrar    todos"
                               FontSize="Small"/>
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>