<local:LiveMessageViewBase
    x:Class="Bili.App.Controls.Player.LiveMessageView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:live="using:Bili.Models.Data.Live"
    xmlns:loc="using:Bili.App.Resources.Extension"
    xmlns:local="using:Bili.App.Controls.Player"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    xmlns:uwp="using:Richasy.FluentIcon.Uwp"
    d:DesignHeight="300"
    d:DesignWidth="400"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource LayerFillColorDefaultBrush}" CornerRadius="{StaticResource OverlayCornerRadius}">
        <ScrollViewer
            x:Name="ScrollViewer"
            HorizontalScrollMode="Disabled"
            VerticalScrollBarVisibility="Auto"
            ViewChanged="OnViewChanged">
            <Grid>
                <muxc:ItemsRepeater
                    x:Name="MessageRepeater"
                    Margin="12"
                    ItemsSource="{x:Bind ViewModel.Danmakus}">
                    <muxc:ItemsRepeater.Layout>
                        <muxc:StackLayout Spacing="12" />
                    </muxc:ItemsRepeater.Layout>
                    <muxc:ItemsRepeater.ItemTemplate>
                        <DataTemplate x:DataType="live:LiveDanmakuInformation">
                            <Grid RowSpacing="8">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Grid ColumnSpacing="4">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto" />
                                        <ColumnDefinition Width="*" />
                                    </Grid.ColumnDefinitions>
                                    <Border
                                        Padding="2"
                                        VerticalAlignment="Center"
                                        BorderBrush="{x:Bind UserLevelColor, Converter={StaticResource BrushConverter}}"
                                        BorderThickness="1"
                                        CornerRadius="{StaticResource ControlCornerRadius}">
                                        <TextBlock
                                            FontSize="10"
                                            Foreground="{x:Bind UserLevelColor, Converter={StaticResource BrushConverter}}"
                                            Text="{x:Bind UserLevel}" />
                                    </Border>
                                    <TextBlock
                                        Grid.Column="1"
                                        VerticalAlignment="Center"
                                        FontSize="12"
                                        Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                        Text="{x:Bind UserName}" />
                                </Grid>

                                <Border
                                    Grid.Row="1"
                                    Padding="12,8"
                                    HorizontalAlignment="Left"
                                    VerticalAlignment="Top"
                                    Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
                                    CornerRadius="{StaticResource ControlCornerRadius}">
                                    <TextBlock
                                        IsTextSelectionEnabled="True"
                                        Text="{x:Bind Text}"
                                        TextWrapping="WrapWholeWords" />
                                </Border>
                            </Grid>
                        </DataTemplate>
                    </muxc:ItemsRepeater.ItemTemplate>
                </muxc:ItemsRepeater>
                <StackPanel
                    Padding="0,12"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Spacing="8"
                    Visibility="{x:Bind ViewModel.IsDanmakusEmpty, Mode=OneWay}">
                    <uwp:RegularFluentIcon
                        HorizontalAlignment="Center"
                        FontSize="32"
                        Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                        Symbol="Chat48" />
                    <TextBlock
                        HorizontalAlignment="Center"
                        Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                        Text="{loc:Locale Name=NoMessage}"
                        TextAlignment="Center"
                        TextWrapping="Wrap" />
                </StackPanel>
            </Grid>
        </ScrollViewer>
    </Grid>
</local:LiveMessageViewBase>
