﻿<Page
    x:Class="PilotsHubApp.Shell"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PilotsHubApp"
    xmlns:converters="using:PilotsHubApp.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">    
    <Page.Resources>
        <ResourceDictionary>
            <converters:BooleanToVisibilityConverter x:Key="_booleanToVisbilityConverter" />
            <converters:NavPageSelectedConverter x:Key="navPageSelectedConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid Background="{ThemeResource PilotsHubAppBarBrush}">
        <SplitView Background="{ThemeResource PilotsHubSplitViewColorBrush}" Grid.Row="1" Grid.ColumnSpan="3"
            IsPaneOpen="{Binding PaneOpen, Mode=TwoWay}"
            PanePlacement="Left"
            DisplayMode="CompactOverlay">
            <SplitView.Pane>
                <StackPanel>
                    <RadioButton
                        Style="{StaticResource HamburgerRadioButtonStyle1}"
                                             Command="{Binding NavBarExpandCommand}"
                                             AutomationProperties.Name="{Binding NavAction.NavbarTitle}"
                                             Height="{ThemeResource AppBarThemeCompactHeight}" Background="Transparent">
                        <TextBlock VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,10,0" FontFamily="Segoe MDL2 Assets" Text="&#xE700;"/>
                    </RadioButton>
                    <ItemsControl TabIndex="2" x:Name="NavbarItems" ItemsSource="{Binding NavbarItems}">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <RadioButton Style="{StaticResource RadioButtonStyle1}"
                                             Command="{Binding ElementName=NavbarItems, Path=DataContext.NavigateToPageCommand}"
                                             CommandParameter="{Binding }"
                                             AutomationProperties.Name="{Binding NavAction.NavbarTitle}"
                                             Height="{ThemeResource AppBarThemeCompactHeight}"
                                             IsChecked="{Binding IsChecked, Mode=TwoWay}"
                                             Visibility="{Binding NavAction, Converter={StaticResource navPageSelectedConverter}}">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock VerticalAlignment="Center" Margin="0,0,10,0" FontFamily="Segoe MDL2 Assets" Text="{Binding NavAction.NavbarIcon}"/>
                                        <TextBlock VerticalAlignment="Center" Text="{Binding NavAction.NavbarTitle}" Visibility="{Binding ElementName=NavbarItems, Path=DataContext.PaneOpen, Converter={StaticResource _booleanToVisbilityConverter}, Mode=TwoWay}"/>
                                    </StackPanel>
                                </RadioButton>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </StackPanel>
            </SplitView.Pane>
            <SplitView.Content>
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    
                    <CommandBar Grid.Row="0" IsTabStop="True" Background="{ThemeResource PilotsHubAppBarBrush}">
                        <CommandBar.Content>
                            <StackPanel Orientation="Horizontal" Height="{ThemeResource AppBarThemeCompactHeight}" VerticalAlignment="Stretch">
                                <TextBlock Margin="24,0,0,0" VerticalAlignment="Center" FontWeight="Bold" FontSize="18" TextTrimming="CharacterEllipsis" Text="{Binding PageHeader}"/>
                            </StackPanel>
                        </CommandBar.Content>
                        <CommandBar.PrimaryCommands>
                            <AppBarButton  x:Uid="AppbarShare" Label="Share (PH)" Command="{Binding AppBarShareCommand}" Visibility="{Binding SelectedPageSupportsShareContract, Converter={StaticResource _booleanToVisbilityConverter}}">
                                <AppBarButton.Icon>
                                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE72D;"/>
                                </AppBarButton.Icon>
                            </AppBarButton>
                            <AppBarButton x:Uid="AppbarFeedback" Label="Feedback (PH)" Command="{Binding AppBarNavigationCommand}" CommandParameter="windows-feedback:?ContextID=240">
                                <AppBarButton.Icon>
                                    <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE939;"/>
                                </AppBarButton.Icon>
                            </AppBarButton>
                        </CommandBar.PrimaryCommands>
                        <CommandBar.SecondaryCommands>
                            <AppBarButton x:Uid="AppBarCopyLinkButton" Label="Copy link to clipboard (PH)" Command="{Binding AppBarCopyLinkCommand}" Visibility="{Binding SelectedPageSupportsUriNavigation, Converter={StaticResource _booleanToVisbilityConverter}}"/>
                            <AppBarSeparator Visibility="{Binding SelectedPageSupportsUriNavigation, Converter={StaticResource _booleanToVisbilityConverter}}"/>
                            <AppBarButton  Width="300" x:Uid="AppBarTermsOfUseLink" Label="Terms of Use (PH)" Command="{Binding AppBarNavigationCommand}" CommandParameter="http://go.microsoft.com/fwlink/?LinkID=523980"/>
                            <AppBarButton x:Uid="AppBarPrivacyLink" Label="Privacy Statement (PH)" Command="{Binding AppBarNavigationCommand}" CommandParameter="http://go.microsoft.com/fwlink/?LinkId=511803" />
                        </CommandBar.SecondaryCommands>
                    </CommandBar>
                    <ProgressBar Grid.Row="0" IsIndeterminate="True" HorizontalAlignment="Stretch" VerticalAlignment="Top" 
                                 Visibility="{Binding State, Converter={StaticResource loadingStateToVisibilityConverter}, ConverterParameter=Loading}"/>
                    <Frame Grid.Row="1" TabIndex="3" x:Name="frameBody" />    
                </Grid>
                
            </SplitView.Content>
        </SplitView>
    </Grid>
</Page>


