Skip to content

Commit

Permalink
Merge pull request #201 from AuroraZiling/main
Browse files Browse the repository at this point in the history
[Doc/Refactor] Update
  • Loading branch information
kikipoulet authored May 26, 2024
2 parents 77f1e1d + 14c3ffd commit e5affe2
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 37 deletions.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Documentation
description: Submit documentation suggestions to help improve
title: "[Doc] "
labels:
- Documentation
body:
- type: textarea
id: description
attributes:
label: Suggestion
description: Please describe in detail.
validations:
required: true
- type: textarea
id: additional
attributes:
label: Additional Information
description: Add any other context about the problem here
validations:
required: false
4 changes: 2 additions & 2 deletions SukiUI.Demo/Features/ControlsLibrary/MiscViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ 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.", ToastType.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.Info, "Update Now", () =>{SukiHost.CloseDialog();} ));
}

[RelayCommand]
private void OpenBoxError()
{
SukiHost.ShowMessageBox(new MessageBoxModel("Error", "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. ", ToastType.Error));
SukiHost.ShowMessageBox(new MessageBoxModel("Error", "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.Error));
}

[RelayCommand]
Expand Down
12 changes: 6 additions & 6 deletions SukiUI.Demo/Features/ControlsLibrary/Toasts/ToastsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,24 @@ private static Task ShowSingleStandardToast() =>

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

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

[RelayCommand]
private static Task ShowSuccessToast() =>
SukiHost.ShowToast("A Simple Toast", "This is the content of a success toast.", ToastType.Success);
SukiHost.ShowToast("A Simple Toast", "This is the content of a success toast.", NotificationType.Success);

[RelayCommand]
private static Task ShowWarningToast() =>
SukiHost.ShowToast("A Simple Toast", "This is the content of a warning toast.", ToastType.Warning);
SukiHost.ShowToast("A Simple Toast", "This is the content of a warning toast.", NotificationType.Warning);

[RelayCommand]
private static Task ShowErrorToast() =>
SukiHost.ShowToast("A Simple Toast", "This is the content of an error toast.", ToastType.Error);
SukiHost.ShowToast("A Simple Toast", "This is the content of an error toast.", NotificationType.Error);

[RelayCommand]
private static async Task ShowThreeInfoToasts()
Expand All @@ -52,7 +52,7 @@ private static async Task ShowThreeInfoToasts()
[RelayCommand]
private static Task ShowToastWithCallback()
{
return SukiHost.ShowToast("Click This Toast", "Click this toast to open a dialog.", ToastType.Info, TimeSpan.FromSeconds(15),
return SukiHost.ShowToast("Click This Toast", "Click this toast to open a dialog.", NotificationType.Info, TimeSpan.FromSeconds(15),
() => SukiHost.ShowDialog(
new TextBlock { Text = "You clicked the toast! - Click anywhere outside of this dialog to close." },
allowBackgroundClose: true));
Expand Down
24 changes: 12 additions & 12 deletions SukiUI/Controls/SukiHost.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ public static void ShowMessageBox(MessageBoxModel model, bool allowbackgroundclo
ActionButtonContent = model.ActionButtonContent,
Icon = model.Type switch
{
ToastType.Info => Icons.InformationOutline,
ToastType.Success => Icons.Check,
ToastType.Warning => Icons.AlertOutline,
ToastType.Error => Icons.AlertOutline,
NotificationType.Info => Icons.InformationOutline,
NotificationType.Success => Icons.Check,
NotificationType.Warning => Icons.AlertOutline,
NotificationType.Error => Icons.AlertOutline,
_ => Icons.InformationOutline
}
, Foreground = model.Type switch
{
ToastType.Info => SukiHost.GetGradient(Color.FromRgb(47,84,235)),
ToastType.Success => SukiHost.GetGradient(Color.FromRgb(82,196,26)),
ToastType.Warning => SukiHost.GetGradient(Color.FromRgb(240,140,22)),
ToastType.Error => SukiHost.GetGradient(Color.FromRgb(245,34,45)),
NotificationType.Info => 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)),
_ => SukiHost.GetGradient(Color.FromRgb(89,126,255))
}}, false, allowbackgroundclose);

Expand Down Expand Up @@ -257,11 +257,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, ToastType? type = ToastType.Info, TimeSpan? duration = null, Action? onClicked = null) =>
public static Task ShowToast(string title, object content, NotificationType? type = NotificationType.Info, TimeSpan? duration = null, Action? onClicked = null) =>
ShowToast(new ToastModel(
title,
content as Control ?? ViewLocator.TryBuild(content),
type ?? ToastType.Info,
type ?? NotificationType.Info,
duration ?? TimeSpan.FromSeconds(4),
onClicked));

