Files
egwcorelib/EgwCoreLib.Razor/CustomDialog_old.razor
T
2026-05-05 10:18:37 +02:00

47 lines
1.2 KiB
Plaintext

<div class="modal-overlay" style="@(_isVisible ? "display:flex;" : "display:none;")">
<div class="modal-box align-items-top">
<p>@Message</p>
<input @bind="UserInput" placeholder="Type here..." />
<div class="modal-buttons">
<button class="btn btn-sm btn-success" @onclick="Confirm">OK</button>
<button class="btn btn-sm btn-warning" @onclick="Cancel">Cancel</button>
</div>
</div>
</div>
@code {
private bool _isVisible;
private TaskCompletionSource<string?>? _tcs;
public string Message { get; set; } = "";
public string UserInput { get; set; } = "";
/// <summary>
/// Shows the prompt and waits for user input.
/// </summary>
public Task<string?> ShowAsync(string message, string defaultValue = "")
{
Message = message;
UserInput = defaultValue;
_isVisible = true;
StateHasChanged();
_tcs = new TaskCompletionSource<string?>();
return _tcs.Task;
}
private void Confirm()
{
_isVisible = false;
_tcs?.TrySetResult(UserInput);
}
private void Cancel()
{
_isVisible = false;
_tcs?.TrySetResult(null);
}
}