StyleGuide Sample 완료

This commit is contained in:
logonkhi
2026-01-13 20:39:45 +09:00
parent c8ff7b503d
commit ee86f93814
47 changed files with 20319 additions and 88 deletions

View File

@@ -3,6 +3,7 @@ using System;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.UIElements;
using UVC.UIToolkit.Common;
namespace UVC.UIToolkit
{
@@ -10,6 +11,37 @@ namespace UVC.UIToolkit
/// 알림 창 컴포넌트.
/// 화면 모서리에 표시되는 알림 메시지입니다.
/// </summary>
/// <example>
/// <para><b>C# 코드에서 사용:</b></para>
/// <code>
/// // 초기화 (root 설정 필요)
/// UTKNotification.Initialize(rootVisualElement);
///
/// // 기본 알림
/// UTKNotification.Show("알림", "새로운 메시지가 있습니다.");
///
/// // 타입별 알림
/// UTKNotification.ShowSuccess("성공", "저장되었습니다.");
/// UTKNotification.ShowError("오류", "실패했습니다.");
/// UTKNotification.ShowWarning("경고", "주의가 필요합니다.");
///
/// // 위치 설정
/// UTKNotification.Show("알림", "메시지", position: NotificationPosition.BottomRight);
///
/// // 액션 버튼 있는 알림
/// UTKNotification.Show("알림", "메시지", actions: new[] {
/// ("확인", () => Debug.Log("확인")),
/// ("취소", () => Debug.Log("취소"))
/// });
/// </code>
/// <para><b>UXML에서 사용:</b></para>
/// <code>
/// <ui:UXML xmlns:utk="UVC.UIToolkit">
/// <!-- Notification은 주로 C# 코드로 동적 생성합니다 -->
/// <utk:UTKNotification Title="알림" Message="메시지" Type="Info" />
/// </ui:UXML>
/// </code>
/// </example>
[UxmlElement]
public partial class UTKNotification : VisualElement, IDisposable
{
@@ -129,6 +161,14 @@ namespace UVC.UIToolkit
CreateUI();
SubscribeToThemeChanges();
// UXML에서 로드될 때 속성이 설정된 후 UI 갱신
RegisterCallback<AttachToPanelEvent>(_ =>
{
if (_titleLabel != null) _titleLabel.text = _title;
if (_messageLabel != null) _messageLabel.text = _message;
UpdateType();
});
}
public UTKNotification(string title, string message, NotificationType type = NotificationType.Info) : this()
@@ -210,14 +250,16 @@ namespace UVC.UIToolkit
_iconLabel = new Label { name = "icon" };
_iconLabel.AddToClassList("utk-notification__icon");
UTKMaterialIcons.ApplyIconStyle(_iconLabel, 20);
_header.Add(_iconLabel);
_titleLabel = new Label { name = "title" };
_titleLabel.AddToClassList("utk-notification__title");
_header.Add(_titleLabel);
_closeButton = new Button { name = "close-btn", text = "✕" };
_closeButton = new Button { name = "close-btn", text = UTKMaterialIcons.Close };
_closeButton.AddToClassList("utk-notification__close-btn");
UTKMaterialIcons.ApplyIconStyle(_closeButton, 16);
_closeButton.RegisterCallback<ClickEvent>(_ => Close());
_header.Add(_closeButton);
@@ -270,10 +312,10 @@ namespace UVC.UIToolkit
{
_iconLabel.text = _type switch
{
NotificationType.Success => "✓",
NotificationType.Warning => "⚠",
NotificationType.Error => "✕",
_ => ""
NotificationType.Success => UTKMaterialIcons.CheckCircle,
NotificationType.Warning => UTKMaterialIcons.Warning,
NotificationType.Error => UTKMaterialIcons.Error,
_ => UTKMaterialIcons.Info
};
}
}