// © 2025 Naked People Team. All Rights Reserved.


#include "ConfirmModalWidget.h"

#include "Components/Button.h"
#include "Components/TextBlock.h"

void UConfirmModalWidget::Setup(const FText& InTitle, const FText& InMessage)
{
	PendingTitle = InTitle;
	PendingMessage = InMessage;

	if (TitleText)
		TitleText->SetText(PendingTitle);
	if (MessageText)
		MessageText->SetText(PendingMessage);
}

void UConfirmModalWidget::NativeOnActivated()
{
	Super::NativeOnActivated();

	if (TitleText)
		TitleText->SetText(PendingTitle);
	if (MessageText)
		MessageText->SetText(PendingMessage);

	ConfirmButton->OnClicked.AddUniqueDynamic(this, &UConfirmModalWidget::HandleConfirmClicked);
	CancelButton->OnClicked.AddUniqueDynamic(this, &UConfirmModalWidget::HandleCancelClicked);
}

void UConfirmModalWidget::HandleConfirmClicked()
{
	OnConfirmed.Broadcast();
	DeactivateWidget();
}

void UConfirmModalWidget::HandleCancelClicked()
{
	OnCancelled.Broadcast();
	DeactivateWidget();
}