From 2eea7c0df43e8d43ade00611fc451b94aed2117f Mon Sep 17 00:00:00 2001 From: Piero Castillo Date: Fri, 4 Feb 2022 15:36:34 -0500 Subject: [PATCH] wip --- Aura.UI.sln | 31 ++++++- .../AuraTabViewMVVMSample.csproj | 8 +- .../NavigationViewMVVMSample.csproj | 8 +- Tests/MathsForUI.Test/MathTests.cs | 17 ++++ Tests/MathsForUI.Test/MathsForUI.Test.csproj | 3 +- build/version.props | 10 +-- .../Aura.UI.Gallery.NetCore.csproj | 6 +- .../Aura.UI.Gallery.Web.csproj | 2 +- samples/Aura.UI.Gallery/App.axaml.cs | 43 ---------- .../Aura.UI.Gallery/Aura.UI.Gallery.csproj | 12 +-- samples/MiniSample/App.axaml | 2 +- samples/MiniSample/MiniSample.csproj | 11 +-- samples/MiniSample/Program.cs | 2 + .../ViewModels/MainWindowViewModel.cs | 80 ++++++++++++++++++- samples/MiniSample/Views/MainWindow.axaml | 21 ++--- .../AppBuilderExtensions.cs | 23 ++++++ .../Aura.UI.FluentTheme.csproj | 2 +- src/Aura.UI.FluentTheme/AuraUI.xaml.cs | 1 + .../Aura.UI.Painting.FluentTheme.csproj | 2 +- src/Aura.UI.Painting/Aura.UI.Painting.csproj | 16 ++-- src/Aura.UI/Aura.UI.csproj | 14 ++-- src/Aura.UI/Controls/Neumorphism/Neumor.cs | 52 ------------ src/Aura.UI/Extensions/RectExtensions.cs | 12 +++ 23 files changed, 218 insertions(+), 160 deletions(-) create mode 100644 src/Aura.UI.FluentTheme/AppBuilderExtensions.cs delete mode 100644 src/Aura.UI/Controls/Neumorphism/Neumor.cs create mode 100644 src/Aura.UI/Extensions/RectExtensions.cs diff --git a/Aura.UI.sln b/Aura.UI.sln index 9055d83..d2f1367 100644 --- a/Aura.UI.sln +++ b/Aura.UI.sln @@ -45,9 +45,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aura.UI.Gallery.NetCore", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aura.UI.Gallery.Web", "samples\Aura.UI.Gallery.Web\Aura.UI.Gallery.Web.csproj", "{E7ADBCED-FBED-4C95-B185-8002277B6690}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aura.UI.Painting", "src\Aura.UI.Painting\Aura.UI.Painting.csproj", "{1B62A10F-0645-4F86-B772-5B07F73A8A57}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aura.UI.Painting", "src\Aura.UI.Painting\Aura.UI.Painting.csproj", "{1B62A10F-0645-4F86-B772-5B07F73A8A57}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aura.UI.Painting.FluentTheme", "src\Aura.UI.Painting.FluentTheme\Aura.UI.Painting.FluentTheme.csproj", "{E0A75E75-CB4A-4E77-B311-E8D7CEC23D21}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aura.UI.Painting.FluentTheme", "src\Aura.UI.Painting.FluentTheme\Aura.UI.Painting.FluentTheme.csproj", "{E0A75E75-CB4A-4E77-B311-E8D7CEC23D21}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aura.UI.Neumorphism", "src\Aura.UI.Neumorphism\Aura.UI.Neumorphism.csproj", "{C475616B-704D-4A67-8E4C-A5D39D975B15}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -329,6 +331,30 @@ Global {E0A75E75-CB4A-4E77-B311-E8D7CEC23D21}.Release|x64.Build.0 = Release|Any CPU {E0A75E75-CB4A-4E77-B311-E8D7CEC23D21}.Release|x86.ActiveCfg = Release|Any CPU {E0A75E75-CB4A-4E77-B311-E8D7CEC23D21}.Release|x86.Build.0 = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|ARM.ActiveCfg = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|ARM.Build.0 = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|iPhone.ActiveCfg = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|iPhone.Build.0 = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|x64.ActiveCfg = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|x64.Build.0 = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|x86.ActiveCfg = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Debug|x86.Build.0 = Debug|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|Any CPU.Build.0 = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|ARM.ActiveCfg = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|ARM.Build.0 = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|iPhone.ActiveCfg = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|iPhone.Build.0 = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|iPhoneSimulator.Build.0 = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|x64.ActiveCfg = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|x64.Build.0 = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|x86.ActiveCfg = Release|Any CPU + {C475616B-704D-4A67-8E4C-A5D39D975B15}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -345,6 +371,7 @@ Global {E7ADBCED-FBED-4C95-B185-8002277B6690} = {3AF1E581-2ACF-4F42-BC10-12BACF221499} {1B62A10F-0645-4F86-B772-5B07F73A8A57} = {E0772EFF-1A2A-466C-83C7-A81D93213336} {E0A75E75-CB4A-4E77-B311-E8D7CEC23D21} = {E0772EFF-1A2A-466C-83C7-A81D93213336} + {C475616B-704D-4A67-8E4C-A5D39D975B15} = {E0772EFF-1A2A-466C-83C7-A81D93213336} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B04BDC4F-181C-461F-BB14-4E7516DB6B4A} diff --git a/MVVMSamples/AuraTabViewMVVMSample/AuraTabViewMVVMSample.csproj b/MVVMSamples/AuraTabViewMVVMSample/AuraTabViewMVVMSample.csproj index 55144ff..a5d848f 100644 --- a/MVVMSamples/AuraTabViewMVVMSample/AuraTabViewMVVMSample.csproj +++ b/MVVMSamples/AuraTabViewMVVMSample/AuraTabViewMVVMSample.csproj @@ -10,11 +10,11 @@ - - + + - - + + diff --git a/MVVMSamples/NavigationViewMVVMSample/NavigationViewMVVMSample.csproj b/MVVMSamples/NavigationViewMVVMSample/NavigationViewMVVMSample.csproj index 55144ff..a5d848f 100644 --- a/MVVMSamples/NavigationViewMVVMSample/NavigationViewMVVMSample.csproj +++ b/MVVMSamples/NavigationViewMVVMSample/NavigationViewMVVMSample.csproj @@ -10,11 +10,11 @@ - - + + - - + + diff --git a/Tests/MathsForUI.Test/MathTests.cs b/Tests/MathsForUI.Test/MathTests.cs index 267497b..0948f46 100644 --- a/Tests/MathsForUI.Test/MathTests.cs +++ b/Tests/MathsForUI.Test/MathTests.cs @@ -1,5 +1,8 @@ using Aura.UI.Helpers; +using Aura.UI.Neumorphism.Controls; using Avalonia; +using Avalonia.Media; +using Avalonia.Skia; using System; using Xunit; using static Aura.UI.Helpers.Maths; @@ -44,5 +47,19 @@ public void ThicknessTests(double width, double height, double p, double strokeW var padding = new Thickness(p); var r = size.WithHeight(Maths.TriangleHeightBySide(size.Width)).Inflate(padding + new Thickness(strokeWidth)); } + + [Theory] + [InlineData("#ffffff", 0.6, "#ffffff", "#666666")] + [InlineData("#ffffff", 0.08, "#ffffff", "#ebebeb")] + [InlineData("#a34d4d", 0.33, "#d96666", "#6d3434")] + public void ColorLuminanceTests(string baseColor, double intensity, string expectedLightColor, string expectedDarkColor) + { + var color = Color.Parse(baseColor).ToSKColor(); + + var light = Neumor.ChangeColorLuminosity(color, intensity); + var dark = Neumor.ChangeColorLuminosity(color, intensity * -1); + + Assert.Equal(light.ToString(), Color.Parse(expectedLightColor).ToSKColor().ToString()); + } } } diff --git a/Tests/MathsForUI.Test/MathsForUI.Test.csproj b/Tests/MathsForUI.Test/MathsForUI.Test.csproj index 67542a0..a51c1a2 100644 --- a/Tests/MathsForUI.Test/MathsForUI.Test.csproj +++ b/Tests/MathsForUI.Test/MathsForUI.Test.csproj @@ -13,13 +13,14 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all + diff --git a/build/version.props b/build/version.props index cc4abf3..8165279 100644 --- a/build/version.props +++ b/build/version.props @@ -1,12 +1,12 @@ - 0.1.5.0-dev-04 - 0.1.5.0 - 0.1.5.0 + 0.1.0-dev-01 + 0.1.0 + 0.1.0 10.0 MIT - https://github.com/PieroCastillo/Aura.UI + https://github.com/PieroCastillo/Aura.UI.Neumorphism/ true - auraui avalonia controls ui navigationview url + auraui avalonia controls ui neumorphism \ No newline at end of file diff --git a/samples/Aura.UI.Gallery.NetCore/Aura.UI.Gallery.NetCore.csproj b/samples/Aura.UI.Gallery.NetCore/Aura.UI.Gallery.NetCore.csproj index e4269af..4601ca0 100644 --- a/samples/Aura.UI.Gallery.NetCore/Aura.UI.Gallery.NetCore.csproj +++ b/samples/Aura.UI.Gallery.NetCore/Aura.UI.Gallery.NetCore.csproj @@ -7,10 +7,10 @@ 0.10.11 - + - - + + diff --git a/samples/Aura.UI.Gallery.Web/Aura.UI.Gallery.Web.csproj b/samples/Aura.UI.Gallery.Web/Aura.UI.Gallery.Web.csproj index e88f54e..e0d93cd 100644 --- a/samples/Aura.UI.Gallery.Web/Aura.UI.Gallery.Web.csproj +++ b/samples/Aura.UI.Gallery.Web/Aura.UI.Gallery.Web.csproj @@ -24,7 +24,7 @@ - + diff --git a/samples/Aura.UI.Gallery/App.axaml.cs b/samples/Aura.UI.Gallery/App.axaml.cs index dd9837e..7235ff2 100644 --- a/samples/Aura.UI.Gallery/App.axaml.cs +++ b/samples/Aura.UI.Gallery/App.axaml.cs @@ -70,49 +70,6 @@ public override void OnFrameworkInitializationCompleted() base.OnFrameworkInitializationCompleted(); } - - public void NavigationViewStatic() - { - var animation = new Animation() - { - Duration = new TimeSpan(0,0,0,3), - FillMode = FillMode.Forward, - Easing = new CubicEaseOut(), - Children = - { - new KeyFrame() - { - Cue = new Cue(0), - Setters = - { - new Setter(TranslateTransform.YProperty, 0), - new Setter(Control.OpacityProperty, 1), - } - }, - new KeyFrame() - { - Cue = new Cue(1), - Setters = - { - new Setter(TranslateTransform.YProperty, 0), - new Setter(Control.OpacityProperty, 1), - } - } - } - }; - - var style = new Style(x => x. - OfType() - .Class(":normal") - .Template() - .OfType() - .Name("PART_SelectedContentPresenter")); - - style.Animations.Add(animation); - - Styles.Add(style); - } - private AppSettings Settings { get; diff --git a/samples/Aura.UI.Gallery/Aura.UI.Gallery.csproj b/samples/Aura.UI.Gallery/Aura.UI.Gallery.csproj index 9a3d87b..ea8c3a8 100644 --- a/samples/Aura.UI.Gallery/Aura.UI.Gallery.csproj +++ b/samples/Aura.UI.Gallery/Aura.UI.Gallery.csproj @@ -48,12 +48,12 @@ - - - - - - + + + + + + diff --git a/samples/MiniSample/App.axaml b/samples/MiniSample/App.axaml index e51683b..38cd22a 100644 --- a/samples/MiniSample/App.axaml +++ b/samples/MiniSample/App.axaml @@ -8,6 +8,6 @@ - + diff --git a/samples/MiniSample/MiniSample.csproj b/samples/MiniSample/MiniSample.csproj index 03b8ca1..7ea0f9a 100644 --- a/samples/MiniSample/MiniSample.csproj +++ b/samples/MiniSample/MiniSample.csproj @@ -1,7 +1,7 @@ WinExe - net5.0 + net6.0 enable @@ -10,14 +10,15 @@ - - + + - - + + + diff --git a/samples/MiniSample/Program.cs b/samples/MiniSample/Program.cs index efa5d91..354b986 100644 --- a/samples/MiniSample/Program.cs +++ b/samples/MiniSample/Program.cs @@ -1,3 +1,4 @@ +using Aura.UI.FluentTheme; using Avalonia; using Avalonia.Controls.ApplicationLifetimes; using Avalonia.ReactiveUI; @@ -19,6 +20,7 @@ public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() .LogToTrace() + .UseAuraUIFluentTheme() .UseReactiveUI(); } } diff --git a/samples/MiniSample/ViewModels/MainWindowViewModel.cs b/samples/MiniSample/ViewModels/MainWindowViewModel.cs index d3557cf..cdb029e 100644 --- a/samples/MiniSample/ViewModels/MainWindowViewModel.cs +++ b/samples/MiniSample/ViewModels/MainWindowViewModel.cs @@ -1,3 +1,6 @@ +using Avalonia.Media; +using DynamicData.Binding; +using ReactiveUI; using System; using System.Collections.Generic; using System.Text; @@ -6,6 +9,81 @@ namespace MiniSample.ViewModels { public class MainWindowViewModel : ViewModelBase { - public string Greeting => "Welcome to Avalonia!"; + public MainWindowViewModel() + { + this.WhenPropertyChanged(x => x.R).Subscribe(x => + { + BackgroundColor = Color.FromRgb((byte)R, (byte)G, (byte)B); + }); + + + this.WhenPropertyChanged(x => x.G).Subscribe(x => + { + BackgroundColor = Color.FromRgb((byte)R, (byte)G, (byte)B); + }); + + + this.WhenPropertyChanged(x => x.B).Subscribe(x => + { + BackgroundColor = Color.FromRgb((byte)R, (byte)G, (byte)B); + }); + } + + private Color _BackgroundColor = Color.Parse("#FFe0e0e0"); + private double _Radius = 60; + private double _Distance = 20; + private double _Intensity = 0.15; + private double _Blur = 60; + private double _R = 0xe0; + private double _G = 0xe0; + private double _B = 0xe0; + + public Color BackgroundColor + { + get => _BackgroundColor; + set => this.RaiseAndSetIfChanged(ref _BackgroundColor, value); + } + + public double Radius + { + get => _Radius; + set => this.RaiseAndSetIfChanged(ref _Radius, value); + } + + public double Distance + { + get => _Distance; + set => this.RaiseAndSetIfChanged(ref _Distance, value); + } + + public double Intensity + { + get => _Intensity; + set => this.RaiseAndSetIfChanged(ref _Intensity, value); + } + + public double Blur + { + get => _Blur; + set => this.RaiseAndSetIfChanged(ref _Blur, value); + } + + public double R + { + get => _R; + set => this.RaiseAndSetIfChanged(ref _R, value); + } + + public double G + { + get => _G; + set => this.RaiseAndSetIfChanged(ref _G, value); + } + + public double B + { + get => _B; + set => this.RaiseAndSetIfChanged(ref _B, value); + } } } diff --git a/samples/MiniSample/Views/MainWindow.axaml b/samples/MiniSample/Views/MainWindow.axaml index 7ad9706..f5e0152 100644 --- a/samples/MiniSample/Views/MainWindow.axaml +++ b/samples/MiniSample/Views/MainWindow.axaml @@ -3,8 +3,9 @@ xmlns:vm="using:MiniSample.ViewModels" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" + mc:Ignorable="d" x:Class="MiniSample.Views.MainWindow" + Width="1000" Height="600" Icon="/Assets/avalonia-logo.ico" Title="MiniSample"> @@ -12,18 +13,8 @@ - - - - - - -