<?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:conv="clr-namespace:inutralia.Converters;assembly=inutralia"              
             xmlns:views="clr-namespace:inutralia.Views;assembly=inutralia"             
             x:Class="inutralia.Views.RecipeListView"
             x:Name="recipeListView" 
             BackgroundColor="White"
             Title="Recetas">

    <ContentPage.ToolbarItems>
        <ToolbarItem Icon="icon_filter.png" Clicked="ToolbarFiltersClicked" />
    </ContentPage.ToolbarItems>

    <ContentPage.Resources>
        <ResourceDictionary>
            <conv:ImageTransformator x:Key="cnvImg"></conv:ImageTransformator>
        </ResourceDictionary>
    </ContentPage.Resources>

    <StackLayout VerticalOptions="FillAndExpand">

        <ActivityIndicator HorizontalOptions="FillAndExpand" IsRunning="{Binding IsBusy}" IsVisible="{Binding IsBusy}"/>

        <Label Text="Buscando recetas..." 
               VerticalOptions="CenterAndExpand"
               VerticalTextAlignment="Center" 
               HorizontalTextAlignment="Center"
               IsVisible="{Binding IsBusy}"/>

        <Label Margin="8,0,8,0"
               Text="No se encontraron resultados. Cambie los filtros y pulse Aplicar"
               VerticalOptions="CenterAndExpand" 
               VerticalTextAlignment="Center"
               HorizontalTextAlignment="Center"
               IsVisible="{Binding IsEmpty}"/>

        <ListView VerticalOptions="FillAndExpand"
                  SeparatorVisibility="None"
                  SeparatorColor="{ DynamicResource ListViewSeparatorColor }"
                  ItemsSource="{Binding Recipes}"
                  RowHeight="240"
                  ItemTapped="ItemTapped"
                  HasUnevenRows="false"
                  x:Name="listRecipe"
                  IsVisible="{Binding IsNotEmpty}">

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <views:RecipeItemTemplate/>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</ContentPage>

