<?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="FillAndExpand"
                       VerticalOptions="Center"
                       IsVisible="{Binding IsBusy}"
                       IsRunning="{Binding IsBusy}"/>
    <StackLayout Grid.Row="0" BackgroundColor="#5ABAFF" Padding="10,10,10,5">
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition/>
          <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Entry Text="{Binding Name}" 
               Placeholder="Item name" />
        <StackLayout Grid.Column="1" 
                     Orientation="Horizontal" 
                     HorizontalOptions="StartAndExpand">
          <Button Text="Add"
                  MinimumHeightRequest="30"
                  Command="{Binding AddCommand}" />
          <Button Text="Sync"
                MinimumHeightRequest="30"
                Command="{Binding SyncCommand}" />
        </StackLayout>
      </Grid>
    </StackLayout>
    <ListView 
        ItemsSource="{Binding Items}"
				ItemSelected="OnSelected"
				IsPullToRefreshEnabled="true" 
        IsRefreshing="{Binding IsBusy, Mode=OneWay}"
        RefreshCommand="{Binding SyncCommand}"
        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>
