<Page
    x:Class="was.touchcopy.features.calllogs.CallLogsContentPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.touchcopy.features.calllogs"
    xmlns:converters="using:was.touchcopy.features.calllogs.converters"
    xmlns:fconverters="using:was.touchcopy.features.converters"
    xmlns:data="using:was.touchcopy.features.calllogs.data"
    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:CallLogsContentPage}"
    Visibility="{x:Bind CallLog, Converter={StaticResource ValueToVisibilityConverter}, Mode=OneWay}">
    <Page.Resources>
        <ResourceDictionary>
            <converters:CallLogEntryToFontIconColorConverter x:Key="CallLogEntryToFontIconColorConverter" />
            <converters:CallLogEntryToFontIconGlyphConverter x:Key="CallLogEntryToFontIconGlyphConverter" />
            <converters:CallLogEntryToDurationStringConverter x:Key="CallLogEntryToDurationStringConverter" />
            <converters:CallLogEntryToDetailStringConverter x:Key="CallLogEntryToDetailStringConverter" />
            <converters:CallLogEntryToDurationFontWeightConverter x:Key="CallLogEntryToDurationFontWeightConverter" />
            <converters:CallLogFilterOptionsToDescriptionStringConverter x:Key="CallLogFilterOptionsToDescriptionStringConverter" />
            <converters:EnumerableCountToVisibilityConverter x:Key="EnumerableCountToVisibilityConverter" />
            <fconverters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Border Style="{ThemeResource FeatureContentPageBorder}"  Background="{ThemeResource CardBackgroundFillColorDefaultBrush}">
        <ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Padding="0,20">
            <Grid>
                <StackPanel Orientation="Vertical">
                    <InfoBar x:Uid="InfoBarFilter" IsOpen="True" Title="Date Filter Applied" Message="{x:Bind DateFilterOptions, Converter={StaticResource CallLogFilterOptionsToDescriptionStringConverter}, Mode=OneWay}" 
                 Severity="Informational" HorizontalAlignment="Stretch" IsClosable="False" Margin="0,0,0,20" 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="Clear Filter" Click="_buttonClearFilter_Click" />
                        </InfoBar.ActionButton>
                    </InfoBar>
                    <TextBlock Text="{x:Bind CallLog.ParticipantGroup.Name, Mode=OneWay}" Style="{ThemeResource TitleTextBlockStyle}" />
                    <TextBlock Text="{x:Bind CallLog.ParticipantGroup.Provider.CallLogProviderTypeString, Mode=OneWay}" Style="{ThemeResource BaseTextBlockStyle}" />
                    <ItemsRepeater ItemsSource="{x:Bind CallLogEntries, Mode=OneWay}" Margin="0,30,0,0" Visibility="{x:Bind CallLogEntries, Converter={StaticResource EnumerableCountToVisibilityConverter}, Mode=OneWay}">
                        <ItemsRepeater.Layout>
                            <StackLayout Orientation="Vertical" />
                        </ItemsRepeater.Layout>
                        <ItemsRepeater.ItemTemplate>
                            <DataTemplate>
                                <Border d:DataContext="{d:DesignInstance Type=data:CallLogEntry}" BorderThickness="0,0,0,1" BorderBrush="{ThemeResource ButtonBorderThemeBrush}" Margin="0,0,0,10" Padding="0,0,0,10">
                                    <Grid ColumnSpacing="10">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="auto" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="auto" />
                                            <RowDefinition Height="auto" />
                                        </Grid.RowDefinitions>
                                        <FontIcon Grid.RowSpan="1" Glyph="{Binding Converter={StaticResource CallLogEntryToFontIconGlyphConverter}}" Foreground="{Binding Converter={StaticResource CallLogEntryToFontIconColorConverter}}" />
                                        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Converter={StaticResource CallLogEntryToDetailStringConverter}}" TextWrapping="Wrap" />
                                        <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Converter={StaticResource CallLogEntryToDurationStringConverter}}" FontWeight="{Binding Converter={StaticResource CallLogEntryToDurationFontWeightConverter}}" />
                                    </Grid>
                                </Border>
                            </DataTemplate>
                        </ItemsRepeater.ItemTemplate>
                    </ItemsRepeater>
                    <StackPanel Orientation="Horizontal" Margin="0,30,0,0"
                            Visibility="{x:Bind CallLogEntries, Converter={StaticResource EnumerableCountToVisibilityConverter}, ConverterParameter=invert, Mode=OneWay}">
                        <FontIcon Glyph="&#xE783;" Margin="0,0,10,0" />
                        <TextBlock x:Uid="NoEntriesFoundTextBlock" Text="XX No entries found between the set dates." VerticalAlignment="Center" Style="{ThemeResource CaptionTextBlockStyle}" />
                    </StackPanel>
                </StackPanel>
            </Grid>
        </ScrollViewer>
    </Border>
</Page>
