Skip to content

Commit

Permalink
Merge pull request #267 from AuroraZiling/main
Browse files Browse the repository at this point in the history
Docs & fix update
  • Loading branch information
kikipoulet authored Aug 10, 2024
2 parents ddec032 + b62d548 commit db083d6
Show file tree
Hide file tree
Showing 31 changed files with 252 additions and 53 deletions.
3 changes: 2 additions & 1 deletion SukiUI.Demo/Features/ControlsLibrary/MiscViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Controls.Notifications;
using Avalonia.Media;
using Avalonia.Platform.Storage;
using CommunityToolkit.Mvvm.ComponentModel;
Expand Down Expand Up @@ -32,7 +33,7 @@ private async Task ToggleBusy()
[RelayCommand]
private void OpenBox()
{
SukiHost.ShowMessageBox(new MessageBoxModel("Update Available", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", NotificationType.Info, "Update Now", () =>{SukiHost.CloseDialog();} ));
SukiHost.ShowMessageBox(new MessageBoxModel("Update Available", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", NotificationType.Information, "Update Now", () =>{SukiHost.CloseDialog();} ));
}

[RelayCommand]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.Input;
using Material.Icons;
using SukiUI.Controls;
Expand All @@ -18,11 +19,11 @@ private static Task ShowSingleStandardToast() =>

[RelayCommand]
private static Task ShowInfoToast() =>
SukiHost.ShowToast("A Simple Toast", "This is the content of an info toast.", NotificationType.Info);
SukiHost.ShowToast("A Simple Toast", "This is the content of an info toast.", NotificationType.Information);

[RelayCommand]
private static Task ShowActionToast() =>
SukiHost.ShowToast(new ToastModel("Update Available", "A new version is available for you.", NotificationType.Info, TimeSpan.FromSeconds(5), null, "Update Now",
SukiHost.ShowToast(new ToastModel("Update Available", "A new version is available for you.", NotificationType.Information, TimeSpan.FromSeconds(5), null, "Update Now",
() => { SukiHost.ShowToast("Update", new ProgressBar(){Value = 43, ShowProgressText = true});}));

[RelayCommand]
Expand All @@ -47,7 +48,7 @@ private static async Task ShowThreeInfoToasts()
[RelayCommand]
private static Task ShowToastWithCallback()
{
return SukiHost.ShowToast("Click This Toast", "Click this toast to open a dialog.", NotificationType.Info, TimeSpan.FromSeconds(15),
return SukiHost.ShowToast("Click This Toast", "Click this toast to open a dialog.", NotificationType.Information, TimeSpan.FromSeconds(15),
() => SukiHost.ShowDialog(
new TextBlock { Text = "You clicked the toast! - Click anywhere outside of this dialog to close." },
allowBackgroundClose: true));
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
5 changes: 3 additions & 2 deletions SukiUI/Controls/InfoBadge.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Notifications;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.Media;
Expand All @@ -13,7 +14,7 @@ public class InfoBadge: HeaderedContentControl
private Border? _badgeContainer;

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

public NotificationType Appearance
{
Expand All @@ -22,7 +23,7 @@ public NotificationType Appearance
{
Background = value switch
{
NotificationType.Info => NotificationColor.InfoIconForeground,
NotificationType.Information => NotificationColor.InfoIconForeground,
NotificationType.Success => NotificationColor.SuccessIconForeground,
NotificationType.Warning => NotificationColor.WarningIconForeground,
NotificationType.Error => NotificationColor.ErrorIconForeground,
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
19 changes: 7 additions & 12 deletions SukiUI/Controls/SukiHost.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Interactivity;
using Avalonia.Controls.Notifications;
using Avalonia.LogicalTree;
using Avalonia.Media;
using Avalonia.Rendering.Composition;
using Avalonia.Rendering.Composition.Animations;
using Avalonia.VisualTree;
using SukiUI.Content;

namespace SukiUI.Controls;
Expand All @@ -27,9 +25,6 @@ namespace SukiUI.Controls;
/// </summary>
public class SukiHost : ContentControl
{



protected override Type StyleKeyOverride => typeof(SukiHost);

public static readonly StyledProperty<bool> IsDialogOpenProperty =
Expand Down Expand Up @@ -172,15 +167,15 @@ public static void ShowMessageBox(MessageBoxModel model, bool allowbackgroundclo
ActionButtonContent = model.ActionButtonContent,
Icon = model.Type switch
{
NotificationType.Info => Icons.InformationOutline,
NotificationType.Information => Icons.InformationOutline,
NotificationType.Success => Icons.Check,
NotificationType.Warning => Icons.AlertOutline,
NotificationType.Error => Icons.AlertOutline,
_ => Icons.InformationOutline
}
, Foreground = model.Type switch
{
NotificationType.Info => SukiHost.GetGradient(Color.FromRgb(47,84,235)),
NotificationType.Information => SukiHost.GetGradient(Color.FromRgb(47,84,235)),
NotificationType.Success => SukiHost.GetGradient(Color.FromRgb(82,196,26)),
NotificationType.Warning => SukiHost.GetGradient(Color.FromRgb(240,140,22)),
NotificationType.Error => SukiHost.GetGradient(Color.FromRgb(245,34,45)),
Expand Down Expand Up @@ -273,11 +268,11 @@ public static Task ShowToast(ToastModel model) =>
/// <param name="type">The type of the toast, including Info, Success, Warning and Error</param>
/// <param name="duration">Duration for this toast to be active. Default is 2 seconds.</param>
/// <param name="onClicked">A callback that will be fired if the Toast is cleared by clicking.</param>
public static Task ShowToast(string title, object content, NotificationType? type = NotificationType.Info, TimeSpan? duration = null, Action? onClicked = null) =>
public static Task ShowToast(string title, object content, NotificationType? type = NotificationType.Information, TimeSpan? duration = null, Action? onClicked = null) =>
ShowToast(new ToastModel(
title,
content as Control ?? ViewLocator.TryBuild(content),
type ?? NotificationType.Info,
type ?? NotificationType.Information,
duration ?? TimeSpan.FromSeconds(4),
onClicked));

Expand All @@ -291,12 +286,12 @@ public static Task ShowToast(string title, object content, NotificationType? typ
/// <param name="type">The type of the toast, including Info, Success, Warning and Error</param>
/// <param name="duration">Duration for this toast to be active. Default is 2 seconds.</param>
/// <param name="onClicked">A callback that will be fired if the Toast is cleared by clicking.</param>
public static Task ShowToast(Window window, string title, object content, NotificationType? type = NotificationType.Info, TimeSpan? duration = null,
public static Task ShowToast(Window window, string title, object content, NotificationType? type = NotificationType.Information, TimeSpan? duration = null,
Action? onClicked = null) =>
ShowToast(window, new ToastModel(
title,
content as Control ?? ViewLocator.TryBuild(content),
type ?? NotificationType.Info,
type ?? NotificationType.Information,
duration ?? TimeSpan.FromSeconds(4),
onClicked));

Expand Down
5 changes: 3 additions & 2 deletions SukiUI/Controls/SukiToast.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using SukiUI.Models;
using System;
using System.Timers;
using Avalonia.Controls.Notifications;
using Avalonia.Interactivity;
using Avalonia.Media;
using SukiUI.ColorTheme;
Expand Down Expand Up @@ -114,15 +115,15 @@ public void Initialize(ToastModel model, SukiHost host)
}
Icon = model.Type switch
{
NotificationType.Info => Icons.InformationOutline,
NotificationType.Information => Icons.InformationOutline,
NotificationType.Success => Icons.Check,
NotificationType.Warning => Icons.AlertOutline,
NotificationType.Error => Icons.AlertOutline,
_ => Icons.InformationOutline
};
Foreground = model.Type switch
{
NotificationType.Info => NotificationColor.InfoIconForeground,
NotificationType.Information => NotificationColor.InfoIconForeground,
NotificationType.Success => NotificationColor.SuccessIconForeground,
NotificationType.Warning => NotificationColor.WarningIconForeground,
NotificationType.Error => NotificationColor.ErrorIconForeground,
Expand Down
9 changes: 0 additions & 9 deletions SukiUI/Enums/NotificationType.cs

This file was deleted.

3 changes: 2 additions & 1 deletion SukiUI/Models/MessageBoxModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using Avalonia.Controls.Notifications;
using SukiUI.Enums;

namespace SukiUI.Models
{
public readonly record struct MessageBoxModel(string Title, object Content, NotificationType Type = NotificationType.Info, string? ActionButtonContent = null,Action? ActionButton= null)
public readonly record struct MessageBoxModel(string Title, object Content, NotificationType Type = NotificationType.Information, string? ActionButtonContent = null,Action? ActionButton= null)
{
public string Title { get; } = Title;
public object Content { get; } = Content;
Expand Down
3 changes: 2 additions & 1 deletion SukiUI/Models/ToastModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System;
using Avalonia.Controls.Notifications;
using SukiUI.Enums;

namespace SukiUI.Models;

public readonly record struct ToastModel(string Title, object Content, NotificationType Type = NotificationType.Info, TimeSpan? Lifetime = null, Action? OnClicked = null, string? ActionButtonContent = null,Action? ActionButton= null)
public readonly record struct ToastModel(string Title, object Content, NotificationType Type = NotificationType.Information, TimeSpan? Lifetime = null, Action? OnClicked = null, string? ActionButtonContent = null,Action? ActionButton= null)
{
public string Title { get; } = Title;
public object Content { get; } = Content;
Expand Down
21 changes: 10 additions & 11 deletions SukiUI/Theme/HyperlinkButton.axaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<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">
<ControlTheme x:Key="SukiHyperlinkButtonStyle" TargetType="HyperlinkButton">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Background" Value="Transparent" />
Expand All @@ -21,30 +20,30 @@
<Setter Property="Template">
<ControlTemplate>
<ContentPresenter x:Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}"
RecognizesAccessKey="True"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
CornerRadius="{TemplateBinding CornerRadius}"
RecognizesAccessKey="True" />
</ControlTemplate>
</Setter>

<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Transitions">
<Transitions>
<BrushTransition Property="Foreground" Duration="{StaticResource ShortAnimationDuration}"/>
<BrushTransition Property="Foreground" Duration="{StaticResource ShortAnimationDuration}" />
</Transitions>
</Setter>
</Style>

<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource SukiPrimaryDarkColor}" />
<Setter Property="Foreground" Value="{DynamicResource SukiPrimaryColor50}" />
</Style>

<Style Selector="^:pressed">
Expand Down
4 changes: 2 additions & 2 deletions SukiUI/Theme/TimePickerStyle.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@

<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlHighBrush}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="TextElement.Foreground" Value="{TemplateBinding Foreground}" />
</Style>

<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background">
<SolidColorBrush Opacity="0.6" Color="{DynamicResource ThemeControlMidHighColor}" />
</Setter>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeControlLowBrush}" />
<Setter Property="TextElement.Foreground" Value="{DynamicResource ThemeForegroundBrush}" />
<Setter Property="TextElement.Foreground" Value="{TemplateBinding Foreground}" />
</Style>

<Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/.vitepress/config/en.mts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const en = defineConfig({
items: [
{ text: 'Calendar', link: '/documentation/controls/datetime/calendar' },
{ text: 'DatePicker', link: '/documentation/controls/datetime/datepicker' },
{ text: 'CalendarDatePicker', link: '/documentation/controls/datetime/calendardatepicker' },
{ text: 'TimePicker', link: '/documentation/controls/datetime/timepicker' },
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/.vitepress/config/zh.mts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const zh = defineConfig({
items: [
{ text: 'Calendar', link: '/zh/documentation/controls/datetime/calendar' },
{ text: 'DatePicker', link: '/zh/documentation/controls/datetime/datepicker' },
{ text: 'CalendarDatePicker', link: '/zh/documentation/controls/datetime/calendardatepicker' },
{ text: 'TimePicker', link: '/zh/documentation/controls/datetime/timepicker' },
]
},
{
Expand Down
17 changes: 17 additions & 0 deletions docs/docs/documentation/controls/datetime/calendar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Calendar

Controls for displaying date data

## Show

<img src="/controls/datetime/calendar.gif" height="300px" width="300px"/>

## Example

```xml
<Calendar SelectedDate="{Binding SelectedDateTime}" />
```

## See Also

[Demo: SukiUI.Demo/Features/ControlsLibrary/MiscView.axaml](https://github.com/kikipoulet/SukiUI/blob/main/SukiUI.Demo/Features/ControlsLibrary/MiscView.axaml)
17 changes: 17 additions & 0 deletions docs/docs/documentation/controls/datetime/calendardatepicker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CalendarDatePicker

Controls for picking date data

## Show

<img src="/controls/datetime/calendardatepicker.gif" height="300px" width="300px"/>

## Example

```xml
<CalendarDatePicker SelectedDate="{Binding SelectedDateTimeOffset}" />
```

## See Also

[Demo: SukiUI.Demo/Features/ControlsLibrary/MiscView.axaml](https://github.com/kikipoulet/SukiUI/blob/main/SukiUI.Demo/Features/ControlsLibrary/MiscView.axaml)
Loading

0 comments on commit db083d6

Please sign in to comment.