<featurebase:FeaturePage
    x:Class="was.touchcopy.features.voicememos.VoiceMemosPage"
    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.voicememos"
    xmlns:converters="using:was.touchcopy.features.voicememos.converters"
    xmlns:dialogs="using:was.touchcopy.features.dialogs"
    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:VoiceMemosPage}"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <ResourceDictionary>
            <converters:VoiceMemosFolderToFontIconGlyphConverter x:Key="VoiceMemosFolderToFontIconGlyphConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <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="appBarButtonSaveToPC" x:Uid="AppBarButtonSaveToPC" Icon="SaveLocal" Label="XX Save to PC" Style="{ThemeResource AppBarButtonStyle}" Click="SaveToPCAppBarButton_Click" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}" />
                    <AppBarSeparator/>
                    <AppBarButton x:Name="appBarButtonFilterDates" x:Uid="AppBarButtonFilterDates" Label="XX Filter Dates" Style="{ThemeResource AppBarButtonStyle}" Click="AppBarButtonFilterDates_Click">
                        <AppBarButton.Content>
                            <FontIcon Glyph="&#xE787;" Foreground="{ThemeResource AccentFillColorDefaultBrush}"/>
                        </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="textBoxVoiceMemosFilter" x:Uid="VoiceMemosFilterTextBox" Margin="10,5" PlaceholderText="XX Search Voice Memos" 
                             TextChanged="TextBoxVoiceMemosFilter_TextChanged" />
                    <ListView x:Name="listViewFolders" Grid.Row="1" SelectionMode="Single" ItemsSource="{x:Bind Folders, Mode=OneWay}" SelectionChanged="ListViewFolders_SelectionChanged"
                              RightTapped="ListViewFolders_RightTapped">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <Grid ColumnSpacing="8">
                                    <Grid.ContextFlyout>
                                        <MenuFlyout>
                                            <MenuFlyoutItem x:Uid="MenuFlyoutSaveFolderToPC" Text="XX Save to PC" Icon="SaveLocal" Click="MenuFlyoutSaveFolderToPC_Click" />
                                            <MenuFlyoutSeparator />
                                            <MenuFlyoutItem x:Uid="MenuFlyoutSortFolderByName" Text="XX Sort by Name" Tag="0" Click="MenuFlyoutApplySort_Click">
                                                <MenuFlyoutItem.Icon>
                                                    <FontIcon Glyph="&#xE84B;" />
                                                </MenuFlyoutItem.Icon>
                                            </MenuFlyoutItem>
                                            <MenuFlyoutItem x:Uid="MenuFlyoutSortFolderByLastUpdated" Text="XX Sort by Last Updated" Tag="1" Click="MenuFlyoutApplySort_Click">
                                                <MenuFlyoutItem.Icon>
                                                    <FontIcon Glyph="&#xE787;" />
                                                </MenuFlyoutItem.Icon>
                                            </MenuFlyoutItem>
                                        </MenuFlyout>
                                    </Grid.ContextFlyout>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <FontIcon Glyph="{Binding Converter={StaticResource VoiceMemosFolderToFontIconGlyphConverter}}" />
                                    <TextBlock Grid.Column="1" Text="{Binding Name}" TextTrimming="CharacterEllipsis" />
                                </Grid>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </Grid>
            </SplitView.Pane>
            <Grid Margin="10,0,0,0" x:Name="gridContent">
                <local:VoiceMemosContentPage x:Name="contentPage" Folder="{Binding SelectedItem, ElementName=listViewFolders}"
                                             SearchFilter="{Binding Text, ElementName=textBoxVoiceMemosFilter, Mode=OneWay}"         
                                             DateFilterOptions="{x:Bind DateFilterOptions, Mode=OneWay}"
                                             SaveToPCRequested="VoiceMemosContentPage_SaveToPCRequested"
                                             ClearFilterRequested="VoiceMemosContentPage_ClearFilterRequested"
                                             StartPlayback="ContentPage_StartPlayback" StopPlayback="ContentPage_StopPlayback" />
            </Grid>
        </SplitView>
        <dialogs:DateFilterContentDialog x:Name="dialogDateFilter"  />
    </Grid>
</featurebase:FeaturePage>
