<controls:EnhancedPage
    x:Class="Pixeval.Pages.Capability.Feeds.FeedPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Pixeval.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:feeds="using:Pixeval.Pages.Capability.Feeds"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:media="using:CommunityToolkit.WinUI.Media"
    xmlns:ui="using:CommunityToolkit.WinUI"
    Background="Transparent"
    mc:Ignorable="d">
    <Page.Resources>
        <media:AttachedCardShadow x:Key="ContentPanelShadow" Offset="4" />
        <!--  See https://github.com/microsoft/microsoft-ui-xaml/blob/35c590bb28841eb9d466624bb828c78b939d4312/src/controls/dev/ItemContainer/ItemContainer_themeresources.xaml#L59  -->
        <SolidColorBrush x:Key="ItemContainerSelectedInnerBorderBrush" Color="Transparent" />
        <SolidColorBrush x:Key="ItemContainerBorderBrush" Color="Transparent" />
        <SolidColorBrush x:Key="ItemContainerSelectedBackground" Color="Transparent" />
        <SolidColorBrush x:Key="ItemContainerSelectedPointerOverBackground" Color="Transparent" />
        <SolidColorBrush x:Key="ItemContainerSelectedPressedBackground" Color="Transparent" />
        <SolidColorBrush x:Key="ItemContainerSelectionVisualBackground" Color="Transparent" />
        <SolidColorBrush x:Key="ItemContainerSelectionVisualPointerOverBackground" Color="Transparent" />
        <SolidColorBrush x:Key="ItemContainerSelectionVisualPressedBackground" Color="Transparent" />
        <media:AttachedCardShadow x:Key="TimelineBlockShadow" Offset="4" />
    </Page.Resources>
    <SplitView
        HorizontalAlignment="Stretch"
        VerticalAlignment="Stretch"
        DisplayMode="Inline"
        IsPaneOpen="True"
        OpenPaneLength="350"
        PaneBackground="Transparent"
        PanePlacement="Left">
        <SplitView.Pane>
            <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock
                    x:Uid="/FeedPage/FeedListTextBlock"
                    Grid.Row="0"
                    Margin="40,30,20,10"
                    Style="{StaticResource TitleTextBlockStyle}" />
                <Grid Grid.Row="1">
                    <controls:EntryView
                        Padding="0,10,0,0"
                        VerticalAlignment="Stretch"
                        Background="Transparent"
                        HasNoItem="{x:Bind _viewModel.HasNoItem, Mode=OneWay}"
                        IsLoadingMore="{x:Bind ItemsView.IsLoadingMore, Mode=OneWay}">
                        <controls:EntryView.Content>
                            <controls:AdvancedItemsView
                                x:Name="ItemsView"
                                HorizontalAlignment="Stretch"
                                IsItemInvokedEnabled="False"
                                ItemsSource="{x:Bind _viewModel.DataProvider.View, Mode=OneWay}"
                                SelectionChanged="ItemsView_OnSelectionChanged"
                                SelectionMode="Single">
                                <controls:AdvancedItemsView.ItemTemplate>
                                    <DataTemplate x:DataType="feeds:AbstractFeedItemViewModel">
                                        <ItemContainer x:Name="FeedItemContainer" Width="320">
                                            <Grid Width="320">
                                                <Grid
                                                    Width="320"
                                                    Height="80"
                                                    Padding="10,0"
                                                    ui:Effects.Shadow="{StaticResource ContentPanelShadow}"
                                                    Background="{x:Bind ItemBackground, Mode=OneWay}"
                                                    CornerRadius="4"
                                                    DataContext="{x:Bind Mode=OneWay}"
                                                    EffectiveViewportChanged="TimelineBlock_OnEffectiveViewportChanged"
                                                    Loaded="TimelineUnit_OnLoaded">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="60" />
                                                        <ColumnDefinition />
                                                    </Grid.ColumnDefinitions>
                                                    <Grid
                                                        Grid.Column="0"
                                                        Width="35"
                                                        Height="35"
                                                        HorizontalAlignment="Center"
                                                        VerticalAlignment="Center"
                                                        CornerRadius="50">
                                                        <Grid.Background>
                                                            <ImageBrush ImageSource="{x:Bind UserAvatar, Mode=OneWay}" Stretch="UniformToFill" />
                                                        </Grid.Background>
                                                    </Grid>
                                                    <Grid
                                                        Grid.Column="1"
                                                        HorizontalAlignment="Stretch"
                                                        VerticalAlignment="Stretch">
                                                        <Grid.RowDefinitions>
                                                            <RowDefinition Height="*" />
                                                            <RowDefinition Height="5" />
                                                            <RowDefinition Height="2*" />
                                                        </Grid.RowDefinitions>
                                                        <Grid Grid.Row="0">
                                                            <TextBlock
                                                                MaxWidth="155"
                                                                HorizontalAlignment="Left"
                                                                VerticalAlignment="Bottom"
                                                                FontSize="13"
                                                                FontWeight="Bold"
                                                                Text="{x:Bind PostUsername}"
                                                                TextTrimming="CharacterEllipsis"
                                                                TextWrapping="WrapWholeWords" />
                                                            <TextBlock
                                                                HorizontalAlignment="Right"
                                                                VerticalAlignment="Bottom"
                                                                FontSize="10"
                                                                Text="{x:Bind PostDateFormatted}" />
                                                        </Grid>
                                                        <Grid Grid.Row="2">
                                                            <TextBlock
                                                                x:Name="FeedContentTextBlock"
                                                                Margin="0,0,60,0"
                                                                FontSize="12"
                                                                LineHeight="20"
                                                                TextTrimming="CharacterEllipsis"
                                                                TextWrapping="WrapWholeWords" />
                                                            <SymbolIcon
                                                                HorizontalAlignment="Right"
                                                                Symbol="Pictures"
                                                                Visibility="{x:Bind IsCondensed}" />
                                                        </Grid>
                                                    </Grid>
                                                </Grid>
                                            </Grid>
                                        </ItemContainer>
                                    </DataTemplate>
                                </controls:AdvancedItemsView.ItemTemplate>
                                <controls:AdvancedItemsView.ItemTransitionProvider>
                                    <LinedFlowLayoutItemCollectionTransitionProvider />
                                </controls:AdvancedItemsView.ItemTransitionProvider>
                            </controls:AdvancedItemsView>
                        </controls:EntryView.Content>
                    </controls:EntryView>
                </Grid>
            </Grid>
        </SplitView.Pane>
        <Grid
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch"
            ui:Effects.Shadow="{StaticResource ContentPanelShadow}"
            CornerRadius="8,0,0,8">
            <Frame
                x:Name="FeedPageFrame"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch" />
            <Grid
                Width="100"
                Height="80"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Background="{ThemeResource PixevalAppAcrylicBrush}"
                CornerRadius="4"
                Visibility="{x:Bind _viewModel.IsLoading, Mode=OneWay}">
                <ProgressRing
                    Width="30"
                    Height="30"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center" />
            </Grid>
        </Grid>
    </SplitView>
</controls:EnhancedPage>
