<Page 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:local="clr-namespace:ForzaUI"
      mc:Ignorable="d"
      x:Class="ForzaUI.Scenes.Anthem.A_OnlineAdventureFlyerView"
      Style="{StaticResource A_Style_Page_Generic}"
      FlowDirection="LeftToRight"
      DataContext="{Binding RelativeSource={RelativeSource Self}}">

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

    <Page.Resources>
        <ResourceDictionary>
            <Style x:Key="A_Style_NetworkCountdownControl_CarSelectCustom"
                   TargetType="{x:Type local:NetworkCountdownControl}"
                   BasedOn="{StaticResource A_Style_NetworkCountdownControl_Base}">
                <Setter Property="TimerDisplayName" Value="{local:Loc Lobby.IDS_SelectYourCar_Countdown}" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding IsCarSelected}" Value="True">
                        <Setter Property="TimerDisplayName" Value="{local:Loc Lobby.IDS_AdventureStart_Countdown}" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>

            <Style x:Key="A_Style_CompositeVisiblityWrapper" TargetType="{x:Type Decorator}">
                <Setter Property="Visibility" Value="Collapsed" />
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ShowCountdown}" Value="True">
                        <Setter Property="Visibility" Value="Visible" />
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>

        <local:MappingConverter x:Key="A_Converter_InverseVisibility" Default="Hidden">
            <local:MappingConverterEntry Key="{x:Static Visibility.Collapsed}" Value="{x:Static Visibility.Visible}"/>
            <local:MappingConverterEntry Key="{x:Static Visibility.Visible}" Value="{x:Static Visibility.Collapsed}"/>
        </local:MappingConverter>
        
    </Page.Resources>

    <Grid x:Name="LayoutRoot" Visibility="{Binding FlyerLoaded, Converter={StaticResource A_FZBooleanToVisibilityConverter}}">
        <ContentControl x:Name="BottomBar"
                        Style="{StaticResource A_Style_ButtonBar}">
            <ContentControl x:Name="DefaultHelpPanel"
                            Style="{StaticResource A_Style_ContentControl_DefaultButtonBar}" />
        </ContentControl>

        <Decorator x:Name="PART_TimerVisibility" Style="{StaticResource A_Style_CompositeVisiblityWrapper}">
            <local:NetworkCountdownControl Style="{StaticResource A_Style_NetworkCountdownControl_CarSelectCustom}" />
        </Decorator>

        <Border Style="{StaticResource A_Style_Border_ScenePadding}">
            <Grid Style="{StaticResource A_Style_FrameworkElement_DefaultTransition_0}">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" DataContext="{Binding CampaignSetup}">
                    <ContentControl Width="574" Height="846" Style="{StaticResource A_Style_ContentControl_CampaignFlyerFront}"/>
                    <Decorator Width="75"/>
                    <Control Width="574" Height="846" Style="{StaticResource A_Style_Control_CampaignFlyerBack}"/>
                </StackPanel>
            </Grid>
        </Border>

        <Decorator Style="{StaticResource A_Style_FrameworkElement_LayoutRoot}" Margin="0,70,0,0"
              Visibility="{Binding Path=Visibility, ElementName=PART_TimerVisibility, Converter={StaticResource A_Converter_InverseVisibility}}">
            <ContentControl Style="{StaticResource A_Style_ContentControl_LoadingSpinnerWithMessage}"
                            Visibility="{Binding AdventureStatusMessage, Converter={StaticResource A_StringVisConverter}, FallbackValue=Collapsed}"
                            Content="{Binding AdventureStatusMessage}"/>
        </Decorator>
    </Grid>
</Page>