<Page
    x:Class="was.touchcopy.features.voicemail.VoiceMailContentPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.touchcopy.features.voicemail"
    xmlns:converters="using:was.touchcopy.features.voicemail.converters"
    xmlns:coreconverters="using:was.touchcopy.features.converters"
    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:VoiceMailContentPage}"
    Visibility="{x:Bind Group, Converter={StaticResource ValueToVisibilityConverter}, Mode=OneWay}">
    <Page.Resources>
        <ResourceDictionary>
            <converters:VoiceMailGroupToFilteredEntriesConverter x:Key="VoiceMailGroupToFilteredEntriesConverter" />
            <converters:VoiceMailFilterOptionsToDescriptionStringConverter x:Key="VoiceMailFilterOptionsToDescriptionStringConverter" />
            <coreconverters:DurationToStringConverter x:Key="DurationToStringConverter" />
            <coreconverters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Border Style="{ThemeResource FeatureContentPageBorder}" Padding="0">
        <Grid>
            <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <InfoBar x:Uid="InfoBarFilter" IsOpen="True" Title="XX Date Filter Applied" Message="{x:Bind DateFilterOptions, Converter={StaticResource VoiceMailFilterOptionsToDescriptionStringConverter}, Mode=OneWay}" 
                 Severity="Informational" HorizontalAlignment="Stretch" IsClosable="False" Visibility="{x:Bind DateFilterOptions, Converter={StaticResource ValueToVisibilityConverter}, Mode=OneWay}">
            <InfoBar.IconSource>
                <SymbolIconSource Symbol="Calendar"/>
            </InfoBar.IconSource>
            <InfoBar.ActionButton>
                <Button x:Name="buttonClearFilter" x:Uid="ClearFilterButton" Content="XX Clear Filter" Click="ButtonClearFilter_Click" />
            </InfoBar.ActionButton>
        </InfoBar>
        <Border Grid.Row="1" BorderThickness="0,0,0,1" BorderBrush="{ThemeResource AppBarBorderThemeBrush}" Padding="16,4,12,6">
            <Grid ColumnSpacing="4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="2*" />
                    <ColumnDefinition Width="1*" />
                </Grid.ColumnDefinitions>
                <Border Grid.Column="0" BorderThickness="0,0,1,0" BorderBrush="{ThemeResource AppBarBorderThemeBrush}">
                    <TextBlock x:Uid="NameLabelTextBlock" Tag="0" Text="XX Name" Tapped="ItemColumnHeader_Tapped" />
                </Border>
                <Border Grid.Column="1" BorderThickness="0,0,1,0" BorderBrush="{ThemeResource AppBarBorderThemeBrush}">
                    <TextBlock x:Uid="AddressLabelTextBlock" Tag="1" Text="XX Address" Tapped="ItemColumnHeader_Tapped" />
                </Border>
                <Border Grid.Column="2" BorderThickness="0,0,1,0" BorderBrush="{ThemeResource AppBarBorderThemeBrush}">
                    <TextBlock x:Uid="DateLabelTextBlock" Tag="2" Text="XX Date" Tapped="ItemColumnHeader_Tapped" />
                </Border>
                <TextBlock x:Uid="DurationLabelTextBlock" Grid.Column="3" Tag="3" Text="XX Duration" Tapped="ItemColumnHeader_Tapped" />
            </Grid>
        </Border>
        <ListView Grid.Row="2" x:Name="listViewItems" ItemsSource="{x:Bind Group, Converter={StaticResource VoiceMailGroupToFilteredEntriesConverter}, Mode=OneWay}"
                  SelectionMode="Extended" RightTapped="ListViewItems_RightTapped">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid ColumnSpacing="4">
                        <Grid.ContextFlyout>
                            <MenuFlyout>
                                <MenuFlyoutItem x:Uid="MenuFlyoutSaveItemToPC" Text="XX Save to PC" Icon="SaveLocal" Click="MenuFlyoutSaveItemToPC_Click" />
                                <MenuFlyoutSeparator />
                                <MenuFlyoutItem x:Uid="MenuFlyoutSortFilesByName" Tag="0" Text="XX Sort by Name" Click="MenuFlyoutApplySort_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE84B;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutItem x:Uid="MenuFlyoutSortFilesByAddress" Tag="1" Text="XX Sort by Address" Click="MenuFlyoutApplySort_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE717;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutItem x:Uid="MenuFlyoutSortFilesByDate" Tag="2" Text="XX Sort by Date" Click="MenuFlyoutApplySort_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE787;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutItem x:Uid="MenuFlyoutSortFilesByDuration" Tag="3" Text="XX Sort by Duration" Click="MenuFlyoutApplySort_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE823;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                            </MenuFlyout>
                        </Grid.ContextFlyout>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="2*" />
                            <ColumnDefinition Width="2*" />
                            <ColumnDefinition Width="2*" />
                            <ColumnDefinition Width="1*" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{Binding Title}" />
                        <TextBlock Grid.Column="1" Text="{Binding SenderAddress, TargetNullValue=-}" />
                        <TextBlock Grid.Column="2" Text="{Binding ReceivedDate}" />
                        <TextBlock Grid.Column="3" Text="{Binding Duration, Converter={StaticResource DurationToStringConverter}}" />
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
    </Border>
</Page>
