<Page xmlns:local="clr-namespace:ForzaUI"
      xmlns:System="clr-namespace:System;assembly=mscorlib"
      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" 
      x:Class="ForzaUI.Scenes.Anthem.A_ClubLevelLeaderboard"
      mc:Ignorable="d"
      Style="{StaticResource A_Style_Page_Generic}"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

    <local:UIPageTransitionManager.TransitionManager>
        <local:UIPageTransitionManager Preset="{StaticResource A_UIPageTransitionManagerPreset_Menu}"/>
    </local:UIPageTransitionManager.TransitionManager>
    
    <Page.Resources>
        <ResourceDictionary>
            <GridLength x:Key="A_GridLength_ClubLeaderboard_Position">52</GridLength>
            <GridLength x:Key="A_GridLength_ClubLeaderboard_Club">500</GridLength>
            <GridLength x:Key="A_GridLength_ClubLeaderboard_Members">250</GridLength>
            <GridLength x:Key="A_GridLength_ClubLeaderboard_XP">250</GridLength>
            <GridLength x:Key="A_GridLength_Column_PositionSpacer_Width">18</GridLength>

            <!-- Row Templates -->                                
            <ControlTemplate x:Key="A_ControlTemplate_HeaderRow" TargetType="Control">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_FlatPanel_HeaderPill}" >
                    <Grid Margin="18,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_Position}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_PositionSpacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_Club}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_Members}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                            <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_XP}"/>
                        </Grid.ColumnDefinitions>
                        <local:FZTextBlock Grid.Column="0" Text="{local:Loc Clan.IDS_Pos}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="2" Text="{local:Loc Clan.IDS_Club}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="4" Text="{local:Loc Clan.IDS_Members}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                        <local:FZTextBlock Grid.Column="6" Text="{local:Loc Clan.IDS_Club_XP}" Style="{StaticResource A_Style_FZTextBlock_DriverListHeading}" />
                    </Grid>
                </local:FZMaterial>
            </ControlTemplate>

            <ControlTemplate x:Key="A_ControlTemplate_ClubLevelLeaderboardRow" TargetType="ListBoxItem">
                <Grid Margin="{StaticResource A_Thickness_LeaderboardRowMargin}">
                    <StackPanel Name="Content" Orientation="Horizontal" Visibility="{Binding IsLoading, Converter={StaticResource A_FZBooleanToVisibilityConverter_Inverse}}">
                        <ContentControl Style="{StaticResource A_Style_ContentControl_SelectableRow}">
                            <Grid Margin="18,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_Position}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_PositionSpacer_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_Club}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_Members}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_Column_Spacer_Width}"/>
                                    <ColumnDefinition Width="{StaticResource A_GridLength_ClubLeaderboard_XP}"/>
                                </Grid.ColumnDefinitions>
                                <ContentControl Grid.Column="0" Template="{StaticResource A_ControlTemplate_Cell_Position}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="-18,0,0,0"/>
                                <StackPanel Orientation="Horizontal" Grid.Column="2" VerticalAlignment="Center">
                                    <Decorator Visibility="{Binding ClubTag, Converter={StaticResource A_StringVisConverter}}" Margin="0,0,5,0">
                                        <local:FZTextBlock x:Name="ClubTag" Text="{Binding ClubTag, Converter={StaticResource A_Converter_StringFormatConverter}, ConverterParameter={local:Loc Main.IDS_ClanTagOnly}}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}"/>
                                    </Decorator>

                                    <local:FZTextBlock x:Name="ClubDescription" Text="{Binding ClubDescription}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}"/>
                                </StackPanel>

                                <local:FZTextBlock x:Name="ClubMemberCount" Grid.Column="4" Text="{Binding ClubMemberCount}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}" VerticalAlignment="Center" />
                                <local:FZTextBlock x:Name="ClubXP" Grid.Column="6" Text="{Binding ClubXP}" Style="{StaticResource A_Style_FZTextBlock_LeaderboardRow}" VerticalAlignment="Center"/>
                            </Grid>
                        </ContentControl>
                    </StackPanel>
                </Grid>
            </ControlTemplate>

            <Style x:Key="A_Style_ListBoxItem_ClubLevelLeaderboardEntry" TargetType="ListBoxItem" BasedOn="{StaticResource A_Style_ListBoxItem_LeaderboardBase}">
                <Setter Property="Template" Value="{StaticResource A_ControlTemplate_ClubLevelLeaderboardRow}" />
            </Style>

            <!-- Footer Stuff -->
            <ControlTemplate x:Key="A_ControlTemplate_FooterRow" TargetType="Control">
                <local:FZMaterial Style="{StaticResource A_Style_FZMaterial_AcrylicPanel_Tile_Background}">
                    <Grid>
                        <Control Style="{StaticResource A_Style_Cell}" Template="{StaticResource A_ControlTemplate_FooterRow_Filter}" Width="Auto" />
                    </Grid>
                </local:FZMaterial>
            </ControlTemplate>

        </ResourceDictionary>
    </Page.Resources>


    <Border>
        <Grid x:Name="LayoutRoot">
            <!-- Background Blur -->
           <Control Style="{StaticResource A_Style_Control_ScreenBackground}" />
            
            <ContentControl x:Name="BottomBar" Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="DefaultHelpPanel"
                    local:ControllerButtonPanel.ADescription="{local:Loc HelpButtons.IDS_ClubOptions}"
                    local:ControllerButtonPanel.BDescription="{local:Loc HelpButtons.IDS_Back}"
                    local:ControllerButtonPanel.XDescription="{local:Loc HelpButtons.IDS_Filter}"
                    Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
            </ContentControl>

            <Border Style="{StaticResource A_Style_Border_ScenePadding}">
                <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,92">
                    <StackPanel Orientation="Horizontal" Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                        <ContentControl Content="{local:Loc Clan.IDS_Club_Leaderboards}" 
                                        Style="{StaticResource A_Style_ContentControl_ScreenTitleBlock}"
                                        local:BindingProxy.A="/ForzaUI;component/Textures/Anthem/Icons/Titles/Leaderboards.png" />
                    </StackPanel>

                    <StackPanel Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}"
                                    Orientation="Horizontal"
                                    HorizontalAlignment="Center">
                        <StackPanel>
                            <Control Style="{StaticResource A_Style_HeaderRow}" Template="{StaticResource A_ControlTemplate_HeaderRow}" />
                            <local:CommonListBox x:Name="PART_ListBox_LeaderboardList" ItemsSource="{Binding LeadersList}" MaxHeight="561" 
                                                        ItemContainerStyle="{StaticResource A_Style_ListBoxItem_ClubLevelLeaderboardEntry}"
                                                        Style="{StaticResource A_Style_CommonListBox_Leaderboard}"
                                                        VerticalAlignment="Top"
                                                        VirtualizingStackPanel.VirtualizationMode="Recycling"
                                                        ScrollViewer.CanContentScroll="True"
                                                        Panel.ZIndex="2"/>
                            <Control Style="{StaticResource A_Style_FooterRow}" Template="{StaticResource A_ControlTemplate_FooterRow_Default}" />
                        </StackPanel>
                    </StackPanel>
                </StackPanel>
            </Border>
        </Grid>
    </Border>
</Page>
