feat: Add Dark/Light color palette.
This commit is contained in:
parent
43305be6bf
commit
1a512e589d
@ -2,6 +2,7 @@
|
|||||||
x:Class="Semi.Avalonia.Demo.Pages.ColorPickerDemo"
|
x:Class="Semi.Avalonia.Demo.Pages.ColorPickerDemo"
|
||||||
xmlns="https://github.com/avaloniaui"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:colorPicker="clr-namespace:Semi.Avalonia.ColorPicker;assembly=Semi.Avalonia.ColorPicker"
|
||||||
xmlns:controls="using:Avalonia.Controls"
|
xmlns:controls="using:Avalonia.Controls"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
@ -15,11 +16,7 @@
|
|||||||
Spacing="20">
|
Spacing="20">
|
||||||
<ColorView ColorSpectrumShape="Ring" />
|
<ColorView ColorSpectrumShape="Ring" />
|
||||||
<ColorView ColorSpectrumShape="Box" />
|
<ColorView ColorSpectrumShape="Box" />
|
||||||
<ColorView>
|
<ColorView Palette="{DynamicResource SemiColorPalette}" />
|
||||||
<ColorView.Palette>
|
|
||||||
<controls:MaterialColorPalette />
|
|
||||||
</ColorView.Palette>
|
|
||||||
</ColorView>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
<StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
|
||||||
<ColorPicker ColorSpectrumShape="Ring">
|
<ColorPicker ColorSpectrumShape="Ring">
|
||||||
@ -29,7 +26,7 @@
|
|||||||
</ColorPicker>
|
</ColorPicker>
|
||||||
<ColorPicker ColorSpectrumShape="Box">
|
<ColorPicker ColorSpectrumShape="Box">
|
||||||
<ColorPicker.Palette>
|
<ColorPicker.Palette>
|
||||||
<controls:MaterialColorPalette />
|
<colorPicker:SemiColorLightPalette />
|
||||||
</ColorPicker.Palette>
|
</ColorPicker.Palette>
|
||||||
</ColorPicker>
|
</ColorPicker>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
<ResourceDictionary
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:colorPicker="clr-namespace:Semi.Avalonia.ColorPicker">
|
||||||
<!-- Add Resources Here -->
|
<!-- Add Resources Here -->
|
||||||
<SolidColorBrush x:Key="ColorViewRadioButtonForeground" Color="#54A9FF" />
|
<SolidColorBrush x:Key="ColorViewRadioButtonForeground" Color="#54A9FF" />
|
||||||
<SolidColorBrush x:Key="ColorViewRadioButtonBackground" Color="#1C1F23" />
|
<SolidColorBrush x:Key="ColorViewRadioButtonBackground" Color="#1C1F23" />
|
||||||
@ -40,4 +43,6 @@
|
|||||||
<CornerRadius x:Key="ColorPreviewerCornerRadius">3</CornerRadius>
|
<CornerRadius x:Key="ColorPreviewerCornerRadius">3</CornerRadius>
|
||||||
|
|
||||||
<BoxShadows x:Key="ColorPreviewerMainBoxShadow">0 0 14 0 #1AFFFFFF</BoxShadows>
|
<BoxShadows x:Key="ColorPreviewerMainBoxShadow">0 0 14 0 #1AFFFFFF</BoxShadows>
|
||||||
|
|
||||||
|
<colorPicker:SemiColorDarkPalette x:Key="SemiColorPalette" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
<ResourceDictionary
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:colorPicker="clr-namespace:Semi.Avalonia.ColorPicker">
|
||||||
<!-- Add Resources Here -->
|
<!-- Add Resources Here -->
|
||||||
<SolidColorBrush x:Key="ColorViewRadioButtonForeground" Color="#0077FA" />
|
<SolidColorBrush x:Key="ColorViewRadioButtonForeground" Color="#0077FA" />
|
||||||
<SolidColorBrush x:Key="ColorViewRadioButtonBackground" Color="White" />
|
<SolidColorBrush x:Key="ColorViewRadioButtonBackground" Color="White" />
|
||||||
@ -40,4 +43,5 @@
|
|||||||
<CornerRadius x:Key="ColorPreviewerCornerRadius">3</CornerRadius>
|
<CornerRadius x:Key="ColorPreviewerCornerRadius">3</CornerRadius>
|
||||||
|
|
||||||
<BoxShadows x:Key="ColorPreviewerMainBoxShadow">0 0 14 0 #1A000000</BoxShadows>
|
<BoxShadows x:Key="ColorPreviewerMainBoxShadow">0 0 14 0 #1A000000</BoxShadows>
|
||||||
|
<colorPicker:SemiColorLightPalette x:Key="SemiColorPalette" />
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<Import Project="../Package.props"/>
|
<Import Project="../Package.props" />
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Title>Semi.Avalonia.ColorPicker</Title>
|
<Title>Semi.Avalonia.ColorPicker</Title>
|
||||||
|
29
src/Semi.Avalonia.ColorPicker/SemiColorDarkPalette.cs
Normal file
29
src/Semi.Avalonia.ColorPicker/SemiColorDarkPalette.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Utilities;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.ColorPicker;
|
||||||
|
|
||||||
|
public class SemiColorDarkPalette: IColorPalette
|
||||||
|
{
|
||||||
|
private static readonly Color[,] Colors = new Color[,]
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Color.FromUInt32(0xFF6C090B),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Color.FromUInt32(0xFF6C090B),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public Color GetColor(int colorIndex, int shadeIndex)
|
||||||
|
{
|
||||||
|
return Colors[
|
||||||
|
MathUtilities.Clamp(colorIndex, 0, ColorCount - 1),
|
||||||
|
MathUtilities.Clamp(shadeIndex, 0, ShadeCount - 1)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ColorCount => Colors.GetLength(0);
|
||||||
|
|
||||||
|
public int ShadeCount => Colors.GetLength(1);
|
||||||
|
}
|
29
src/Semi.Avalonia.ColorPicker/SemiColorLightPalette.cs
Normal file
29
src/Semi.Avalonia.ColorPicker/SemiColorLightPalette.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Utilities;
|
||||||
|
|
||||||
|
namespace Semi.Avalonia.ColorPicker;
|
||||||
|
|
||||||
|
public class SemiColorLightPalette: IColorPalette
|
||||||
|
{
|
||||||
|
private static readonly Color[,] Colors = new Color[,]
|
||||||
|
{
|
||||||
|
{
|
||||||
|
Color.FromUInt32(0xFFFEF2ED),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Color.FromUInt32(0xFFFEF2ED),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public Color GetColor(int colorIndex, int shadeIndex)
|
||||||
|
{
|
||||||
|
return Colors[
|
||||||
|
MathUtilities.Clamp(colorIndex, 0, ColorCount - 1),
|
||||||
|
MathUtilities.Clamp(shadeIndex, 0, ShadeCount - 1)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ColorCount => Colors.GetLength(0);
|
||||||
|
|
||||||
|
public int ShadeCount => Colors.GetLength(1);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user