Manuális lezárás indokkal
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<toolkit:Popup xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
|
||||
xmlns:popups="clr-namespace:WorkFlowCheck.MAUI.Pages.System"
|
||||
x:Class="WorkFlowCheck.MAUI.Pages.System.InputPopup">
|
||||
|
||||
<toolkit:Popup.Resources>
|
||||
<Style TargetType="{x:Type popups:InputPopup}">
|
||||
<Setter Property="Size" Value="400,150" />
|
||||
<Setter Property="HorizontalOptions" Value="Center" />
|
||||
<Setter Property="VerticalOptions" Value="Start" />
|
||||
<Setter Property="CanBeDismissedByTappingOutsideOfPopup" Value="True" />
|
||||
</Style>
|
||||
</toolkit:Popup.Resources>
|
||||
<VerticalStackLayout Padding="20" Spacing="10">
|
||||
<Label x:Name="UserConfirmationLabel" />
|
||||
<Entry x:Name="UserInputEntry" />
|
||||
<HorizontalStackLayout HorizontalOptions="End" Spacing="10">
|
||||
<Button Text="Mégsem" Clicked="OnCancelClicked" />
|
||||
<Button Text="Megerősít" Clicked="OnOkClicked" />
|
||||
</HorizontalStackLayout>
|
||||
</VerticalStackLayout>
|
||||
|
||||
</toolkit:Popup>
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user