<?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="DevDaysTasks.TodoList"
				Title="Azure Todo">
  <Grid RowSpacing="0">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <ActivityIndicator Grid.RowSpan="2"
                       HorizontalOptions="Center"
                       VerticalOptions="Center"
                       IsVisible="False"
                       IsEnabled="True"
                       x:Name="syncIndicator"/>
    <StackLayout Grid.Row="0" BackgroundColor="#5ABAFF" Padding="10,10,10,5">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition/>
          <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Entry x:Name="newItemName"
                  Placeholder="Item name" />
        <StackLayout x:Name="buttonsPanel" Grid.Column="1" Orientation="Horizontal" HorizontalOptions="StartAndExpand">
          <Button Text="Add"
                  MinimumHeightRequest="30"
                  Clicked="OnAdd" />
          <Button Text="Sync"
                MinimumHeightRequest="30"
                Clicked="OnSyncItems" />
        </StackLayout>
      </Grid>
    </StackLayout>
    <ListView x:Name="todoList"
				ItemSelected="OnSelected"
				IsPullToRefreshEnabled="true" 
        
        Refreshing="OnRefresh"
        HasUnevenRows="true"
				Grid.Row="1">
      <ListView.ItemTemplate>
        <DataTemplate>
          <ViewCell>
            <ViewCell.ContextActions>
              <MenuItem Clicked="OnComplete" Text="Complete" CommandParameter="{Binding .}"/>
            </ViewCell.ContextActions>
            <StackLayout Padding="10">
              <Label Text="{Binding Name}" FontSize="24"  />
            </StackLayout>
          </ViewCell>
        </DataTemplate>
      </ListView.ItemTemplate>
    </ListView>
  </Grid>
</ContentPage>