Expand All @@ -275,12 +275,12 @@ public static Task ShowToast(string title, object content, ToastType? type = Toa
/// <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, ToastType? type = ToastType.Info, TimeSpan? duration = null,
public static Task ShowToast(Window window, string title, object content, NotificationType? type = NotificationType.Info, TimeSpan? duration = null,
Action? onClicked = null) =>
ShowToast(window, new ToastModel(
title,
content as Control ?? ViewLocator.TryBuild(content),
type ?? ToastType.Info,
type ?? NotificationType.Info,
duration ?? TimeSpan.FromSeconds(4),
onClicked));

Expand Down
16 changes: 8 additions & 8 deletions SukiUI/Controls/SukiToast.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,18 @@ public void Initialize(ToastModel model, SukiHost host)
}
Icon = model.Type switch
{
ToastType.Info => Icons.InformationOutline,
ToastType.Success => Icons.Check,
ToastType.Warning => Icons.AlertOutline,
ToastType.Error => Icons.AlertOutline,
NotificationType.Info => Icons.InformationOutline,
NotificationType.Success => Icons.Check,
NotificationType.Warning => Icons.AlertOutline,
NotificationType.Error => Icons.AlertOutline,
_ => Icons.InformationOutline
};
Foreground = model.Type switch
{
ToastType.Info => _infoIconForeground,
ToastType.Success => _successIconForeground,
ToastType.Warning => _warningIconForeground,
ToastType.Error => _errorIconForeground,
NotificationType.Info => _infoIconForeground,
NotificationType.Success => _successIconForeground,
NotificationType.Warning => _warningIconForeground,
NotificationType.Error => _errorIconForeground,
_ => _infoIconForeground
};
_onClickedCallback = model.OnClicked;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace SukiUI.Enums;

public enum ToastType
public enum NotificationType
{
Info,
Success,
Expand Down
4 changes: 2 additions & 2 deletions SukiUI/Models/MessageBoxModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

namespace SukiUI.Models
{
public readonly record struct MessageBoxModel(string Title, object Content, ToastType Type = ToastType.Info, string? ActionButtonContent = null,Action? ActionButton= null)
public readonly record struct MessageBoxModel(string Title, object Content, NotificationType Type = NotificationType.Info, string? ActionButtonContent = null,Action? ActionButton= null)
{
public string Title { get; } = Title;
public object Content { get; } = Content;
public ToastType Type { get; } = Type;
public NotificationType Type { get; } = Type;



Expand Down
4 changes: 2 additions & 2 deletions SukiUI/Models/ToastModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

namespace SukiUI.Models;

public readonly record struct ToastModel(string Title, object Content, ToastType Type = ToastType.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.Info, TimeSpan? Lifetime = null, Action? OnClicked = null, string? ActionButtonContent = null,Action? ActionButton= null)
{
public string Title { get; } = Title;
public object Content { get; } = Content;
public ToastType Type { get; } = Type;
public NotificationType Type { get; } = Type;
public TimeSpan? Lifetime { get; } = Lifetime ;
public Action? OnClicked { get; } = OnClicked;

Expand Down
4 changes: 4 additions & 0 deletions docs/docs/.vitepress/config/shared.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export const shared = defineConfig({
base: '/SukiUI/',
title: "SukiUI",

head: [
['link', { rel: 'icon', type: 'image/webp', href: '/suki.webp' }],
],

themeConfig: {
logo: { src: '/suki.webp', width: 24, height: 24 },
socialLinks: [
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/documentation/controls/navigation/sidemenu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SukiSideMenu

`SukiSideMenu` is the main navigation control used in SukiUI, similar to `NavigationView` in other libraries.
6 changes: 5 additions & 1 deletion docs/docs/documentation/index.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# test
# Documentation

Welcome to SukiUI's documentation site, where you can jump to related pages in the sidebar.

Feel free to submit [Github Issue](https://github.com/kikipoulet/SukiUI/issues/new/choose) for this document!
2 changes: 1 addition & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ layout: home
hero:
name: "SukiUI"
text: "A Desktop UI Library for Avalonia"
tagline: Modern, Simple, Animated
tagline: Flat, Simple, Animated
actions:
- theme: brand
text: 🚀 Get Started
Expand Down
6 changes: 5 additions & 1 deletion docs/docs/zh/documentation/index.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# test
# 文档

欢迎访问 SukiUI 的文档站,你可以在侧边栏跳转到相关网页。

欢迎反馈有关该文档的[问题](https://github.com/kikipoulet/SukiUI/issues/new/choose)
2 changes: 1 addition & 1 deletion docs/docs/zh/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ layout: home
hero:
name: "SukiUI"
text: "一个 Avalonia 控件库"
tagline: 现代,简单,灵动
tagline: 扁平,简单,灵动
actions:
- theme: brand
text: 🚀 开始
Expand Down

0 comments on commit e5affe2

Please sign in to comment.