Skip to content

Commit

Permalink
modify: Merge SukiUI
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzh0816 committed Aug 29, 2024
1 parent 773d501 commit f064298
Show file tree
Hide file tree
Showing 42 changed files with 456 additions and 291 deletions.
12 changes: 7 additions & 5 deletions SukiUI/ColorTheme/Dark.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Color x:Key="SukiBackground">Transparent</Color>
<Color x:Key="SukiStrongBackground">#353535</Color>
<Color x:Key="SukiLightBackground">Transparent</Color>
<Color x:Key="SukiCardBackground">#292929</Color>
<Color x:Key="SukiCardBackground">#323232</Color>
<Color x:Key="SukiGlassCardBackground">#49aaaaaa</Color>
<Color x:Key="SukiGlassCardOpaqueBackground">#333333</Color>
<Color x:Key="SukiControlTouchBackground">#505050</Color>
Expand All @@ -24,10 +24,10 @@
<BoxShadows x:Key="SukiSwitchShadow">0 1 5 0 #555555</BoxShadows>
<BoxShadows x:Key="SukiSmallPopupShadow">0 0 4 1 #101010</BoxShadows>
<BoxShadows x:Key="SukiPopupShadow">1 1 14 1 #101010</BoxShadows>
<BoxShadows x:Key="SukiBigPopupShadow">1 1 15 0 #606060</BoxShadows>
<BoxShadows x:Key="SukiBigPopupShadow">1 4 17 0 #111111</BoxShadows>

<LinearGradientBrush x:Key="PopupGradientBrush" StartPoint="0%,0%" EndPoint="100%,100%">
<GradientStop Color="{DynamicResource SukiAccentColor10}" Offset="0"></GradientStop>
<GradientStop Color="{DynamicResource SukiAccentColor3}" Offset="0"></GradientStop>
<GradientStop Color="{DynamicResource SukiPrimaryColor10}" Offset="0.9"></GradientStop>

</LinearGradientBrush>
Expand All @@ -36,7 +36,9 @@
<system:Boolean x:Key="IsLight">False</system:Boolean>

<system:Double x:Key="GlassOpacity">0.18</system:Double>
<system:Double x:Key="GlassOpacityDark">0.18</system:Double>
<system:Double x:Key="GlassOpacityLight">0.57</system:Double>

<system:Double x:Key="ControlGlassOpacity">0.3</system:Double>
<system:Double x:Key="DiscreteControlGlassOpacity">0.17</system:Double>
<Color x:Key="ControlSukiGlassCardBackground">#49aaaaaa</Color>

</ResourceDictionary>
9 changes: 6 additions & 3 deletions SukiUI/ColorTheme/Light.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<BoxShadows x:Key="SukiSwitchShadow">0 1 5 0 #aaaaaa</BoxShadows>
<BoxShadows x:Key="SukiSmallPopupShadow">0 0 2 0 DimGray</BoxShadows>
<BoxShadows x:Key="SukiPopupShadow">1 1 8 0 LightGray</BoxShadows>
<BoxShadows x:Key="SukiBigPopupShadow">1 1 15 0 #dedede</BoxShadows>
<BoxShadows x:Key="SukiBigPopupShadow">1 4 17 0 #999999</BoxShadows>

<LinearGradientBrush x:Key="PopupGradientBrush" StartPoint="0%,0%" EndPoint="100%,100%">
<GradientStop Color="{DynamicResource SukiAccentColor5}" Offset="0"></GradientStop>
Expand All @@ -36,6 +36,9 @@
<system:Boolean x:Key="IsLight">True</system:Boolean>

<system:Double x:Key="GlassOpacity">0.42</system:Double>
<system:Double x:Key="GlassOpacityDark">0.3</system:Double>
<system:Double x:Key="GlassOpacityLight">0.42</system:Double>

<system:Double x:Key="ControlGlassOpacity">0.05</system:Double>
<system:Double x:Key="DiscreteControlGlassOpacity">0.4</system:Double>
<Color x:Key="ControlSukiGlassCardBackground">#fd111111</Color>

