<ContentDialog
    x:Class="Wino.Dialogs.SignatureEditorDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:accounts="using:Wino.Core.Domain.Models.Accounts"
    xmlns:controls="using:Wino.Controls"
    xmlns:controls1="using:CommunityToolkit.WinUI.Controls"
    xmlns:coreControls="using:Wino.Core.UWP.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:domain="using:Wino.Core.Domain"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
    Title="{x:Bind domain:Translator.SignatureEditorDialog_Title}"
    HorizontalContentAlignment="Stretch"
    Closed="DialogClosed"
    DefaultButton="Primary"
    IsPrimaryButtonEnabled="False"
    Opened="SignatureDialogOpened"
    PrimaryButtonClick="SaveClicked"
    PrimaryButtonText="{x:Bind domain:Translator.Buttons_Save}"
    SecondaryButtonClick="CancelClicked"
    SecondaryButtonText="{x:Bind domain:Translator.Buttons_Cancel}"
    Style="{StaticResource WinoDialogStyle}"
    mc:Ignorable="d">

    <ContentDialog.Resources>
        <x:Double x:Key="ContentDialogMaxWidth">1200</x:Double>
    </ContentDialog.Resources>

    <Grid Margin="0,20,0,0" RowSpacing="30">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" MaxHeight="400" />
        </Grid.RowDefinitions>

        <TextBox
            x:Name="SignatureNameTextBox"
            MinWidth="300"
            MaxWidth="500"
            HorizontalAlignment="Left"
            PlaceholderText="{x:Bind domain:Translator.SignatureEditorDialog_SignatureName_Placeholder}"
            TextChanged="SignatureNameTextBoxTextChanged" />

        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="300" />
            </Grid.RowDefinitions>

            <CommandBar
                Grid.Row="0"
                HorizontalAlignment="Left"
                Background="Transparent"
                DefaultLabelPosition="Collapsed"
                IsOpen="False">
                <AppBarButton
                    Width="48"
                    Click="InvertComposerThemeClicked"
                    LabelPosition="Collapsed"
                    ToolTipService.ToolTip="Light Theme"
                    Visibility="{x:Bind IsComposerDarkMode, Mode=OneWay}">
                    <AppBarButton.Icon>
                        <coreControls:WinoFontIcon Icon="LightEditor" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarButton
                    Width="48"
                    Click="InvertComposerThemeClicked"
                    LabelPosition="Collapsed"
                    ToolTipService.ToolTip="Dark Theme"
                    Visibility="{x:Bind IsComposerDarkMode, Mode=OneWay, Converter={StaticResource ReverseBooleanToVisibilityConverter}}">
                    <AppBarButton.Icon>
                        <coreControls:WinoFontIcon Icon="DarkEditor" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarSeparator />

                <AppBarToggleButton
                    x:Name="BoldButton"
                    Width="48"
                    Click="BoldButtonClicked"
                    Label="Bold"
                    ToolTipService.ToolTip="Bold">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource BoldPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    x:Name="ItalicButton"
                    Width="48"
                    Click="ItalicButtonClicked"
                    Label="Italic"
                    ToolTipService.ToolTip="Italic">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource ItalicPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    x:Name="UnderlineButton"
                    Width="48"
                    Click="UnderlineButtonClicked"
                    Label="Underline"
                    ToolTipService.ToolTip="Underline">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource UnderlinePathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    x:Name="StrokeButton"
                    Width="48"
                    Click="StrokeButtonClicked"
                    Label="Stroke"
                    ToolTipService.ToolTip="Stroke">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource StrikePathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarSeparator />
                <AppBarToggleButton
                    x:Name="BulletListButton"
                    Width="48"
                    Click="BulletListButtonClicked"
                    Label="Bullet List"
                    ToolTipService.ToolTip="Bullet List">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource BulletedListPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    x:Name="OrderedListButton"
                    Width="48"
                    Click="OrderedListButtonClicked"
                    Label="Ordered List"
                    ToolTipService.ToolTip="Ordered List">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource OrderedListPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>

                <AppBarSeparator />

                <AppBarButton
                    x:Name="DecreaseIndentButton"
                    Width="48"
                    Click="DecreaseIndentClicked"
                    Label="Decrease Indent"
                    ToolTipService.ToolTip="Decrease Indent">
                    <AppBarButton.Icon>
                        <PathIcon Data="{StaticResource DecreaseIndentPathIcon}" />
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton
                    x:Name="IncreaseIndentButton"
                    Width="48"
                    Click="IncreaseIndentClicked"
                    Label="Increase Indent"
                    ToolTipService.ToolTip="Increase Indent">
                    <AppBarButton.Icon>
                        <PathIcon Data="{StaticResource IncreaseIndentPathIcon}" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarElementContainer VerticalAlignment="Center">
                    <ComboBox
                        x:Name="AlignmentListView"
                        Background="Transparent"
                        BorderBrush="Transparent"
                        SelectionChanged="AlignmentChanged">
                        <ComboBoxItem IsSelected="True" Tag="left">
                            <StackPanel Orientation="Horizontal" Spacing="8">
                                <Viewbox Width="16">
                                    <PathIcon Data="{StaticResource AlignLeftPathIcon}" />
                                </Viewbox>
                                <TextBlock VerticalAlignment="Center" Text="{x:Bind domain:Translator.Left}" />
                            </StackPanel>
                        </ComboBoxItem>

                        <ComboBoxItem Tag="center">
                            <StackPanel Orientation="Horizontal" Spacing="8">
                                <Viewbox Width="16">
                                    <PathIcon Data="{StaticResource AlignCenterPathIcon}" />
                                </Viewbox>
                                <TextBlock VerticalAlignment="Center" Text="{x:Bind domain:Translator.Center}" />
                            </StackPanel>
                        </ComboBoxItem>

                        <ComboBoxItem Tag="right">
                            <StackPanel Orientation="Horizontal" Spacing="8">
                                <Viewbox Width="16">
                                    <PathIcon Data="{StaticResource AlignRightPathIcon}" />
                                </Viewbox>
                                <TextBlock VerticalAlignment="Center" Text="{x:Bind domain:Translator.Right}" />
                            </StackPanel>
                        </ComboBoxItem>

                        <ComboBoxItem Tag="justify">
                            <StackPanel Orientation="Horizontal" Spacing="8">
                                <Viewbox Width="16">
                                    <PathIcon Data="{StaticResource AlignJustifyPathIcon}" />
                                </Viewbox>
                                <TextBlock VerticalAlignment="Center" Text="{x:Bind domain:Translator.Justify}" />
                            </StackPanel>
                        </ComboBoxItem>
                    </ComboBox>
                </AppBarElementContainer>
                <AppBarSeparator />
                <AppBarButton
                    x:Name="AddImageButton"
                    Width="48"
                    Click="AddImageClicked"
                    Label="Add Image"
                    ToolTipService.ToolTip="{x:Bind domain:Translator.Photos}">
                    <AppBarButton.Icon>
                        <PathIcon Data="{StaticResource AddPhotoPathIcon}" />
                    </AppBarButton.Icon>
                    <AppBarButton.Content>
                        <StackPanel Orientation="Horizontal" Spacing="8">
                            <Viewbox Width="16" VerticalAlignment="Center">
                                <PathIcon Data="{StaticResource AddPhotoPathIcon}" />
                            </Viewbox>
                            <TextBlock Text="{x:Bind domain:Translator.Photos}" />
                        </StackPanel>
                    </AppBarButton.Content>
                </AppBarButton>
                <AppBarButton
                    x:Name="EmojiButton"
                    Width="48"
                    Click="EmojiButtonClicked"
                    Label="Add Emoji"
                    ToolTipService.ToolTip="{x:Bind domain:Translator.Emoji}">
                    <AppBarButton.Icon>
                        <PathIcon Data="{StaticResource EmojiPathIcon}" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarToggleButton
                    x:Name="WebviewToolBarButton"
                    Width="48"
                    Click="WebViewToggleButtonClicked"
                    Label="Webview ToolBar"
                    ToolTipService.ToolTip="Webview ToolBar">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource WebviewToolBarPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
            </CommandBar>
            <Border
                Grid.Row="1"
                Margin="0,6,0,0"
                BorderBrush="{StaticResource CardStrokeColorDefaultBrush}"
                BorderThickness="1"
                CornerRadius="3">
                <Grid CornerRadius="3">
                    <Grid Background="White" Visibility="{x:Bind IsComposerDarkMode, Converter={StaticResource ReverseBooleanToVisibilityConverter}, Mode=OneWay}" />

                    <muxc:WebView2 x:Name="Chromium" />
                </Grid>
            </Border>
        </Grid>
    </Grid>
</ContentDialog>
