<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:controls2="using:Wino.Mail.Controls"
    xmlns:coreControls="using:Wino.Core.WinUI.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="Auto"
                    MinWidth="40"
                    Click="{x:Bind WebViewEditor.ToggleEditorTheme}"
                    LabelPosition="Collapsed"
                    ToolTipService.ToolTip="Light Theme"
                    Visibility="{x:Bind WebViewEditor.IsEditorDarkMode, Mode=OneWay}">
                    <AppBarButton.Icon>
                        <coreControls:WinoFontIcon Icon="LightEditor" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarButton
                    Width="Auto"
                    MinWidth="40"
                    Click="{x:Bind WebViewEditor.ToggleEditorTheme}"
                    LabelPosition="Collapsed"
                    ToolTipService.ToolTip="Dark Theme"
                    Visibility="{x:Bind WebViewEditor.IsEditorDarkMode, Mode=OneWay, Converter={StaticResource ReverseBooleanToVisibilityConverter}}">
                    <AppBarButton.Icon>
                        <coreControls:WinoFontIcon Icon="DarkEditor" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarSeparator />

                <AppBarToggleButton
                    Width="Auto"
                    MinWidth="40"
                    IsChecked="{x:Bind WebViewEditor.IsEditorBold, Mode=TwoWay}"
                    Label="Bold"
                    ToolTipService.ToolTip="Bold">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource BoldPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    Width="Auto"
                    MinWidth="40"
                    IsChecked="{x:Bind WebViewEditor.IsEditorItalic, Mode=TwoWay}"
                    Label="Italic"
                    ToolTipService.ToolTip="Italic">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource ItalicPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    Width="Auto"
                    MinWidth="40"
                    IsChecked="{x:Bind WebViewEditor.IsEditorUnderline, Mode=TwoWay}"
                    Label="Underline"
                    ToolTipService.ToolTip="Underline">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource UnderlinePathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    Width="Auto"
                    MinWidth="40"
                    IsChecked="{x:Bind WebViewEditor.IsEditorStrikethrough, Mode=TwoWay}"
                    Label="Stroke"
                    ToolTipService.ToolTip="Stroke">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource StrikePathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarSeparator />
                <AppBarToggleButton
                    Width="Auto"
                    MinWidth="40"
                    IsChecked="{x:Bind WebViewEditor.IsEditorUl, Mode=TwoWay}"
                    Label="Bullet List"
                    ToolTipService.ToolTip="Bullet List">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource BulletedListPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>
                <AppBarToggleButton
                    Width="Auto"
                    MinWidth="40"
                    IsChecked="{x:Bind WebViewEditor.IsEditorOl, Mode=TwoWay}"
                    Label="Ordered List"
                    ToolTipService.ToolTip="Ordered List">
                    <AppBarToggleButton.Icon>
                        <PathIcon Data="{StaticResource OrderedListPathIcon}" />
                    </AppBarToggleButton.Icon>
                </AppBarToggleButton>

                <AppBarSeparator />

                <AppBarButton
                    Width="Auto"
                    MinWidth="40"
                    Click="{x:Bind WebViewEditor.EditorOutdentAsync}"
                    IsEnabled="{x:Bind WebViewEditor.IsEditorOutdentEnabled, Mode=OneWay}"
                    Label="Decrease Indent"
                    ToolTipService.ToolTip="Decrease Indent">
                    <AppBarButton.Icon>
                        <PathIcon Data="{StaticResource DecreaseIndentPathIcon}" />
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton
                    Width="Auto"
                    MinWidth="40"
                    Click="{x:Bind WebViewEditor.EditorIndentAsync}"
                    IsEnabled="{x:Bind WebViewEditor.IsEditorIndentEnabled, Mode=OneWay}"
                    Label="Increase Indent"
                    ToolTipService.ToolTip="Increase Indent">
                    <AppBarButton.Icon>
                        <PathIcon Data="{StaticResource IncreaseIndentPathIcon}" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarElementContainer
                    Width="Auto"
                    MinWidth="40"
                    VerticalAlignment="Center">
                    <ComboBox
                        Background="Transparent"
                        BorderBrush="Transparent"
                        SelectedIndex="{x:Bind WebViewEditor.EditorAlignmentSelectedIndex, Mode=TwoWay}">
                        <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
                    Width="Auto"
                    MinWidth="40"
                    Click="{x:Bind WebViewEditor.ShowImagePicker}"
                    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
                    Width="Auto"
                    MinWidth="40"
                    Click="{x:Bind WebViewEditor.ShowEmojiPicker}"
                    Label="Add Emoji"
                    ToolTipService.ToolTip="{x:Bind domain:Translator.Emoji}">
                    <AppBarButton.Icon>
                        <PathIcon Data="{StaticResource EmojiPathIcon}" />
                    </AppBarButton.Icon>
                </AppBarButton>

                <AppBarToggleButton
                    Width="Auto"
                    MinWidth="40"
                    IsChecked="{x:Bind WebViewEditor.IsEditorWebViewEditor, Mode=TwoWay}"
                    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">
                <controls2:WebViewEditorControl x:Name="WebViewEditor" />
            </Border>
        </Grid>
    </Grid>
</ContentDialog>
