<?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="TripLog.Views.NewEntryPage"
    xmlns:controls="clr-namespace:TripLog.Controls;assembly=TripLog"
    xmlns:converters="clr-namespace:TripLog.Converters;assembly=TripLog"
    Title="New Entry">
    <ContentPage.Resources>
        <ResourceDictionary>
            <converters:ReverseBooleanConverter x:Key="ReverseBooleanConverter" />
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="Save" Command="{Binding SaveCommand}" />
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <Grid>
            <TableView Intent="Form" IsVisible="{Binding IsBusy, Converter={StaticResource ReverseBooleanConverter}}">
                <TableView.Root>
                    <TableSection>
                        <EntryCell x:Name="title" Label="Title" Text="{Binding Title}" />
                        <EntryCell Label="Latitude" Keyboard="Numeric" Text="{Binding Latitude}" />
                        <EntryCell Label="Longitude" Keyboard="Numeric" Text="{Binding Longitude}" />
                        <controls:DatePickerEntryCell Label="Date" Date="{Binding Date, StringFormat='{0:d}'}" />
                        <EntryCell x:Name="rating" Label="Rating" Keyboard="Numeric" Text="{Binding Rating}" />
                        <EntryCell Label="Notes" Text="{Binding Notes}" />
                    </TableSection>
                </TableView.Root>
            </TableView>

            <StackLayout Orientation="Vertical" VerticalOptions="Center" HorizontalOptions="Center" IsVisible="{Binding IsBusy}">
                <ActivityIndicator IsRunning="True" />
                <Label Text="Saving new entry..." />
            </StackLayout>
        </Grid>
    </ContentPage.Content>
</ContentPage>