스타일 가이드 적용 완료. UTKCOlorPicker, UTKDatePicker 확인해야 함
This commit is contained in:
@@ -15,12 +15,13 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
#region Constants
|
||||
private const string USS_PATH = "UIToolkit/Modal/UTKToast";
|
||||
private const int DEFAULT_DURATION_MS = 3000;
|
||||
private const int DEFAULT_DURATION_MS = 1000;
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
private static VisualElement? _root;
|
||||
|
||||
private bool _disposed;
|
||||
private Label? _iconLabel;
|
||||
private Label? _messageLabel;
|
||||
private Button? _closeButton;
|
||||
|
||||
@@ -116,7 +117,78 @@ namespace UVC.UIToolkit
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static Factory
|
||||
#region Static Methods
|
||||
/// <summary>
|
||||
/// 기본 루트 요소 설정
|
||||
/// </summary>
|
||||
/// <param name="root">Toast를 표시할 기본 루트 요소</param>
|
||||
public static void SetRoot(VisualElement root)
|
||||
{
|
||||
_root = root;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 기본 루트 요소 반환
|
||||
/// </summary>
|
||||
public static VisualElement? GetRoot() => _root;
|
||||
|
||||
private static void ValidateRoot()
|
||||
{
|
||||
if (_root == null)
|
||||
{
|
||||
throw new InvalidOperationException("UTKToast.SetRoot()를 먼저 호출하여 기본 루트 요소를 설정해야 합니다.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static Factory (without parent)
|
||||
/// <summary>
|
||||
/// Info 토스트 표시 (SetRoot로 설정된 루트 사용)
|
||||
/// </summary>
|
||||
public static UTKToast ShowInfo(string message, int duration = DEFAULT_DURATION_MS)
|
||||
{
|
||||
ValidateRoot();
|
||||
return Show(_root!, message, ToastType.Info, duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Success 토스트 표시 (SetRoot로 설정된 루트 사용)
|
||||
/// </summary>
|
||||
public static UTKToast ShowSuccess(string message, int duration = DEFAULT_DURATION_MS)
|
||||
{
|
||||
ValidateRoot();
|
||||
return Show(_root!, message, ToastType.Success, duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Warning 토스트 표시 (SetRoot로 설정된 루트 사용)
|
||||
/// </summary>
|
||||
public static UTKToast ShowWarning(string message, int duration = DEFAULT_DURATION_MS)
|
||||
{
|
||||
ValidateRoot();
|
||||
return Show(_root!, message, ToastType.Warning, duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Error 토스트 표시 (SetRoot로 설정된 루트 사용)
|
||||
/// </summary>
|
||||
public static UTKToast ShowError(string message, int duration = DEFAULT_DURATION_MS)
|
||||
{
|
||||
ValidateRoot();
|
||||
return Show(_root!, message, ToastType.Error, duration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 토스트 표시 (SetRoot로 설정된 루트 사용)
|
||||
/// </summary>
|
||||
public static UTKToast Show(string message, ToastType type = ToastType.Info, int duration = DEFAULT_DURATION_MS)
|
||||
{
|
||||
ValidateRoot();
|
||||
return Show(_root!, message, type, duration);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static Factory (with parent)
|
||||
/// <summary>
|
||||
/// Info 토스트 표시
|
||||
/// </summary>
|
||||
@@ -180,10 +252,6 @@ namespace UVC.UIToolkit
|
||||
{
|
||||
AddToClassList("utk-toast");
|
||||
|
||||
_iconLabel = new Label { name = "icon" };
|
||||
_iconLabel.AddToClassList("utk-toast__icon");
|
||||
Add(_iconLabel);
|
||||
|
||||
_messageLabel = new Label { name = "message" };
|
||||
_messageLabel.AddToClassList("utk-toast__message");
|
||||
Add(_messageLabel);
|
||||
@@ -228,17 +296,6 @@ namespace UVC.UIToolkit
|
||||
_ => "utk-toast--info"
|
||||
};
|
||||
AddToClassList(typeClass);
|
||||
|
||||
if (_iconLabel != null)
|
||||
{
|
||||
_iconLabel.text = _type switch
|
||||
{
|
||||
ToastType.Success => "✓",
|
||||
ToastType.Warning => "⚠",
|
||||
ToastType.Error => "✕",
|
||||
_ => "ℹ"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private async UniTaskVoid AutoCloseAsync(int delayMs)
|
||||
|
||||
Reference in New Issue
Block a user