<UserControl
    x:Class="PicView.Avalonia.Views.UC.SpinWaiter"
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:PicView="clr-namespace:PicView.Avalonia.Views.UC"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">

    <UserControl.Styles>
        <Style Selector="PicView|SpinWaiter">
            <Style.Setters>
                <Setter Property="Transitions">
                    <Transitions>
                        <DoubleTransition Property="Opacity" Duration="0:0:0.35" />
                    </Transitions>
                </Setter>
            </Style.Setters>
            <Style.Animations>
                <Animation
                    FillMode="None"
                    IterationCount="INFINITE"
                    PlaybackDirection="Normal"
                    Duration="0:0:1.5">
                    <Animation.Easing>
                        <QuadraticEaseInOut />
                    </Animation.Easing>
                    <KeyFrame Cue="0%">
                        <Setter Property="RotateTransform.Angle" Value="0" />
                    </KeyFrame>
                    <KeyFrame Cue="30%">
                        <Setter Property="RotateTransform.Angle" Value="0" />
                    </KeyFrame>

                    <KeyFrame Cue="100%">
                        <Setter Property="RotateTransform.Angle" Value="360" />
                    </KeyFrame>
                </Animation>
            </Style.Animations>
            <Setter Property="Template">
                <ControlTemplate>

                    <Arc
                        Name="PART_Arc"
                        Width="52"
                        Height="52"
                        StartAngle="270"
                        Stretch="None"
                        Stroke="{DynamicResource AccentColor}"
                        StrokeJoin="Round"
                        StrokeLineCap="Round"
                        StrokeThickness="4"
                        SweepAngle="30">

                        <Arc.Transitions>
                            <Transitions>
                                <DoubleTransition
                                    Easing="CircularEaseOut"
                                    Property="SweepAngle"
                                    Duration="0:0:0.8" />
                            </Transitions>
                        </Arc.Transitions>
                    </Arc>
                </ControlTemplate>
            </Setter>
        </Style>

        <Style Selector="PicView|SpinWaiter /template/ Arc">

            <Style.Animations>
                <Animation
                    Easing="QuadraticEaseInOut"
                    FillMode="None"
                    IterationCount="INFINITE"
                    PlaybackDirection="Normal"
                    Duration="0:0:1.5">
                    <KeyFrame Cue="0%">
                        <Setter Property="SweepAngle" Value="60" />
                    </KeyFrame>

                    <KeyFrame Cue="50%">
                        <Setter Property="SweepAngle" Value="250" />
                    </KeyFrame>

                    <KeyFrame Cue="100%">
                        <Setter Property="SweepAngle" Value="60" />
                    </KeyFrame>
                </Animation>
            </Style.Animations>
        </Style>
    </UserControl.Styles>
</UserControl>