From 009498f5900b1a00e8363231670a4021c5e1fce0 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Fri, 23 Jun 2023 22:24:43 +0800 Subject: [PATCH] feat: add loading. --- demo/Ursa.Demo/Pages/LoadingDemo.axaml | 25 ++++++ demo/Ursa.Demo/Pages/LoadingDemo.axaml.cs | 18 +++++ demo/Ursa.Demo/Views/MainWindow.axaml | 3 + src/Ursa.Themes.Semi/Controls/Loading.axaml | 78 +++++++++++++++++++ src/Ursa.Themes.Semi/Controls/_index.axaml | 1 + .../Converters/BrushToColorConverter.cs | 22 ++++++ src/Ursa/Controls/Loading/Loading.cs | 26 +++++++ src/Ursa/Controls/Loading/LoadingIcon.cs | 8 ++ 8 files changed, 181 insertions(+) create mode 100644 demo/Ursa.Demo/Pages/LoadingDemo.axaml create mode 100644 demo/Ursa.Demo/Pages/LoadingDemo.axaml.cs create mode 100644 src/Ursa.Themes.Semi/Controls/Loading.axaml create mode 100644 src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs create mode 100644 src/Ursa/Controls/Loading/Loading.cs create mode 100644 src/Ursa/Controls/Loading/LoadingIcon.cs diff --git a/demo/Ursa.Demo/Pages/LoadingDemo.axaml b/demo/Ursa.Demo/Pages/LoadingDemo.axaml new file mode 100644 index 0000000..f291038 --- /dev/null +++ b/demo/Ursa.Demo/Pages/LoadingDemo.axaml @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/demo/Ursa.Demo/Pages/LoadingDemo.axaml.cs b/demo/Ursa.Demo/Pages/LoadingDemo.axaml.cs new file mode 100644 index 0000000..cfbc0e8 --- /dev/null +++ b/demo/Ursa.Demo/Pages/LoadingDemo.axaml.cs @@ -0,0 +1,18 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Ursa.Demo.Pages; + +public partial class LoadingDemo : UserControl +{ + public LoadingDemo() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Views/MainWindow.axaml b/demo/Ursa.Demo/Views/MainWindow.axaml index 230667b..ee33626 100644 --- a/demo/Ursa.Demo/Views/MainWindow.axaml +++ b/demo/Ursa.Demo/Views/MainWindow.axaml @@ -35,6 +35,9 @@ + + + diff --git a/src/Ursa.Themes.Semi/Controls/Loading.axaml b/src/Ursa.Themes.Semi/Controls/Loading.axaml new file mode 100644 index 0000000..442c54b --- /dev/null +++ b/src/Ursa.Themes.Semi/Controls/Loading.axaml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Ursa.Themes.Semi/Controls/_index.axaml b/src/Ursa.Themes.Semi/Controls/_index.axaml index 8cf36e5..c0c304a 100644 --- a/src/Ursa.Themes.Semi/Controls/_index.axaml +++ b/src/Ursa.Themes.Semi/Controls/_index.axaml @@ -5,6 +5,7 @@ + diff --git a/src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs b/src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs new file mode 100644 index 0000000..425c6d2 --- /dev/null +++ b/src/Ursa.Themes.Semi/Converters/BrushToColorConverter.cs @@ -0,0 +1,22 @@ +using System.Globalization; +using Avalonia.Data.Converters; +using Avalonia.Media; + +namespace Ursa.Themes.Semi.Converters; + +public class BrushToColorConverter: IValueConverter +{ + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is ISolidColorBrush b) + { + return b.Color; + } + return null; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} \ No newline at end of file diff --git a/src/Ursa/Controls/Loading/Loading.cs b/src/Ursa/Controls/Loading/Loading.cs new file mode 100644 index 0000000..a444dc2 --- /dev/null +++ b/src/Ursa/Controls/Loading/Loading.cs @@ -0,0 +1,26 @@ +using Avalonia; +using Avalonia.Controls; + +namespace Ursa.Controls; + +public class Loading: ContentControl +{ + public static readonly StyledProperty IndicatorProperty = AvaloniaProperty.Register( + nameof(Indicator)); + + public object? Indicator + { + get => GetValue(IndicatorProperty); + set => SetValue(IndicatorProperty, value); + } + + public static readonly StyledProperty IsLoadingProperty = AvaloniaProperty.Register( + nameof(IsLoading)); + + public object? IsLoading + { + get => GetValue(IsLoadingProperty); + set => SetValue(IsLoadingProperty, value); + } + +} \ No newline at end of file diff --git a/src/Ursa/Controls/Loading/LoadingIcon.cs b/src/Ursa/Controls/Loading/LoadingIcon.cs new file mode 100644 index 0000000..b6d71fb --- /dev/null +++ b/src/Ursa/Controls/Loading/LoadingIcon.cs @@ -0,0 +1,8 @@ +using Avalonia.Controls; + +namespace Ursa.Controls; + +public class LoadingIcon: ContentControl +{ + +} \ No newline at end of file