<Page xmlns:local="clr-namespace:ForzaUI"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      x:Class="ForzaUI.Scenes.Anthem.RecommendedDesigns"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>

    <Page.Resources>
        <ResourceDictionary>
            <local:FZBooleanToVisibilityConverter x:Key="A_Converter_BoolToVis"
                                                  InvertResult="false" />

            <Style x:Key="A_Style_FrameworkElement_CollapseIfNoCategories"
                   BasedOn="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                   TargetType="FrameworkElement">
                   <Setter Property="Visibility"
                           Value="Collapsed" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=DesignCategories.Count, RelativeSource={RelativeSource AncestorType=Page}, Converter={StaticResource A_CompareConverter}, ConverterParameter=1}"
                                 Value="1">
                        <Setter Property="Visibility"
                                Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <DataTemplate x:Key="A_DataTemplate_Carousel_RecommendedDesignItem">
                <Grid>
                    <Grid Height="213"
                          Visibility="{Binding IsReady, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
                        <local:FZMaterial ImageSource="{Binding LargeThumbnail}"
                                          Style="{StaticResource A_Style_FrameworkElement_CarSelectItemForeground}"
                                          Margin="0,0,0,0" />
                        <Grid VerticalAlignment="Top"
                              HorizontalAlignment="Center">
                            <local:FZMaterial Preset="{StaticResource A_FZMaterialPresetRoundtangle_FlatPanel_OuterTopOnly}"
                                              Style="{StaticResource A_Style_FZMaterial_CarSelectCarouselItem_ItemTitleBackground}"
                                              Width="342"
                                              Height="78">
                                <Grid Margin="15">
                                    <Decorator Margin="0,-6,0,0">
                                        <local:AutoScrollPanel Style="{StaticResource A_Style_AutoScrollPanel_CarSelectCarTitle}"
                                                               Orientation="Horizontal"
                                                               VerticalAlignment="Top"
                                                               HorizontalAlignment="Center"
                                                               Height="40"
                                                               Width="312"/>
                                    </Decorator>
                                    <Viewbox StretchDirection="DownOnly"
                                             VerticalAlignment="Bottom">
                                        <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_CarSelectCarousel_Manufacturer}"
                                                           Text="{Binding UserProfile.FormattedGamertag, FallbackValue=-}" />
                                    </Viewbox>
                                </Grid>
                            </local:FZMaterial>
                        </Grid>
                    </Grid>
                    <ProgressBar x:Name="Loading"
                                 IsIndeterminate="True"
                                 Style="{StaticResource A_Style_ProgressBar_WaitSpinnerDark}"
                                 Visibility="{Binding IsReady, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"
                                 HorizontalAlignment="Center"
                                 VerticalAlignment="Center" />
                </Grid>
            </DataTemplate>

            <Style x:Key="A_Style_FZMaterial_CreatorFollowedStatus"
                   TargetType="{x:Type local:FZMaterial}"
                   BasedOn="{StaticResource A_Style_FZMaterial_FlatPanel_FooterPanel}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsCreatorFollowed}"
                                 Value="False">
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_ItemStatusBackground_Alt}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding}" Value="{x:Null}">
                        <Setter Property="Color"
                                Value="{StaticResource A_Color_ItemStatusBackground_Alt}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_FZTextBlock_CreatorFollowedStatus"
                   TargetType="{x:Type local:FZTextBlock}"
                   BasedOn="{StaticResource A_Style_FZTextBlock_CreatorInfo_CreatedDate}" />

            <Size x:Key="A_Size_GamerPicSizeParams">342,342</Size>

        </ResourceDictionary>
    </Page.Resources>

    <Grid x:Name="LayoutRoot">
        <!-- Background Blur -->
       <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />

        <local:PlayerBarControl x:Name="TopBar"
                                Style="{StaticResource A_Style_PlayerBarControl_WithTokens}" />

        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <local:ControllerButtonPanel x:Name="HelpPanel"
                                         HorizontalAlignment="Left"
                                         VerticalAlignment="Bottom"
                                         Background="{x:Null}">
                <local:ControllerButtonControl Button="A"
                                               Description="{local:Loc HelpButtons.IDS_Download}"
                                               Visibility="{Binding DesignCollectionDataSource.IsDownloading, Converter={StaticResource A_Converter_BoolToVis}}" />
                <local:ControllerButtonControl Button="B"
                                               Description="{local:Loc HelpButtons.IDS_Back}" />
                <local:ControllerButtonControl Button="X"
                                               Description="{local:Loc HelpButtons.IDS_DesignOptions}" />
                <local:ControllerButtonControl Button="Y"
                                               Visibility="{Binding DesignCollectionDataSource.IsDownloading, Converter={StaticResource A_Converter_BoolToVis}}" />
                <local:ControllerButtonControl Button="Back"
                                               Description="{local:Loc HelpButtons.IDS_Search}" />
            </local:ControllerButtonPanel>
        </ContentControl>

        <Border Style="{StaticResource A_Style_Border_ScenePadding}">
            <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                        Margin="15,50,0,56"
                        VerticalAlignment="Center">
                <ContentControl x:Name="ContentControl_SceneTitle"
                                Content="{Binding Title}"
                                local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Painting.png"
                                Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                HorizontalAlignment="Left" />
                <Grid Style="{StaticResource A_Style_FrameworkElement_CollapseIfNoCategories}">
                    <local:ItemsSelector x:Name="PART_DesignCategoryList" 
                                         ItemsSource="{Binding DesignCategories, RelativeSource={RelativeSource AncestorType=Page}}"
                                         Style="{StaticResource A_Style_TextTabMenuList}"
                                         Focusable="False"
                                         SelectedItem="{Binding SelectedCategory}"
                                         HorizontalAlignment="Left"
                                         Margin="0,0,0,12" />
                </Grid>

                <Grid>
                    <local:WrapListBox Style="{StaticResource A_Style_CommonListBox_FullScreenCarousel}"
                                         ItemContainerStyle="{StaticResource A_Style_ContentControl_Carousel_ContainerStyle}"
                                         ItemTemplate="{StaticResource A_DataTemplate_Carousel_RecommendedDesignItem}"
                                         ItemsSource="{Binding DesignCollectionDataSource, RelativeSource={RelativeSource AncestorType=Page}}"
                                         local:FocusOnPageFocusGained.SelectorSelectedItem="True"
                                         x:Name="PART_DesignList" />
                    <DockPanel LastChildFill="False"
                               Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                               HorizontalAlignment="Left"
                               VerticalAlignment="Center">
                        <local:FZMaterialGlassCapture />
                        <ContentControl DockPanel.Dock="Left"
                                        Style="{StaticResource A_Style_FrameworkElement_FullScreenCarousel_SidePanel}"
                                        Template="{StaticResource A_ControlTemplate_SidePanel}"
                                        x:Name="InformationPanel"
                                        Tag="{Binding Source={local:Loc Livery.IDS_CreatorInfo}, Converter={StaticResource A_StringToUpper}}">
                            <DockPanel DataContext="{Binding SelectedItem, ElementName=PART_DesignList}">
                                <Grid x:Name="CreatorInfo"
                                      DockPanel.Dock="Top">
                                    <local:FZMaterial x:Name="GamerPicMaterial"
                                        ImageSource="{Binding UserProfile, Converter={StaticResource A_GamerPicConverter}, ConverterParameter={StaticResource A_Size_GamerPicSizeParams}}"
                                        Height="342"
                                        Visibility="{Binding Downloaded, RelativeSource={RelativeSource Self}, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}}" />
                                    <ProgressBar Style="{StaticResource A_Style_ProgressBar_WaitSpinner}"
                                        HorizontalAlignment="Center"
                                        VerticalAlignment="Center"
                                        Visibility="{Binding Downloaded, ElementName=GamerPicMaterial, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}"/>
                                    <local:FZMaterial VerticalAlignment="Bottom"
                                                      Height="96"
                                                      Color="#80000000">
                                        <local:FZTextBlock Text="{Binding UserProfile.FormattedGamertag, FallbackValue=-}"
                                                           Style="{StaticResource A_Style_FZTextBlock_CreatorInfo_Gamertag}" />
                                    </local:FZMaterial>
                                </Grid>
                                <local:FZMaterial x:Name="FooterPanel"
                                                  Style="{StaticResource A_Style_FZMaterial_CreatorFollowedStatus}"
                                                  Height="72"
                                                  DockPanel.Dock="Bottom">
                                    <StackPanel x:Name="DateInfo_Panel"
                                                Margin="30,0"
                                                Orientation="Horizontal"
                                                HorizontalAlignment="Center">
                                        <local:FZMaterial ImageSource="/ForzaUI;component/Textures/Data_Bound/Anthem/Icons/Followed_Players.png"
                                                          Height="72"
                                                          Width="120"
                                                          Margin="0,0,-32,0" />
                                        <Grid DockPanel.Dock="Left"
                                              MaxWidth="220">
                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_CreatorFollowedStatus}"
                                                               Text="{local:Loc Storefront.IDS_LabelCreatorFollowed}"
                                                               Visibility="{Binding IsCreatorFollowed, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden}, FallbackValue=Hidden}" />
                                            <local:FZTextBlock Style="{StaticResource A_Style_FZTextBlock_CreatorFollowedStatus}"
                                                               Text="{local:Loc Storefront.IDS_LabelCreatorNotFollowed}"
                                                               Visibility="{Binding IsCreatorFollowed, Converter={StaticResource A_FZBooleanToVisibilityConverter_UseHidden_Inverse}, FallbackValue=Visible}" />
                                        </Grid>
                                    </StackPanel>
                                </local:FZMaterial>
                                <Grid x:Name="PopularityInfo_Panel">
                                    <StackPanel Margin="30"
                                                VerticalAlignment="Top">
                                        <DockPanel Margin="0,0,0,20">
                                            <local:FZTextBlock Text="{local:Loc Storefront.IDS_LabelRecommendation}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                                               DockPanel.Dock="Left"
                                                               VerticalAlignment="Top" />
                                            <Grid DockPanel.Dock="Right">
                                                <local:FZTextBlock Text="{Binding ReasonCurated}"
                                                                   Style="{StaticResource A_Style_FZTextBlock_InfoValue}"
                                                                   Visibility="{Binding ReasonCurated, Converter={StaticResource A_StringVisConverter}}"
                                                                   HorizontalAlignment="Right"
                                                                   TextWrapping="Wrap"
                                                                   TextAlignment="Right" />
                                                <local:FZTextBlock Text="-"
                                                                   Visibility="{Binding ReasonCurated, Converter={StaticResource A_StringVisConverter_Inverse}}"
                                                                   HorizontalAlignment="Right"
                                                                   Style="{StaticResource A_Style_FZTextBlock_InfoValue}" />
                                            </Grid>
                                        </DockPanel>
                                        <Grid Margin="0,0,0,20">
                                            <local:FZTextBlock Text="{Binding Source={local:Loc Storefront.IDS_NumberLikes}, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                                               Margin="0,0,15,0" />
                                            <local:FZTextBlock Text="{Binding LikeCount, FallbackValue=-}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoValue}" />
                                        </Grid>
                                        <Grid Margin="0,0,0,20">
                                            <local:FZTextBlock Text="{Binding Source={local:Loc Storefront.IDS_NumberDownloads}, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                                               Margin="0,0,15,0" />
                                            <local:FZTextBlock Text="{Binding DownloadCount, FallbackValue=-}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoValue}" />
                                        </Grid>
                                        <Grid>
                                            <local:FZTextBlock Text="{Binding Source={local:Loc Storefront.IDS_LabelPopularity}, Converter={StaticResource A_StringToUpper}}"
                                                               Style="{StaticResource A_Style_FZTextBlock_InfoLabel}"
                                                               Margin="0,0,15,0" />
                                            <Viewbox Width="106"
                                                     Height="18"
                                                     HorizontalAlignment="Right">
                                                <local:DeltaProgressBar Style="{StaticResource A_Style_DeltaProgressBar_Popularity}"
                                                                        BaseValue="{Binding Popularity}"
                                                                        NewValue="{Binding Popularity}" />
                                            </Viewbox>
                                        </Grid>
                                    </StackPanel>
                                </Grid>
                            </DockPanel>
                        </ContentControl>
                    </DockPanel>

                    <local:NavigationArrows Style="{StaticResource A_Style_Control_NavigationArrows}"
                                            Margin="-40,0,-20,0"
                                            CanSelectPrev="{Binding CanSelectPrev, ElementName=PART_DesignList}"
                                            CanSelectNext="{Binding CanSelectNext, ElementName=PART_DesignList}"
                                            ScrollPagePrevCommand="{Binding ScrollPagePrevCommand, ElementName=PART_DesignList}"
                                            ScrollPageNextCommand="{Binding ScrollPageNextCommand, ElementName=PART_DesignList}" />
                </Grid>


            </StackPanel>
        </Border>
    </Grid>
</Page>
