<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary
    x:Class="was.touchcopy.features.messaging.ux.MessageContentAudioV3DataTemplate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.touchcopy.features.messaging.ux"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:featurebase="using:was.touchcopy.features.controls"
    xmlns:converters="using:was.touchcopy.features.messaging.converters"
    xmlns:commonconverters="using:was.touchcopy.features.converters"
    mc:Ignorable="d"  >
    
    <converters:MessageContentToAudioVideoBackupFileConverter x:Key="MessageContentToAudioVideoBackupFileConverter"/>
    <converters:MessageContentSupportedToVisibilityConverter x:Key="MessageContentSupportedToVisibilityConverter" />
    <converters:MessageContentToAudioTranscriptionVisibilityConverter x:Key="MessageContentToAudioTranscriptionVisibilityConverter" />
    <converters:MessageContentToAudioTranscriptionConverter x:Key="MessageContentToAudioTranscriptionConverter" />
    <converters:MessageContentAvailabilityToVisibilityConverter x:Key="MessageContentAvailabilityToVisibilityConverter" />
    <commonconverters:VisibilityInverter x:Key="VisibilityInverter" />
    
    <DataTemplate x:Key="MessageContentAudioV3DataTemplate">
        <Grid>
            <Grid Visibility="{Binding Converter={StaticResource MessageContentSupportedToVisibilityConverter}}" HorizontalAlignment="Center">
                <Grid x:Name="gridContent" Visibility="{Binding Converter={StaticResource MessageContentAvailabilityToVisibilityConverter}, Mode=OneTime}">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <featurebase:MediaPlayerUserControl x:Name="mediaAudioPlayerUserControler" Background="Transparent" Width="420"
                                           BackupFile="{Binding Converter={StaticResource MessageContentToAudioVideoBackupFileConverter} }" 
                                           DownloadClicked="mediaAudioPlayerUserControler_DownloadClicked"/>
                    <Grid Grid.Row="1" x:Name="gridAudioDescription" Margin="0"
                      Visibility="{Binding Converter={StaticResource MessageContentToAudioTranscriptionVisibilityConverter}}" >

                        <Grid Padding="20,0,20,10" Width="{Binding ElementName=mediaAudioPlayerUserControler,  Path=Width}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <FontIcon Glyph="&#xED1E;" VerticalAlignment="Top" Margin="0,3,5,0" Foreground="{ThemeResource TextBoxForegroundThemeBrush}" />
                            <Grid Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <TextBlock x:Uid="TextBlockAudioTranscription" Text="XX Transcription" FontWeight="SemiBold" />
                                <TextBlock Grid.Row="1" Text="{Binding Converter={StaticResource MessageContentToAudioTranscriptionConverter}}" TextWrapping="WrapWholeWords"
                            FontSize="{ThemeResource CaptionTextBlockFontSize}" Style="{ThemeResource CaptionTextBlockStyle}"
                          Visibility="{Binding Converter={StaticResource MessageContentToAudioTranscriptionVisibilityConverter}}"/>
                            </Grid>
                        </Grid>
                    </Grid>
                </Grid>
                <Grid Visibility="{Binding Visibility, ElementName=gridContent, Converter={StaticResource VisibilityInverter}, Mode=OneWay}" ColumnSpacing="12">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <StackPanel VerticalAlignment="Center">
                        <TextBlock x:Uid="TextBlockAudioUnavailable" Text="XX Audio unavailable." Style="{ThemeResource BodyStrongTextBlockStyle}"/>
                        <TextBlock x:Uid="TextBlockAttachmentNotStoredOnDevice" Text="XX It may not be stored on your device." Style="{ThemeResource CaptionTextBlockStyle}"/>
                    </StackPanel>
                    <HyperlinkButton x:Uid="HyperlinkButtonAttachmentUnavailable" VerticalAlignment="Center" Grid.Column="1" CornerRadius="16" Padding="4">
                        <FontIcon Glyph="&#xE897;" />
                    </HyperlinkButton>
                </Grid>
            </Grid>
            <Grid Visibility="{Binding Converter={StaticResource MessageContentSupportedToVisibilityConverter}, ConverterParameter='invert'}">
                <Grid Padding="0" MaxWidth="400">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <FontIcon Glyph="&#xEC72;" VerticalAlignment="Center" Margin="0,0,15,0" FontSize="25px" Foreground="White"/>
                    <TextBlock Grid.Column="1" x:Uid="TextBlockNoAudioClip" x:Name="textBlockNoAudioFound" Text="XX This message contained an Audio recording but has expired or was not kept." 
                               TextWrapping="Wrap" VerticalAlignment="Center" FontStyle="Italic" Foreground="White" />
                </Grid>
            </Grid>
        </Grid>
    </DataTemplate>
</ResourceDictionary>
