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

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

        <Hub x:Name="Container" DataContext="{Binding}" Header="{Binding NavigationHelper}" HeaderTemplate="{StaticResource MainPageHeader}" 
             SectionHeaderClick="OnSectionHeaderClick" SectionsInViewChanged="OnSectionsInViewChanged">
            <HubSection x:Name="DiariosDeMexicoYElMundoSection" Header="Diarios de Mexico y el Mundo" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}" DataContext="{Binding MainViewModel.DiariosDeMexicoYElMundoModel}"
                        d:DataContext="{d:DesignData Source=/Assets/Data/DiariosDeMexicoYElMundoDataSource.json, Type=vm:DiariosDeMexicoYElMundoViewModel, IsDesignTimeCreatable=true}"
                        ContentTemplate="{StaticResource DiariosDeMexicoYElMundoList}" IsHeaderInteractive="{Binding HasMoreItems}" Padding="120,12,0,30"
                        Style="{StaticResource HubSectionStyle}"/>
            <HubSection x:Name="ActualidadYNovedadesSection" Header="Actualidad y Novedades" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}" DataContext="{Binding MainViewModel.ActualidadYNovedadesModel}"
                        d:DataContext="{d:DesignData Source=/Assets/Data/ActualidadYNovedadesDataSource.json, Type=vm:ActualidadYNovedadesViewModel, IsDesignTimeCreatable=true}"
                        ContentTemplate="{StaticResource ActualidadYNovedadesList}" IsHeaderInteractive="{Binding HasMoreItems}" Padding="80,12,0,30"
                        Style="{StaticResource HubSectionStyle}"/>
            <HubSection x:Name="SoftwareHardwareEInternetSection" Header="Software Hardware e Internet" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}" DataContext="{Binding MainViewModel.SoftwareHardwareEInternetModel}"
                        d:DataContext="{d:DesignData Source=/Assets/Data/SoftwareHardwareEInternetDataSource.json, Type=vm:SoftwareHardwareEInternetViewModel, IsDesignTimeCreatable=true}"
                        ContentTemplate="{StaticResource SoftwareHardwareEInternetList}" IsHeaderInteractive="{Binding HasMoreItems}" Padding="80,12,0,30"
                        Style="{StaticResource HubSectionStyle}"/>
            <HubSection x:Name="ContactoSection" Header="Contacto" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}" DataContext="{Binding MainViewModel.ContactoModel}"
                        d:DataContext="{d:DesignData Source=/Assets/Data/ContactoDataSource.json, Type=vm:ContactoViewModel, IsDesignTimeCreatable=true}"
                        ContentTemplate="{StaticResource ContactoList}" IsHeaderInteractive="{Binding HasMoreItems}" Padding="80,12,0,30"
                        Style="{StaticResource HubSectionStyle}"/>
            <HubSection x:Name="AcercaDeSection" Header="Acerca de" HeaderTemplate="{StaticResource HubSectionHeaderTemplate}" DataContext="{Binding MainViewModel.AcercaDeModel}"
                        d:DataContext="{d:DesignData Source=/Assets/Data/AcercaDeDataSource.json, Type=vm:AcercaDeViewModel, IsDesignTimeCreatable=true}"
                        ContentTemplate="{StaticResource AcercaDeList}" IsHeaderInteractive="{Binding HasMoreItems}" Padding="80,12,120,30"
                        Style="{StaticResource HubSectionStyle}"/>
        </Hub>

        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup>
                <VisualState x:Name="SnappedView">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Container" Storyboard.TargetProperty="HeaderTemplate">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource MainPageHeaderSnapped}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DiariosDeMexicoYElMundoSection" Storyboard.TargetProperty="ContentTemplate">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource DiariosDeMexicoYElMundoListSnapped}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="DiariosDeMexicoYElMundoSection" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="24,10,24,10"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ActualidadYNovedadesSection" Storyboard.TargetProperty="ContentTemplate">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ActualidadYNovedadesListSnapped}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ActualidadYNovedadesSection" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="24,10,24,10"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SoftwareHardwareEInternetSection" Storyboard.TargetProperty="ContentTemplate">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SoftwareHardwareEInternetListSnapped}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SoftwareHardwareEInternetSection" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="24,10,24,10"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContactoSection" Storyboard.TargetProperty="ContentTemplate">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ContactoListSnapped}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContactoSection" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="24,10,24,10"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="AcercaDeSection" Storyboard.TargetProperty="ContentTemplate">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource AcercaDeListSnapped}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="AcercaDeSection" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="24,10,24,10"/>
                        </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 MainViewModel}" Command="{Binding RefreshCommand}" Visibility="{Binding RefreshVisibility}"/>
        </CommandBar>
    </Page.BottomAppBar>
</Page>
