<featurebase:FeaturePage
    x:Class="was.touchcopy.features.photos.PhotosPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:featurebase="using:was.touchcopy.features"
    xmlns:local="using:was.touchcopy.features.photos"
    xmlns:converters="using:was.touchcopy.features.photos.converters"
    xmlns:data="using:was.touchcopy.features.photos.data"
    xmlns:utilities="using:was.touchcopy.features.utilities"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DataContext="{d:DesignInstance Type=local:PhotosPage}"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <ResourceDictionary>
            <CollectionViewSource x:Key="PhotoAlbumsCVS" IsSourceGrouped="True" />
            <converters:PhotosAlbumTypeToStringConverter x:Key="PhotosAlbumTypeToStringConverter" />
            <converters:PhotosAlbumToFontIconGlyphConverter x:Key="PhotosAlbumToFontIconGlyphConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <Grid x:Name="gridMain">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Border Style="{ThemeResource PageHeaderBorderStyle}">
                <Grid>
                    <CommandBar Style="{ThemeResource PageHeaderCommandBarStyle}">
                        <featurebase:CopyProgressAppBarUserController x:Name="copyProgressUserControl" Visibility="Collapsed" OnCancelTapped="_copyProgressUserControl_OnCancelTapped" MaxWidth="350" />
                        <AppBarButton x:Name="appBarButtonSave" x:Uid="AppBarButtonSave" Label="XX Save to PC" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonSave_Click" IsEnabled="{x:Bind IsSaveAvailable, Mode=OneWay}">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xE78C;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonSave.IsEnabled), Mode=OneWay}"/>
                            </AppBarButton.Content>
                        </AppBarButton>
                        <AppBarButton x:Name="appBarButtonExport" x:Uid="AppBarButtonExport" Label="XX Export New Photos" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonExport_Click">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xEB9F;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonExport.IsEnabled), Mode=OneWay}"/>
                            </AppBarButton.Content>
                        </AppBarButton>
                        <AppBarSeparator />
                        <AppBarButton x:Name="appBarButtonView" x:Uid="AppBarButtonView" Label="XX Preview" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonView_Click" IsEnabled="{x:Bind photosContentPage.IsPreviewAvailable, Mode=OneWay}">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xE890;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonView.IsEnabled), Mode=OneWay}"/>
                            </AppBarButton.Content>
                        </AppBarButton>
                    </CommandBar>
                    <TextBlock Text="{Binding PageTitle}" Style="{ThemeResource PageHeaderTitleStyle}"/>
                </Grid>
            </Border>
            <SplitView Grid.Row="1" Style="{ThemeResource FeatureSplitViewStyle}">
                <SplitView.Pane>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBox x:Name="textBoxPhotosFilter" x:Uid="PhotosFilterTextBox" Margin="10,5" PlaceholderText="XX Search Photo Albums" 
                             TextChanged="_textBoxPhotosFilter_TextChanged" />
                        <ListView x:Name="listViewPhotoAlbums" Grid.Row="1" SelectionMode="Extended" ItemsSource="{x:Bind PhotoAlbums.View, Mode=OneWay}" SelectionChanged="_listViewPhotoAlbums_SelectionChanged">
                            <ListView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <ItemsStackPanel AreStickyGroupHeadersEnabled="False"/>
                                </ItemsPanelTemplate>
                            </ListView.ItemsPanel>
                            <ListView.GroupStyle>
                                <GroupStyle>
                                    <GroupStyle.HeaderTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Key, Converter={StaticResource PhotosAlbumTypeToStringConverter}}"/>
                                        </DataTemplate>
                                    </GroupStyle.HeaderTemplate>
                                </GroupStyle>
                            </ListView.GroupStyle>
                            <ListView.ItemTemplate>
                                <DataTemplate x:DataType="data:PhotosAlbum">
                                    <Grid ColumnSpacing="8">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <FontIcon Glyph="{Binding Converter={StaticResource PhotosAlbumToFontIconGlyphConverter}, Mode=OneWay}" />
                                        <TextBlock Grid.Column="1" Text="{x:Bind Title}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="0,0,0,2" />
                                    </Grid>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                            <ListView.ContextFlyout>
                                <MenuFlyout>
                                    <MenuFlyoutItem x:Name="menuFlyoutItemSaveAlbum" x:Uid="MenuFlyoutItemSaveAlbum" Text="XX Save to PC" Click="_menuFlyoutItemSaveAlbum_Click">
                                        <MenuFlyoutItem.Icon>
                                            <FontIcon Glyph="&#xE78C;" Foreground="{ThemeResource AppBarItemForegroundThemeBrush}"/>
                                        </MenuFlyoutItem.Icon>
                                    </MenuFlyoutItem>
                                </MenuFlyout>
                            </ListView.ContextFlyout>
                        </ListView>

    
                    </Grid>
                </SplitView.Pane>
                <Grid Margin="10,0,0,0" x:Name="gridContent">
                    <local:PhotosContentPage x:Name="photosContentPage"
                                         CopyRequested="_photosContentPage_CopyRequested"/>
                    
                    <!-- iCloud Tracks Hidden Notifcation -->
                    <InfoBar x:Name="InfoBarRemotePhotosHidden" x:Uid="InfoBarRemotePhotosHidden" Grid.Row="1" Title="XX iCloud only photos are set to be hidden." 
                             IsOpen="False" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="5,0,5,20" Severity="Warning">
                        <InfoBar.IconSource>
                            <FontIconSource Glyph="&#xEC9C;" />
                        </InfoBar.IconSource>
                        <InfoBar.ActionButton>
                            <Button x:Name="ButtonRemotePhotosHiddenShowAll" x:Uid="ButtonRemotePhotosHiddenShowAll" Content="XX Show All" Style="{ThemeResource AccentButtonStyle}"  Click="ButtonRemotePhotosHiddenShowAll_Click"/>
                        </InfoBar.ActionButton>
                    </InfoBar>

                </Grid>
            </SplitView>
            <ContentDialog x:Name="dialogICloudWarning" x:Uid="DialogICloudWarning" CloseButtonText="XX OK" DefaultButton="Close">
                <ContentDialog.Title>
                    <StackPanel Orientation="Horizontal">
                        <FontIcon Glyph="&#xE753;" Margin="0,2,8,0" />
                        <TextBlock x:Uid="DialogICloudWarningTitle" Text="XX Unable to Copy iCloud Media" />
                    </StackPanel>
                </ContentDialog.Title>
                <StackPanel>
                    <TextBlock x:Uid="DialogICloudWarningDescription" Text="XX The chosen media is stored in iCloud and has not yet been downloaded to your connected device. It must be downloaded to your device before it can be copied." TextWrapping="Wrap" />
                </StackPanel>
            </ContentDialog>
        </Grid>
        <Grid x:Name="gridExport" Visibility="Collapsed">
            <local:PhotosExportPage x:Name="photosExportPage" Visibility="{Binding Visibility, ElementName=gridExport}"
                                    FoundNewItemsForExport="_photosExportPage_FoundNewItemsForExport" HideExportPageRequested="_photosExportPage_HideExportPageRequested" />
        </Grid>
        <ContentDialog x:Name="dialogPickExportDirectory" x:Uid="DialogPickExportDirectory" Title="XX Export New Photos" PrimaryButtonText="XX Browse" IsPrimaryButtonEnabled="True" CloseButtonText="XX Cancel" DefaultButton="Primary">
            <StackPanel>
                <TextBlock x:Uid="DialogPickExportDirectoryLineOne" Text="XX TouchCopy can automatically detect new photos on your connected device that are not in your chosen export folder on your PC." TextWrapping="Wrap" />
                <TextBlock x:Uid="DialogPickExportDirectoryLineTwo" Text="XX Click 'Browse' to select the export folder you wish to use. This only needs to be done once and can be changed within Settings > Photos." TextWrapping="Wrap" Style="{ThemeResource CaptionTextBlockStyle}" Margin="0,10,0,0" />
            </StackPanel>
        </ContentDialog>
        <ContentDialog x:Name="dialogNewPhotosDetected" x:Uid="DialogNewPhotosDetected" Title="XX New Photos Detected" PrimaryButtonText="XX View New Photos" IsPrimaryButtonEnabled="True" CloseButtonText="XX Close" DefaultButton="Primary">
            <StackPanel>
                <TextBlock x:Uid="DialogNewPhotosDetectedLineOne" Text="XX TouchCopy detected new photos on your device that are not in your selected export folder." TextWrapping="Wrap" />
                <CheckBox x:Uid="DialogNewPhotosDetectedCheckBox" Content="XX Automatically detect new photos when loading photos." IsChecked="True" Margin="0,15,0,0" />
            </StackPanel>
        </ContentDialog>
    </Grid>
</featurebase:FeaturePage>
