Manuális lezárás indokkal

This commit is contained in:
2025-05-23 10:49:02 +02:00
parent 84f161585a
commit 2318269f99
7 changed files with 186 additions and 0 deletions
@@ -0,0 +1,42 @@
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Views;
namespace WorkFlowCheck.MAUI.Pages.System;
public partial class InputPopup : Popup
{
private TaskCompletionSource<(bool IsConfirmed, string Result)> _taskCompletionSource;
public InputPopup(string userConfirmationLabel)
{
InitializeComponent();
_taskCompletionSource = new();
UserConfirmationLabel.Text = userConfirmationLabel;
this.Closed += OnPopupClosed;
}
public Task<(bool IsConfirmed, string Result)> ShowAsync()
{
Application.Current.MainPage.ShowPopup(this);
return _taskCompletionSource.Task;
}
private void OnOkClicked(object sender, EventArgs e)
{
Close((true, UserInputEntry.Text));
}
private void OnCancelClicked(object sender, EventArgs e)
{
Close((false, ""));
}
private void OnPopupClosed(object sender, PopupClosedEventArgs e)
{
if (e?.Result is ValueTuple<bool, string> value)
{
_taskCompletionSource.TrySetResult(value);
}
else
{
_taskCompletionSource.TrySetResult((false, null));
}
}
}