forked from irihitech/Ursa.Avalonia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
131 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<!-- Add Resources Here --> | ||
<SolidColorBrush x:Key="LoadingIconForeground" Color="#54A9FF" /> | ||
<SolidColorBrush x:Key="LoadingMaskBackground" Opacity="0.12" Color="White" /> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<!-- Add Resources Here --> | ||
<SolidColorBrush x:Key="LoadingIconForeground" Color="#0077FA" /> | ||
<SolidColorBrush x:Key="LoadingMaskBackground" Opacity="0.05" Color="#2E3238" /> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Controls.Metadata; | ||
using Avalonia.Controls.Templates; | ||
|
||
namespace Ursa.Controls; | ||
|
||
[PseudoClasses(PC_Loading)] | ||
public class LoadingContainer: ContentControl | ||
{ | ||
public const string PC_Loading = ":loading"; | ||
|
||
public static readonly StyledProperty<object?> IndicatorProperty = AvaloniaProperty.Register<LoadingContainer, object?>( | ||
nameof(Indicator)); | ||
|
||
public object? Indicator | ||
{ | ||
get => GetValue(IndicatorProperty); | ||
set => SetValue(IndicatorProperty, value); | ||
} | ||
|
||
public static readonly StyledProperty<object?> LoadingMessageProperty = AvaloniaProperty.Register<LoadingContainer, object?>( | ||
nameof(LoadingMessage)); | ||
|
||
public object? LoadingMessage | ||
{ | ||
get => GetValue(LoadingMessageProperty); | ||
set => SetValue(LoadingMessageProperty, value); | ||
} | ||
|
||
public static readonly StyledProperty<IDataTemplate> LoadingMessageTemplateProperty = AvaloniaProperty.Register<LoadingContainer, IDataTemplate>( | ||
nameof(LoadingMessageTemplate)); | ||
|
||
public IDataTemplate LoadingMessageTemplate | ||
{ | ||
get => GetValue(LoadingMessageTemplateProperty); | ||
set => SetValue(LoadingMessageTemplateProperty, value); | ||
} | ||
|
||
public static readonly StyledProperty<bool> IsLoadingProperty = AvaloniaProperty.Register<LoadingContainer, bool>( | ||
nameof(IsLoading)); | ||
|
||
public bool IsLoading | ||
{ | ||
get => GetValue(IsLoadingProperty); | ||
set => SetValue(IsLoadingProperty, value); | ||
} | ||
|
||
static LoadingContainer() | ||
{ | ||
IsLoadingProperty.Changed.AddClassHandler<LoadingContainer>((x, e) => x.OnIsLoadingChanged(e)); | ||
} | ||
|
||
private void OnIsLoadingChanged(AvaloniaPropertyChangedEventArgs args) | ||
{ | ||
bool newValue = args.GetNewValue<bool>(); | ||
PseudoClasses.Set(PC_Loading, newValue); | ||
} | ||
} |