Merge pull request #419 from irihitech/loading
Introducing background and foreground for LoadingContainer
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
<!-- Add Resources Here -->
|
<!-- Add Resources Here -->
|
||||||
<converters:BrushToColorConverter x:Key="BrushToColorConverter" />
|
<converters:BrushToColorConverter x:Key="BrushToColorConverter" />
|
||||||
<ControlTheme x:Key="{x:Type u:LoadingIcon}" TargetType="u:LoadingIcon">
|
<ControlTheme x:Key="{x:Type u:LoadingIcon}" TargetType="u:LoadingIcon">
|
||||||
|
<Setter Property="IsLoading" Value="True"></Setter>
|
||||||
<Setter Property="Foreground" Value="{DynamicResource LoadingIconForeground}" />
|
<Setter Property="Foreground" Value="{DynamicResource LoadingIconForeground}" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:LoadingIcon">
|
<ControlTemplate TargetType="u:LoadingIcon">
|
||||||
@@ -29,20 +30,6 @@
|
|||||||
</GradientStops>
|
</GradientStops>
|
||||||
</ConicGradientBrush>
|
</ConicGradientBrush>
|
||||||
</Arc.Stroke>
|
</Arc.Stroke>
|
||||||
<Arc.Styles>
|
|
||||||
<Style Selector="Arc[IsVisible=True]">
|
|
||||||
<Style.Animations>
|
|
||||||
<Animation IterationCount="Infinite" Duration="0:0:0.5">
|
|
||||||
<KeyFrame Cue="0%">
|
|
||||||
<Setter Property="RotateTransform.Angle" Value="0.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="100%">
|
|
||||||
<Setter Property="RotateTransform.Angle" Value="-360.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
</Animation>
|
|
||||||
</Style.Animations>
|
|
||||||
</Style>
|
|
||||||
</Arc.Styles>
|
|
||||||
</Arc>
|
</Arc>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
@@ -56,13 +43,25 @@
|
|||||||
<Setter Property="Height" Value="32" />
|
<Setter Property="Height" Value="32" />
|
||||||
<Setter Property="StrokeThickness" Value="5" />
|
<Setter Property="StrokeThickness" Value="5" />
|
||||||
</Style>
|
</Style>
|
||||||
|
<Style Selector="^[IsLoading=True] /template/ Arc#PART_Arc">
|
||||||
|
<Style.Animations>
|
||||||
|
<Animation IterationCount="Infinite" Duration="0:0:0.5">
|
||||||
|
<KeyFrame Cue="0%">
|
||||||
|
<Setter Property="RotateTransform.Angle" Value="0.0" />
|
||||||
|
</KeyFrame>
|
||||||
|
<KeyFrame Cue="100%">
|
||||||
|
<Setter Property="RotateTransform.Angle" Value="-360.0" />
|
||||||
|
</KeyFrame>
|
||||||
|
</Animation>
|
||||||
|
</Style.Animations>
|
||||||
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="{x:Type u:Loading}" TargetType="u:Loading">
|
<ControlTheme x:Key="{x:Type u:Loading}" TargetType="u:Loading">
|
||||||
<Setter Property="Background" Value="{DynamicResource LoadingMaskBackground}" />
|
<Setter Property="Background" Value="{DynamicResource LoadingMaskBackground}" />
|
||||||
<Setter Property="Indicator">
|
<Setter Property="Indicator">
|
||||||
<Template>
|
<Template>
|
||||||
<u:LoadingIcon />
|
<u:LoadingIcon IsLoading="{Binding $parent[u:Loading].IsLoading, Mode=TwoWay}" />
|
||||||
</Template>
|
</Template>
|
||||||
</Setter>
|
</Setter>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
@@ -93,10 +92,12 @@
|
|||||||
|
|
||||||
<ControlTheme x:Key="{x:Type u:LoadingContainer}" TargetType="u:LoadingContainer">
|
<ControlTheme x:Key="{x:Type u:LoadingContainer}" TargetType="u:LoadingContainer">
|
||||||
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||||
|
<Setter Property="MessageForeground" Value="{DynamicResource TextBlockDefaultForeground}"/>
|
||||||
|
<Setter Property="Background" Value="{DynamicResource LoadingMaskBackground}" />
|
||||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
<Setter Property="Indicator">
|
<Setter Property="Indicator">
|
||||||
<Template>
|
<Template>
|
||||||
<u:LoadingIcon />
|
<u:LoadingIcon IsLoading="{Binding $parent[u:LoadingContainer].IsLoading, Mode=TwoWay}" />
|
||||||
</Template>
|
</Template>
|
||||||
</Setter>
|
</Setter>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
@@ -109,6 +110,8 @@
|
|||||||
Content="{TemplateBinding Content}"
|
Content="{TemplateBinding Content}"
|
||||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||||
<u:Loading
|
<u:Loading
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
Foreground="{TemplateBinding MessageForeground}"
|
||||||
Content="{TemplateBinding LoadingMessage}"
|
Content="{TemplateBinding LoadingMessage}"
|
||||||
ContentTemplate="{TemplateBinding LoadingMessageTemplate}"
|
ContentTemplate="{TemplateBinding LoadingMessageTemplate}"
|
||||||
Indicator="{TemplateBinding Indicator}"
|
Indicator="{TemplateBinding Indicator}"
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ public class Loading: ContentControl
|
|||||||
set => SetValue(IndicatorProperty, value);
|
set => SetValue(IndicatorProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<object?> IsLoadingProperty = AvaloniaProperty.Register<Loading, object?>(
|
public static readonly StyledProperty<bool> IsLoadingProperty = AvaloniaProperty.Register<Loading, bool>(
|
||||||
nameof(IsLoading));
|
nameof(IsLoading));
|
||||||
|
|
||||||
public object? IsLoading
|
public bool IsLoading
|
||||||
{
|
{
|
||||||
get => GetValue(IsLoadingProperty);
|
get => GetValue(IsLoadingProperty);
|
||||||
set => SetValue(IsLoadingProperty, value);
|
set => SetValue(IsLoadingProperty, value);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Metadata;
|
using Avalonia.Controls.Metadata;
|
||||||
using Avalonia.Controls.Templates;
|
using Avalonia.Controls.Templates;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
@@ -28,6 +29,15 @@ public class LoadingContainer: ContentControl
|
|||||||
set => SetValue(LoadingMessageProperty, value);
|
set => SetValue(LoadingMessageProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<IBrush?> MessageForegroundProperty = AvaloniaProperty.Register<LoadingContainer, IBrush?>(
|
||||||
|
nameof(MessageForeground));
|
||||||
|
|
||||||
|
public IBrush? MessageForeground
|
||||||
|
{
|
||||||
|
get => GetValue(MessageForegroundProperty);
|
||||||
|
set => SetValue(MessageForegroundProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<IDataTemplate> LoadingMessageTemplateProperty = AvaloniaProperty.Register<LoadingContainer, IDataTemplate>(
|
public static readonly StyledProperty<IDataTemplate> LoadingMessageTemplateProperty = AvaloniaProperty.Register<LoadingContainer, IDataTemplate>(
|
||||||
nameof(LoadingMessageTemplate));
|
nameof(LoadingMessageTemplate));
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
public class LoadingIcon: ContentControl
|
public class LoadingIcon: ContentControl
|
||||||
{
|
{
|
||||||
|
public static readonly StyledProperty<bool> IsLoadingProperty = AvaloniaProperty.Register<LoadingIcon, bool>(
|
||||||
|
nameof(IsLoading));
|
||||||
|
|
||||||
|
public bool IsLoading
|
||||||
|
{
|
||||||
|
get => GetValue(IsLoadingProperty);
|
||||||
|
set => SetValue(IsLoadingProperty, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user