<featurebase:FeaturePage
    x:Class="was.touchcopy.features.calllogs.CallLogsPage"
    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.calllogs"
    xmlns:converters="using:was.touchcopy.features.calllogs.converters"
    xmlns:commoncontrols="using:was.touchcopy.features.controls"
    xmlns:commondialogs="using:was.touchcopy.features.dialogs"
    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:CallLogsPage}">
    <Page.Resources>
        <ResourceDictionary>
            <CollectionViewSource x:Key="CallLogsCVS" IsSourceGrouped="True" />
            <converters:ParticipantGroupToFontIconGlyphConverter x:Key="ParticipantGroupToFontIconGlyphConverter" />
            <converters:EnumerableCountToVisibilityConverter x:Key="EnumerableCountToVisibilityConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <Grid x:Name="gridMain" Visibility="Collapsed">
            <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="appBarButtonSavePDF" x:Uid="AppBarButtonSavePDF" Label="XX Save as PDF" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonSavePDF_Click" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xEA90;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonSavePDF.IsEnabled), Mode=OneWay}"/>
                            </AppBarButton.Content>
                        </AppBarButton>
                        <AppBarButton x:Name="appBarButtonSaveHTML" x:Uid="AppBarButtonSaveHTML" Label="XX Save as HTML" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonSaveHTML_Click" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xE78C;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonSaveHTML.IsEnabled), Mode=OneWay}"/>
                            </AppBarButton.Content>
                        </AppBarButton>
                        <AppBarButton x:Name="appBarButtonSaveCSV" x:Uid="AppBarButtonSaveCSV" Label="XX Save as CSV" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonSaveCSV_Click" IsEnabled="{x:Bind IsExportAvailable, Mode=OneWay}">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xE9F9;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonSaveCSV.IsEnabled), Mode=OneWay}"/>
                            </AppBarButton.Content>
                        </AppBarButton>
                        <AppBarButton x:Name="appBarButtonPrint" x:Uid="AppBarButtonPrint" Label="XX Print" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonPrint_Click" IsEnabled="{x:Bind IsPrintAvailable, Mode=OneWay}">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xE749;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonPrint.IsEnabled), Mode=OneWay}"/>
                            </AppBarButton.Content>
                        </AppBarButton>
                        <AppBarSeparator/>
                        <AppBarButton x:Name="appBarButtonFilterDates" x:Uid="AppBarButtonFilterDates" Label="Filter Dates" Style="{ThemeResource AppBarButtonStyle}" Click="_appBarButtonFilterDates_Click">
                            <AppBarButton.Content>
                                <FontIcon Glyph="&#xE787;" Foreground="{x:Bind utilities:AppBarUtilities.BrushForAppBarIcon(appBarButtonFilterDates.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 Margin="0,10,0,0">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBox x:Name="textBoxCallLogsFilter" x:Uid="CallLogsFilterTextBox" Margin="10,5" PlaceholderText="XX Search Call Logs" 
                             TextChanged="_textBoxCallLogsFilter_TextChanged" />
                        <ListView x:Name="listViewGroups" Grid.Row="1" SelectionMode="Extended" ItemsSource="{x:Bind CallLogsGroups.View, Mode=OneWay}"
                                  SelectionChanged="_listViewGroups_SelectionChanged">
                            <ListView.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <ItemsStackPanel AreStickyGroupHeadersEnabled="False"/>
                                </ItemsPanelTemplate>
                            </ListView.ItemsPanel>
                            <ListView.GroupStyle>
                                <GroupStyle HidesIfEmpty="True">
                                    <GroupStyle.HeaderTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Key}"/>
                                        </DataTemplate>
                                    </GroupStyle.HeaderTemplate>
                                </GroupStyle>
                            </ListView.GroupStyle>
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <Grid ColumnSpacing="8">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <FontIcon Glyph="{Binding Converter={StaticResource ParticipantGroupToFontIconGlyphConverter}}" />
                                        <TextBlock Grid.Column="1" Text="{Binding Name}" TextTrimming="CharacterEllipsis" />
                                    </Grid>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                            <ListView.ContextFlyout>
                                <MenuFlyout>
                                    <MenuFlyoutItem x:Name="menuFlyoutItemSortByName" x:Uid="FlyoutItemSortByName" Text="XX Sort by Name" Click="_menuFlyoutItemSortByName_Click">
                                        <MenuFlyoutItem.Icon>
                                            <FontIcon Glyph="&#xE779;" />
                                        </MenuFlyoutItem.Icon>
                                    </MenuFlyoutItem>
                                    <MenuFlyoutItem x:Name="menuFlyoutItemSortByLastUpdated" x:Uid="FlyoutItemSortByLastUpdated" Text="XX Sort by Last Updated" Click="_menuFlyoutItemSortByLastUpdated_Click">
                                        <MenuFlyoutItem.Icon>
                                            <FontIcon Glyph="&#xE787;" />
                                        </MenuFlyoutItem.Icon>
                                    </MenuFlyoutItem>
                                </MenuFlyout>
                            </ListView.ContextFlyout>
                        </ListView>
                    </Grid>
                </SplitView.Pane>
                <Grid Margin="10,0,0,0" x:Name="gridContent" >
                    <local:CallLogsContentPage x:Name="callLogsContentPage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                               DateFilterOptions="{x:Bind DateFilterOptions, Mode=OneWay}"
                                               ClearFilterRequested="_callLogsContentPage_ClearFilterRequested" />
                </Grid>
            </SplitView>
            <commondialogs:DateFilterContentDialog x:Name="dialogDateFilter" />
        </Grid>
        <Grid x:Name="gridEncryptionRequired" Visibility="Collapsed" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="20">
            <StackPanel Orientation="Vertical">
                <TextBlock x:Uid="TextBlockBackupEncryptionRequired" Text="XX Backup Encryption Required" Style="{ThemeResource PageHeaderTitleStyle}" HorizontalAlignment="Center" Margin="0" />
                <TextBlock x:Uid="TextBlockBackupEncryptionRequiredDescription" Text="XX Call Log data can only be accessed for devices running iOS 13 or later if backup encryption is enabled." TextWrapping="Wrap" HorizontalAlignment="Center" Margin="0,10,0,0" />
                <Button x:Name="buttonEncryptionRequired" x:Uid="ButtonFindOutMore" Content="XX Find out more" HorizontalAlignment="Center" Margin="0,50,0,0" Click="_buttonEncryptionRequired_Click" />
            </StackPanel>
        </Grid>
        <!-- WebView for use when printing -->
        <commoncontrols:WebViewPrintUserControl x:Name="webViewPrintUserControl" Grid.RowSpan="2" Visibility="Collapsed" />
    </Grid>
</featurebase:FeaturePage>
