// Toasts/UI/WBP_ToastContainer.ts import { WBP_Toast } from '#root/Toasts/UI/WBP_Toast.ts'; import { CreateWidget } from '#root/UE/CteateWidget.ts'; import { ESlateVisibility } from '#root/UE/ESlateVisibility.ts'; import { SystemLibrary } from '#root/UE/SystemLibrary.ts'; import type { Text } from '#root/UE/Text.ts'; import { UEArray } from '#root/UE/UEArray.ts'; import { UserWidget } from '#root/UE/UserWidget.ts'; import { VerticalBox } from '#root/UE/VerticalBox.ts'; import type { E_MessageType } from '#root/UI/Enums/E_MessageType.ts'; /** * Toast Container Widget * Manages layout and positioning of multiple toast notifications * Automatically stacks toasts vertically with proper spacing */ export class WBP_ToastContainer extends UserWidget { // ════════════════════════════════════════════════════════════════════════════════════════ // FUNCTIONS // ════════════════════════════════════════════════════════════════════════════════════════ /** * Create and add new toast to container * @param Message - Toast message text * @param Type - Toast type for styling * @returns Created toast widget reference * @category Toast Management */ public AddToast(Message: Text, Type: E_MessageType): WBP_Toast { const toast = CreateWidget(WBP_Toast); toast.InitializeToast(Message, Type); this.ToastVerticalBox.AddChild(toast); this.ChildToasts.Add(toast); return toast; } /** * Remove toast from container and hide it * @param Toast - Toast widget to remove * @category Toast Management */ public RemoveToast(Toast: WBP_Toast): void { if (SystemLibrary.IsValid(Toast)) { this.ChildToasts.Remove(Toast); Toast.SetVisibility(ESlateVisibility.Hidden); Toast.RemoveFromParent(); } } /** * Initialize container widget and add to viewport * @category Container Setup */ public InitializeContainer(): void { this.SetVisibility(ESlateVisibility.Visible); this.AddToViewport(); } // ════════════════════════════════════════════════════════════════════════════════════════ // VARIABLES // ════════════════════════════════════════════════════════════════════════════════════════ /** * Vertical layout container for automatic toast stacking * Handles spacing and positioning automatically * @category Layout */ private ToastVerticalBox = new VerticalBox(); /** * Array of managed child toast widgets * @category Container Management */ private ChildToasts: UEArray = new UEArray([]); }