<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="inutralia.Views.NutriQuestion.DetailsNutriQuestionListView"
             Title="Detalles De La consulta">

    <Grid Padding="10,10,10,10">

        <Grid.RowDefinitions>
            <RowDefinition  Height="10*" />
            <RowDefinition  Height="70*"/>
            <RowDefinition  Height="20*"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <!--cabecera con asunto de consulta-->
        <StackLayout Grid.Row="0" Grid.Column="0"
                 BackgroundColor="#333333">
            <Label 
               Margin="15,15,0,15"
               TextColor="#ffffff"
               FontAttributes="Bold"
               Text="{ Binding Conversation.Subject }"/>
        </StackLayout>


        <!--lista con conversación chat-->

        <ListView Grid.Row="1" Grid.Column="0"
            x:Name="MyListView"
            ItemsSource="{Binding Conversation.Messages}"
            CachingStrategy="RecycleElement"
            HasUnevenRows ="True">

            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid Padding="10,10,10,10">
                            <Grid.RowDefinitions>
                                <RowDefinition  />
                                <RowDefinition Height="20"/>
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="20*" />
                                <ColumnDefinition Width="80*" />
                            </Grid.ColumnDefinitions> 

                            <!-- row 3 span, col 0  icono  -->

                            <Image Grid.RowSpan="2" Grid.Column="0"
                              Source="user_chat.png" 
                              Aspect="AspectFit" 
                              WidthRequest="45"
                              HorizontalOptions="Start"     
                              VerticalOptions="CenterAndExpand"/>


                            <!-- row 1 span, col 0  icono  -->

                            <Label Grid.Row="0" Grid.Column="1"
                               TextColor="#000000"
                               FontAttributes="Bold"
                               Text="{Binding Text}"/>


                            <Label  Grid.Row="1" Grid.Column="1"
                               FontSize="Micro"
                               TextColor="#000000"
                               Text="{Binding Created_at }"/>


                           <!-- <Label  Grid.Row="1" Grid.Column="1"
                                XAlign="End"
                                FontSize="Micro"
                             TextColor="#000000"
                               Text="{Binding Read_message}"/>-->

                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>

        </ListView>

        <!-- prueba hasta que cargue todos mensajes lista-->
     <!--   <StackLayout Grid.Row="1" Grid.Column="0"
                 BackgroundColor="Pink">
            <Label 
               Margin="15,15,0,15"
               TextColor="#ffffff"
               FontAttributes="Bold"
				Text="{ Binding Conversation.Subject }"/>

            <Label 
               Margin="15,15,0,15"
               TextColor="#ffffff"
               FontAttributes="Bold"
				Text="{ Binding Conversation.Created_at }"/>
        </StackLayout>-->



        <StackLayout Grid.Row="2" Grid.Column="0"  >
      
            <Entry 
                   Placeholder="Escribe un mensaje.."
                    x:Name="messageEntry" 
                    HeightRequest="45"
                    VerticalOptions="FillAndExpand" 
                    IsVisible="{Binding CanLoadMore}"/>

            <Button Text="ENVIAR >"
                Clicked="OnSendButtonClicked"
                HorizontalOptions="FillAndExpand"
                BackgroundColor="#333333"
                TextColor="#ffffff"
                Margin="0,30,0,0"    
                x:Name="btnEnviar"
                IsVisible="{Binding CanLoadMore}"/>

            <Label  
                   FontSize="Micro"
                   TextColor="#000000"
                   HorizontalTextAlignment="Start"
                   x:Name="infoText"
                  Text="{Binding Title }"/>
            
        </StackLayout>
    </Grid>

</ContentPage>
