diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml b/demo/Ursa.Demo/Pages/AvatarDemo.axaml new file mode 100644 index 0000000..1a07543 --- /dev/null +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml @@ -0,0 +1,96 @@ + + + + + + M7.44721 3.10557C7.786 2.428 8.47852 2 9.23607 2H14.7639C15.5215 2 16.214 2.428 16.5528 3.10557L17.5 5H20C21.6569 5 23 6.34315 23 8V18C23 19.6569 21.6569 21 20 21H4C2.34315 21 1 19.6569 1 18V8C1 6.34315 2.34315 5 4 5H6.5L7.44721 3.10557ZM9 13C9 11.3431 10.3431 10 12 10C13.6569 10 15 11.3431 15 13C15 14.6569 13.6569 16 12 16C10.3431 16 9 14.6569 9 13ZM12 8C9.23858 8 7 10.2386 7 13C7 15.7614 9.23858 18 12 18C14.7614 18 17 15.7614 17 13C17 10.2386 14.7614 8 12 8Z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs b/demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs new file mode 100644 index 0000000..5bc2485 --- /dev/null +++ b/demo/Ursa.Demo/Pages/AvatarDemo.axaml.cs @@ -0,0 +1,13 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Ursa.Demo.Pages; + +public partial class AvatarDemo : UserControl +{ + public AvatarDemo() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs new file mode 100644 index 0000000..6717d41 --- /dev/null +++ b/demo/Ursa.Demo/ViewModels/AvatarDemoViewModel.cs @@ -0,0 +1,16 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; + +namespace Ursa.Demo.ViewModels; + +public partial class AvatarDemoViewModel : ViewModelBase +{ + [ObservableProperty] private string _content = "AS"; + [ObservableProperty] private bool _canClick = true; + + [RelayCommand(CanExecute = nameof(CanClick))] + private void Click() + { + Content = "BM"; + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs index cabccf6..4bd2bab 100644 --- a/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/MainViewViewModel.cs @@ -25,6 +25,7 @@ public class MainViewViewModel : ViewModelBase Content = s switch { MenuKeys.MenuKeyIntroduction => new IntroductionDemoViewModel(), + MenuKeys.MenuKeyAvatar => new AvatarDemoViewModel(), MenuKeys.MenuKeyBadge => new BadgeDemoViewModel(), MenuKeys.MenuKeyBanner => new BannerDemoViewModel(), MenuKeys.MenuKeyButtonGroup => new ButtonGroupDemoViewModel(), diff --git a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs index 9734638..d6af864 100644 --- a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs @@ -12,6 +12,7 @@ public class MenuViewModel: ViewModelBase { new() { MenuHeader = "Introduction", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false }, new() { MenuHeader = "Controls", IsSeparator = true }, + new() { MenuHeader = "Avatar", Key = MenuKeys.MenuKeyAvatar, Status = "WIP"}, new() { MenuHeader = "Badge", Key = MenuKeys.MenuKeyBadge }, new() { MenuHeader = "Banner", Key = MenuKeys.MenuKeyBanner }, new() { MenuHeader = "Breadcrumb", Key = MenuKeys.MenuKeyBreadcrumb }, @@ -60,6 +61,7 @@ public class MenuViewModel: ViewModelBase public static class MenuKeys { public const string MenuKeyIntroduction = "Introduction"; + public const string MenuKeyAvatar = "Avatar"; public const string MenuKeyBadge = "Badge"; public const string MenuKeyBanner = "Banner"; public const string MenuKeyButtonGroup = "ButtonGroup"; diff --git a/src/Ursa.Themes.Semi/Controls/Avatar.axaml b/src/Ursa.Themes.Semi/Controls/Avatar.axaml new file mode 100644 index 0000000..4fe9705 --- /dev/null +++ b/src/Ursa.Themes.Semi/Controls/Avatar.axaml @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Controls/_index.axaml b/src/Ursa.Themes.Semi/Controls/_index.axaml index 05be946..0345044 100644 --- a/src/Ursa.Themes.Semi/Controls/_index.axaml +++ b/src/Ursa.Themes.Semi/Controls/_index.axaml @@ -1,6 +1,7 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml b/src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml new file mode 100644 index 0000000..53516aa --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Dark/Avatar.axaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml index 05efaed..91ca159 100644 --- a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml @@ -1,5 +1,6 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml b/src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml new file mode 100644 index 0000000..9080891 --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Light/Avatar.axaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml index 05efaed..91ca159 100644 --- a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml @@ -1,5 +1,6 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml new file mode 100644 index 0000000..ebd81a4 --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Shared/Avatar.axaml @@ -0,0 +1,29 @@ + + 600 + 100 + + 3 + + 20 + 10 + + 24 + 10 + + 32 + 12 + + 40 + 18 + + 48 + 20 + + 72 + 32 + 6 + + 128 + 64 + 12 + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml index 68ac463..a09a2aa 100644 --- a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml @@ -1,5 +1,6 @@ + diff --git a/src/Ursa/Controls/Avatar/Avatar.cs b/src/Ursa/Controls/Avatar/Avatar.cs new file mode 100644 index 0000000..a3d134c --- /dev/null +++ b/src/Ursa/Controls/Avatar/Avatar.cs @@ -0,0 +1,26 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Media; + +namespace Ursa.Controls; + +public class Avatar : Button +{ + public static readonly StyledProperty SourceProperty = AvaloniaProperty.Register( + nameof(Source)); + + public static readonly StyledProperty HoverMaskProperty = AvaloniaProperty.Register( + nameof(HoverMask)); + + public IImage? Source + { + get => GetValue(SourceProperty); + set => SetValue(SourceProperty, value); + } + + public object? HoverMask + { + get => GetValue(HoverMaskProperty); + set => SetValue(HoverMaskProperty, value); + } +} \ No newline at end of file diff --git a/src/Ursa/Converters/DivideByTwoConverter.cs b/src/Ursa/Converters/DivideByTwoConverter.cs new file mode 100644 index 0000000..1fc2c74 --- /dev/null +++ b/src/Ursa/Converters/DivideByTwoConverter.cs @@ -0,0 +1,22 @@ +using System.Globalization; +using Avalonia.Data.Converters; + +namespace Ursa.Converters; + +public class DivideByTwoConverter : IValueConverter +{ + public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) + { + if (value is double d) + { + return d / 2; + } + + return value; + } + + public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } +} \ No newline at end of file