</ResourceDictionary>
52 changes: 47 additions & 5 deletions SukiUI/ColorTheme/NotificationColor.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
using Avalonia.Media;
using Avalonia;
using Avalonia.Media;
using Avalonia.Styling;

namespace SukiUI.ColorTheme;

public static class NotificationColor
{
public static readonly SolidColorBrush InfoIconForeground = new(Color.FromRgb(47,84,235));
public static readonly SolidColorBrush SuccessIconForeground = new(Color.FromRgb(56,158,13));
public static readonly SolidColorBrush WarningIconForeground = new(Color.FromRgb(240,140,22));
public static readonly SolidColorBrush ErrorIconForeground = new(Color.FromRgb(236,63,48));
public static readonly LinearGradientBrush InfoIconForeground = new LinearGradientBrush()
{
EndPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
StartPoint = new RelativePoint(1, 1, RelativeUnit.Relative),
GradientStops = new GradientStops()
{
new() { Color = Color.FromRgb(89,126,247), Offset = 0.3 },
new() { Color = Color.FromRgb(47,84,235), Offset = 1 },

}
};
public static readonly LinearGradientBrush SuccessIconForeground = new LinearGradientBrush()
{
EndPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
StartPoint = new RelativePoint(1, 1, RelativeUnit.Relative),
GradientStops = new GradientStops()
{
new() { Color = Color.FromRgb(82,196,26), Offset = 0.3 },
new() { Color = Color.FromRgb(56,158,13), Offset = 1 },

}
};
public static readonly LinearGradientBrush WarningIconForeground = new LinearGradientBrush()
{
EndPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
StartPoint = new RelativePoint(1, 1, RelativeUnit.Relative),
GradientStops = new GradientStops()
{
new() { Color = Color.FromRgb(255,169,64), Offset = 0.3 },
new() { Color = Color.FromRgb(250,140,22), Offset = 1 },

}
};
public static readonly LinearGradientBrush ErrorIconForeground = new LinearGradientBrush()
{
EndPoint = new RelativePoint(0, 0, RelativeUnit.Relative),
StartPoint = new RelativePoint(1, 1, RelativeUnit.Relative),
GradientStops = new GradientStops()
{
new() { Color = Color.FromRgb(255,77,79), Offset = 0.3 },
new() { Color = Color.FromRgb(245,34,45), Offset = 1 },

}
};
}
14 changes: 7 additions & 7 deletions SukiUI/Content/Shaders/Background/bubble.sksl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ vec3 blendOverlay(vec3 base, vec3 blend) {

vec3 blendOverlayDark(vec3 base, vec3 blend) {
vec3 result;
result.r = (base.r < 0.5) ? (4 * base.r * blend.r) : (3.5 - 2.0 * (3 - base.r) * (3.5 - blend.r));
result.g = (base.g < 0.5) ? (4 * base.g * blend.g) : (3.5 - 2.0 * (3 - base.g) * (3.5 - blend.g));
result.b = (base.b < 0.5) ? (4 * base.b * blend.b) : (3.5 - 2.0 * (3 - base.b) * (3.5 - blend.b));
result.r = (base.r < 0.5) ? (5 * base.r * blend.r) : (4 - 2.0 * (3 - base.r) * (4 - blend.r));
result.g = (base.g < 0.5) ? (5 * base.g * blend.g) : (4 - 2.0 * (3 - base.g) * (4 - blend.g));
result.b = (base.b < 0.5) ? (5 * base.b * blend.b) : (4 - 2.0 * (3 - base.b) * (4 - blend.b));
return mix(base, clamp(result, 0.0, 1.0), 0.5); // Mélange avec la couleur de base pour réduire l'assombrissement
}

Expand Down Expand Up @@ -66,16 +66,16 @@ vec4 main(vec2 fragCoord) {
float opacityLayer2 = 0.85 - (iDark / 2);


float iPrimaryOpacity = 1; // Exemple de nouvelle opacité pour iPrimary
float iPrimaryOpacity = 1.1;
if (iDark == 1) {
iPrimaryOpacity = 0.28;
iPrimaryOpacity = 0.52;
}
vec3 iPrimaryWithOpacity = iPrimary * iPrimaryOpacity;


float iAccentOpacity = 0.8;
float iAccentOpacity = 1;
if (iDark == 1) {
iAccentOpacity = 0.34;
iAccentOpacity = 0.9;
}
vec3 iAccentWithOpacity = iAccent * iAccentOpacity;

Expand Down
10 changes: 5 additions & 5 deletions SukiUI/Content/Shaders/Background/bubblestrong.sksl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ vec3 blendOverlay(vec3 base, vec3 blend) {

vec3 blendOverlayDark(vec3 base, vec3 blend) {
vec3 result;
result.r = (base.r < 0.5) ? (4 * base.r * blend.r) : (3.5 - 2.0 * (3 - base.r) * (3.5 - blend.r));
result.g = (base.g < 0.5) ? (4 * base.g * blend.g) : (3.5 - 2.0 * (3 - base.g) * (3.5 - blend.g));
result.b = (base.b < 0.5) ? (4 * base.b * blend.b) : (3.5 - 2.0 * (3 - base.b) * (3.5 - blend.b));
result.r = (base.r < 0.5) ? (5 * base.r * blend.r) : (4 - 2.0 * (3 - base.r) * (4 - blend.r));
result.g = (base.g < 0.5) ? (5 * base.g * blend.g) : (4 - 2.0 * (3 - base.g) * (4 - blend.g));
result.b = (base.b < 0.5) ? (5 * base.b * blend.b) : (4 - 2.0 * (3 - base.b) * (4 - blend.b));
return mix(base, clamp(result, 0.0, 1.0), 0.5); // Mélange avec la couleur de base pour réduire l'assombrissement
}

Expand Down Expand Up @@ -68,14 +68,14 @@ vec4 main(vec2 fragCoord) {

float iPrimaryOpacity = 1.1; // Exemple de nouvelle opacité pour iPrimary
if (iDark == 1) {
iPrimaryOpacity = 0.34;
iPrimaryOpacity = 0.52;
}
vec3 iPrimaryWithOpacity = iPrimary * iPrimaryOpacity;


float iAccentOpacity = 1;
if (iDark == 1) {
iAccentOpacity = 0.55;
iAccentOpacity = 0.9;
}
vec3 iAccentWithOpacity = iAccent * iAccentOpacity;

Expand Down
2 changes: 1 addition & 1 deletion SukiUI/Content/Shaders/Background/flat.sksl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
vec4 main(vec2 fragCoord) {

if(iDark == 1)
return vec4(iBase * 0.7, iAlpha);
return vec4(iBase * 1, iAlpha);

return vec4(iBase, iAlpha);
}
14 changes: 7 additions & 7 deletions SukiUI/Content/Shaders/Background/gradient.sksl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ vec3 blendOverlay(vec3 base, vec3 blend) {

vec3 blendOverlayDark(vec3 base, vec3 blend) {
vec3 result;
result.r = (base.r < 0.5) ? (4 * base.r * blend.r) : (3.5 - 2.0 * (3 - base.r) * (3.5 - blend.r));
result.g = (base.g < 0.5) ? (4 * base.g * blend.g) : (3.5 - 2.0 * (3 - base.g) * (3.5 - blend.g));
result.b = (base.b < 0.5) ? (4 * base.b * blend.b) : (3.5 - 2.0 * (3 - base.b) * (3.5 - blend.b));
result.r = (base.r < 0.5) ? (2 * base.r * blend.r) : (4 - 1.5 * (3 - base.r) * (4 - blend.r));
result.g = (base.g < 0.5) ? (2* base.g * blend.g) : (4 - 1.5 * (3 - base.g) * (4 - blend.g));
result.b = (base.b < 0.5) ? (2 * base.b * blend.b) : (4 - 1.5 * (3 - base.b) * (4 - blend.b));
return mix(base, clamp(result, 0.0, 1.0), 0.5); // Mélange avec la couleur de base pour réduire l'assombrissement
}

Expand Down Expand Up @@ -66,16 +66,16 @@ vec4 main(vec2 fragCoord) {
float opacityLayer2 = 0.85 - (iDark / 2);


float iPrimaryOpacity = 0.8; // Exemple de nouvelle opacité pour iPrimary
float iPrimaryOpacity = 0.2; // Exemple de nouvelle opacité pour iPrimary
if (iDark == 1) {
iPrimaryOpacity = 0.32;
iPrimaryOpacity = 0.4;
}
vec3 iPrimaryWithOpacity = iPrimary * iPrimaryOpacity;


float iAccentOpacity = 0;
float iAccentOpacity = 1;
if (iDark == 1) {
iAccentOpacity = 0;
iAccentOpacity = 2;
}
vec3 iAccentWithOpacity = iPrimary * iAccentOpacity;

Expand Down
31 changes: 30 additions & 1 deletion SukiUI/Controls/GlassMorphism/GlassCard.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
xmlns:suki="clr-namespace:SukiUI.Controls">
<ControlTheme x:Key="SukiGlassCardStyle" TargetType="suki:GlassCard">
<Setter Property="BorderBrush" Value="{DynamicResource GlassBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource SukiGlassCardBackground}" />
<Setter Property="Padding" Value="20" />
<Setter Property="Template">
<ControlTemplate>

<Panel Name="RootPanel" Opacity="0">
<Border Name="PART_BorderCard" RenderTransformOrigin="50%,50%"
Background="{DynamicResource SukiGlassCardBackground}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ClipToBounds="{TemplateBinding ClipToBounds}"
Expand Down Expand Up @@ -53,6 +54,29 @@
</Panel>
</ControlTemplate>
</Setter>


<Style Selector="^.Control">
<Setter Property="IsAnimated" Value="False"></Setter>
<Setter Property="Padding" Value="0"></Setter>
</Style>

<Style Selector="^.Discrete">
<Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
<Setter Property="Padding" Value="0"></Setter>
</Style>
<Style Selector="^.Control /template/ Border#PART_BorderCard">
<Setter Property="Background" Value="{DynamicResource ControlSukiGlassCardBackground}" />
<Setter Property="Opacity" Value="{DynamicResource ControlGlassOpacity}" />
</Style>

<Style Selector="^.Discrete /template/ Border#PART_BorderCard">
<Setter Property="Background" Value="{DynamicResource SukiGlassCardBackground}" />
<Setter Property="Opacity" Value="{DynamicResource DiscreteControlGlassOpacity}" />


</Style>

<Style Selector="^.Primary /template/ Border#PART_ClipBorder">
<Setter Property="BorderBrush" Value="{DynamicResource SukiAccentColor0}" />
</Style>
Expand All @@ -79,6 +103,11 @@
<Setter Property="Background" Value="{DynamicResource SukiPrimaryColor25}" />
</Style>

<Style Selector="^.PrimaryOpaque /template/ Border#PART_BorderCard">
<Setter Property="Opacity" Value="1"/>
<Setter Property="Background" Value="{DynamicResource SukiPrimaryColor}" />
</Style>

<Style Selector="^[IsVisible=True] /template/ Panel#RootPanel">
<Setter Property="Opacity" Value="1" />
</Style>
Expand Down
8 changes: 4 additions & 4 deletions SukiUI/Controls/GroupBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Style Selector="suki|GroupBox">
<Setter Property="Template">
<ControlTemplate>
<StackPanel>
<Grid RowDefinitions="Auto, Auto, *">
<ContentControl Margin="0,0,0,0" Content="{TemplateBinding Header}">
<ContentControl.Styles>
<Style Selector="TextBlock">
Expand All @@ -23,12 +23,12 @@
</ContentControl.Styles>
</ContentControl>

<Border Height="1"
<Border Grid.Row="1" Height="1"
Margin="0,10,0,10"
Background="{DynamicResource SukiControlBorderBrush}"
BorderThickness="0" />
<ContentControl Content="{TemplateBinding Content}" />
</StackPanel>
<ContentControl Grid.Row="2" Content="{TemplateBinding Content}" />
</Grid>
</ControlTemplate>
</Setter>
</Style>
Expand Down
4 changes: 2 additions & 2 deletions SukiUI/Controls/InfoBadge.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Height="400"
Margin="0,20,0,0"
Spacing="20">
<controls:InfoBadge Appearance="Info"
<controls:InfoBadge Appearance="Information"
CornerPosition="TopRight"
Header="Info">

Expand All @@ -34,7 +34,7 @@
IsDot="True">
<Button />
</controls:InfoBadge>
<controls:InfoBadge Appearance="Info"
<controls:InfoBadge Appearance="Information"
CornerPosition="TopRight"
Header="100"
Overflow="99">
Expand Down
14 changes: 7 additions & 7 deletions SukiUI/Controls/InfoBadge.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ public class InfoBadge: HeaderedContentControl
{
private Border? _badgeContainer;

public static readonly StyledProperty<NotificationType> AppearanceProperty =
AvaloniaProperty.Register<InfoBadge, NotificationType>(nameof(Appearance), NotificationType.Info);
public static readonly StyledProperty<Avalonia.Controls.Notifications.NotificationType> AppearanceProperty =
AvaloniaProperty.Register<InfoBadge, Avalonia.Controls.Notifications.NotificationType>(nameof(Appearance), Avalonia.Controls.Notifications.NotificationType.Information);

public NotificationType Appearance
public Avalonia.Controls.Notifications.NotificationType Appearance
{
get => GetValue(AppearanceProperty);
set
{
Background = value switch
{
NotificationType.Info => NotificationColor.InfoIconForeground,
NotificationType.Success => NotificationColor.SuccessIconForeground,
NotificationType.Warning => NotificationColor.WarningIconForeground,
NotificationType.Error => NotificationColor.ErrorIconForeground,
Avalonia.Controls.Notifications.NotificationType.Information => NotificationColor.InfoIconForeground,
Avalonia.Controls.Notifications.NotificationType.Success => NotificationColor.SuccessIconForeground,
Avalonia.Controls.Notifications.NotificationType.Warning => NotificationColor.WarningIconForeground,
Avalonia.Controls.Notifications.NotificationType.Error => NotificationColor.ErrorIconForeground,
_ => NotificationColor.InfoIconForeground
};

Expand Down
12 changes: 5 additions & 7 deletions SukiUI/Controls/InfoBar.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
using System.Windows.Input;
using Avalonia;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.Media;
using SukiUI.ColorTheme;
using SukiUI.Content;
using SukiUI.Enums;

namespace SukiUI.Controls;

public class InfoBar : ContentControl
{
public static readonly StyledProperty<NotificationType> SeverityProperty =
AvaloniaProperty.Register<InfoBar, NotificationType>(nameof(Severity), NotificationType.Info);
AvaloniaProperty.Register<InfoBar, NotificationType>(nameof(Severity), NotificationType.Information);

public NotificationType Severity
{
Expand All @@ -22,7 +20,7 @@ public NotificationType Severity
{
Icon = value switch
{
NotificationType.Info => Icons.InformationOutline,
NotificationType.Information => Icons.InformationOutline,
NotificationType.Success => Icons.Check,
NotificationType.Warning => Icons.AlertOutline,
NotificationType.Error => Icons.AlertOutline,
Expand All @@ -31,7 +29,7 @@ public NotificationType Severity

IconForeground = value switch
{
NotificationType.Info => NotificationColor.InfoIconForeground,
NotificationType.Information => NotificationColor.InfoIconForeground,
NotificationType.Success => NotificationColor.SuccessIconForeground,
NotificationType.Warning => NotificationColor.WarningIconForeground,
NotificationType.Error => NotificationColor.ErrorIconForeground,
Expand Down
Loading

0 comments on commit f064298

Please sign in to comment.