<ContentDialog
    x:Class="Wallet.Avalonia.CreateWalletView"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ui="using:FluentAvalonia.UI.Controls"
    xmlns:vm="using:Wallet"
    x:DataType="vm:CreateWalletViewModel"
    CloseButtonText="Cancel"
    DefaultButton="Primary"
    PrimaryButtonText="Create">
    <ContentDialog.Resources>
        <x:Double x:Key="PersonPictureSize">144</x:Double>
        <x:Double x:Key="ButtonSize">36</x:Double>
        <Thickness x:Key="ButtonMargin">0,0,6,6</Thickness>
        <CornerRadius x:Key="ButtonCornerRadius">18</CornerRadius>
    </ContentDialog.Resources>
    <ContentDialog.Styles>
        <Style Selector="ui|ContentDialog.Write">
            <Setter Property="IsPrimaryButtonEnabled" Value="True" />
        </Style>
        <Style Selector="ui|ContentDialog.Read">
            <Setter Property="IsPrimaryButtonEnabled" Value="False" />
        </Style>
        <Style Selector="ui|ContentDialog.Active">
            <Setter Property="IsPrimaryButtonEnabled" Value="False" />
        </Style>
    </ContentDialog.Styles>
    <Interaction.Behaviors>
        <DataTriggerBehavior Binding="{Binding Validation.HasErrors}" Value="True">
            <AddClassAction ClassName="Read" RemoveIfExists="True" />
            <RemoveClassAction ClassName="Write" />
        </DataTriggerBehavior>
        <DataTriggerBehavior Binding="{Binding Validation.HasErrors}" Value="False">
            <AddClassAction ClassName="Write" RemoveIfExists="True" />
            <RemoveClassAction ClassName="Read" />
        </DataTriggerBehavior>
        <DataTriggerBehavior Binding="{Binding IsActive}" Value="True">
            <ConditionAction>
                <ConditionAction.Condition>
                    <ConditionalExpression ForwardChaining="And">
                        <ComparisonCondition LeftOperand="{Binding IsConfirmed}" RightOperand="False" />
                    </ConditionalExpression>
                </ConditionAction.Condition>
                <AddClassAction ClassName="Active" RemoveIfExists="True" />
            </ConditionAction>
        </DataTriggerBehavior>
        <DataTriggerBehavior Binding="{Binding IsActive}" Value="False">
            <ConditionAction>
                <ConditionAction.Condition>
                    <ConditionalExpression ForwardChaining="And">
                        <ComparisonCondition LeftOperand="{Binding IsConfirmed}" RightOperand="False" />
                    </ConditionalExpression>
                </ConditionAction.Condition>
                <RemoveClassAction ClassName="Active" />
            </ConditionAction>
        </DataTriggerBehavior>
    </Interaction.Behaviors>
    <Grid>
        <StackPanel
            Width="400"
            Margin="0,-24,0,0"
            IsEnabled="{Binding !IsActive}"
            Spacing="18">
            <Grid HorizontalAlignment="Center">
                <PersonPicture
                    Width="{StaticResource PersonPictureSize}"
                    Height="{StaticResource PersonPictureSize}"
                    DisplayName="{Binding Name}"
                    ProfilePicture="{Binding Image, Converter={ImageDescriptorToBitmapConverter}}" />
                <DropDownButton
                    Width="{StaticResource ButtonSize}"
                    Height="{StaticResource ButtonSize}"
                    Margin="{StaticResource ButtonMargin}"
                    Padding="0"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Bottom"
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    CornerRadius="{StaticResource ButtonCornerRadius}">
                    <DropDownButton.Styles>
                        <Style Selector="DropDownButton /template/ ui|FontIcon#DropDownGlyph">
                            <Setter Property="IsVisible" Value="False" />
                        </Style>
                    </DropDownButton.Styles>
                    <DropDownButton.Flyout>
                        <MenuFlyout>
                            <MenuItem Command="{Binding ImportCommand}" Header="Import image" />
                            <MenuItem Header="Remove image" />
                        </MenuFlyout>
                    </DropDownButton.Flyout>
                    <TextBlock
                        Margin="0,3,0,0"
                        VerticalAlignment="Center"
                        FontFamily="{DynamicResource FluentThemeFontFamily}"
                        FontSize="18"
                        Text="&#xE36A;" />
                </DropDownButton>
            </Grid>
            <StackPanel>
                <TextBlock Margin="0,0,0,6" Text="Name" />
                <TextBox Text="{Binding Name}" Watermark="e.g. Personal" />
            </StackPanel>
            <StackPanel>
                <TextBlock Margin="0,0,0,6" Text="Password" />
                <TextBox
                    Classes="revealPasswordButton"
                    PasswordChar="&#x25CF;"
                    Text="{Binding Password}" />
            </StackPanel>
        </StackPanel>
        <ProgressRing
            Width="48"
            Height="48"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            IsActive="{Binding IsActive}"
            IsVisible="{Binding IsActive}" />
    </Grid>
</ContentDialog>
