<Page
    x:Class="AppStudio.Views.NeoteoPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:AppStudio.Views"
     xmlns:controls="using:AppStudio.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:commands="using:AppStudio.Commands"
    xmlns:vm="using:AppStudio.ViewModels"
    mc:Ignorable="d">

    <Grid Background="{StaticResource AppBackground}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <TextBlock x:Name="Title" Grid.Row="1" Margin="120,0,0,0" Style="{StaticResource PageTitleStyle}">Neoteo</TextBlock>

        <Grid Grid.Row="2" DataContext="{Binding NeoteoModel}" 
              d:DataContext="{d:DesignData Source=/Assets/Data/NeoteoDataSource.json, Type=vm:NeoteoViewModel, IsDesignTimeCreatable=true}">

            <GridView x:Name="List" Margin="0,12,0,0" Padding="120,0,120,20" ItemsSource="{Binding Items}"
                      SelectionMode="None" IsSwipeEnabled="False" IsItemClickEnabled="True" commands:ItemClickCommand.Command="{Binding ItemClickCommand}"
                      ScrollViewer.VerticalScrollBarVisibility="Hidden"
                      ItemTemplate="{StaticResource NeoteoItem}"/>
            <ListView x:Name="ListSnapped" Margin="30,0,0,0" ItemsSource="{Binding Items}"
                      SelectionMode="None" IsSwipeEnabled="False" IsItemClickEnabled="True" commands:ItemClickCommand.Command="{Binding ItemClickCommand}"
                      Width="240" HorizontalAlignment="Left"
                      ScrollViewer.VerticalScrollBarVisibility="Hidden"
                      ItemTemplate="{StaticResource NeoteoItemSnapped}"
                      Visibility="Collapsed"/>
            <ProgressBar Width="520" Height="40" IsIndeterminate="True" Visibility="{Binding ProgressBarVisibility}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Grid>

      <!-- Back button and page title -->
      <ContentPresenter x:Name="HeaderHost" Grid.Row="0" ContentTemplate="{StaticResource PageHeader}" Content="{Binding NavigationHelper}" />

      <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="SnappedView">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderHost" Storyboard.TargetProperty="ContentTemplate">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PageHeaderSnapped}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Title" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="24,24,0,0"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="List" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ListSnapped" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="FullscreenView">
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>

    <Page.BottomAppBar>
        <CommandBar Background="{StaticResource AppBarBackground}" BorderBrush="{StaticResource AppBarBackground}" Foreground="{StaticResource AppBarForeground}">
            <AppBarButton x:Uid="RefreshButton" Icon="Refresh" DataContext="{Binding NeoteoModel}" Command="{Binding RefreshCommand}" Visibility="{Binding RefreshVisibility}"/>
        </CommandBar>
    </Page.BottomAppBar>
</Page>
