<?xml version="1.0" encoding="utf-8" ?>
<local:DrawServicePageBase
    x:Class="RodelAgent.UI.Pages.DrawServicePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:base="using:Richasy.WinUI.Share.Base"
    xmlns:community="using:CommunityToolkit.WinUI.Controls"
    xmlns:controls="using:RodelAgent.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:draw="using:RodelAgent.UI.Controls.Draw"
    xmlns:ext="using:RodelAgent.UI.Extensions"
    xmlns:local="using:RodelAgent.UI.Pages"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid>
        <base:EmptyHolder
            Title="{ext:Locale Name=NoAvailableService}"
            Description="{ext:Locale Name=NoAvailableServiceDescription}"
            Emoji="&#x1F3A8;"
            Visibility="{x:Bind ViewModel.IsAvailableServicesEmpty, Mode=OneWay}" />
        <Grid Visibility="{x:Bind ViewModel.IsAvailableServicesEmpty, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="{x:Bind ViewModel.NavColumnWidth, Mode=OneWay, Converter={StaticResource GridLengthConverter}}" />
            </Grid.ColumnDefinitions>

            <Grid.ChildrenTransitions>
                <RepositionThemeTransition IsStaggeringEnabled="False" />
            </Grid.ChildrenTransitions>

            <Grid Margin="0,0,-6,0" RowSpacing="8">
                <Grid.RowDefinitions>
                    <RowDefinition Height="56" />
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <draw:DrawServiceHeader />
                <StackPanel
                    Grid.Row="1"
                    Padding="20,12"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    Background="{ThemeResource CardBackgroundFillColorDefaultBrush}"
                    BorderBrush="{ThemeResource SystemFillColorCriticalBrush}"
                    BorderThickness="1"
                    CornerRadius="{ThemeResource ControlCornerRadius}"
                    Spacing="8"
                    Visibility="{x:Bind ViewModel.Session.ErrorText, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}">
                    <TextBlock
                        x:Name="ErrorBlock"
                        MaxWidth="240"
                        HorizontalAlignment="Center"
                        MaxLines="3"
                        Style="{StaticResource CaptionTextBlockStyle}"
                        Text="{x:Bind ViewModel.Session.ErrorText, Mode=OneWay}"
                        TextAlignment="Center"
                        TextWrapping="Wrap">
                        <ToolTipService.ToolTip>
                            <ToolTip Content="{x:Bind ViewModel.Session.ErrorText, Mode=OneWay}" IsEnabled="{x:Bind ErrorBlock.IsTextTrimmed, Mode=OneWay}" />
                        </ToolTipService.ToolTip>
                    </TextBlock>
                </StackPanel>

                <Grid Grid.Row="1" Visibility="{x:Bind ViewModel.Session.ErrorText, Mode=OneWay, Converter={StaticResource ObjectToVisibilityReverseConverter}}">
                    <ScrollViewer
                        Padding="22,0"
                        Style="{StaticResource PageScrollViewerStyle}"
                        Visibility="{x:Bind ViewModel.Session.ImagePath, Mode=OneWay, Converter={StaticResource ObjectToVisibilityConverter}}">
                        <draw:DrawSessionPresenter Margin="0,12" ViewModel="{x:Bind ViewModel.Session, Mode=OneWay}" />
                    </ScrollViewer>
                    <Grid Visibility="{x:Bind ViewModel.Session.ImagePath, Mode=OneWay, Converter={StaticResource ObjectToVisibilityReverseConverter}}">
                        <base:Shimmer
                            Margin="20"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            CornerRadius="{StaticResource OverlayCornerRadius}"
                            Visibility="{x:Bind ViewModel.Session.IsDrawing, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
                        <base:EmptyHolder
                            Title="{ext:Locale Name=NeedDrawImage}"
                            Description="{ext:Locale Name=NeedDrawImageDescription}"
                            Emoji="&#x270D;"
                            Visibility="{x:Bind ViewModel.Session.IsDrawing, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}" />
                    </Grid>
                </Grid>

                <draw:DrawSessionInput
                    Grid.Row="2"
                    MinHeight="120"
                    ViewModel="{x:Bind ViewModel.Session, Mode=OneWay}" />
            </Grid>

            <Grid
                Grid.Column="2"
                Margin="-6,0,0,0"
                Background="{ThemeResource LayerFillColorDefaultBrush}"
                Visibility="{x:Bind ViewModel.IsNavColumnManualHide, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
                <draw:DrawHistorySection />
            </Grid>

            <!--  右侧分栏大小控制器  -->
            <controls:ColumnSplitter
                Grid.RowSpan="2"
                Grid.Column="1"
                ColumnWidth="{x:Bind ViewModel.NavColumnWidth, Mode=TwoWay}"
                IsHide="{x:Bind ViewModel.IsNavColumnManualHide, Mode=TwoWay}"
                IsInvertDirection="True" />
        </Grid>
    </Grid>
</local:DrawServicePageBase>
