Med Popups och nytt system för släckning, men utan hantering av rätt popup
This commit is contained in:
@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
public class PopupEventHub : IPopupEventHub
|
public class PopupEventHub : IPopupEventHub
|
||||||
{
|
{
|
||||||
public event EventHandler? InfoPopupCloseRequested;
|
public event EventHandler<PopupCloseEventArgs>? InfoPopupCloseRequested;
|
||||||
|
|
||||||
public void RaiseInfoPopupClose()
|
public void RaiseInfoPopupClose(string popupId)
|
||||||
{
|
{
|
||||||
InfoPopupCloseRequested?.Invoke(this, EventArgs.Empty);
|
InfoPopupCloseRequested?.Invoke(this, new PopupCloseEventArgs(popupId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
public interface IPopupEventHub
|
public interface IPopupEventHub
|
||||||
{
|
{
|
||||||
event EventHandler? InfoPopupCloseRequested;
|
event EventHandler<PopupCloseEventArgs>? InfoPopupCloseRequested;
|
||||||
|
|
||||||
|
void RaiseInfoPopupClose(string popupId);
|
||||||
|
|
||||||
void RaiseInfoPopupClose();
|
|
||||||
}
|
}
|
||||||
11
GreadyPoang.Services/Services/PopupClosingEventArgs.cs
Normal file
11
GreadyPoang.Services/Services/PopupClosingEventArgs.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace GreadyPoang.Services;
|
||||||
|
|
||||||
|
public class PopupCloseEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public string PopupId { get; }
|
||||||
|
|
||||||
|
public PopupCloseEventArgs(string popupId)
|
||||||
|
{
|
||||||
|
PopupId = popupId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@ public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable
|
|||||||
{
|
{
|
||||||
private readonly IPopupService _popupService;
|
private readonly IPopupService _popupService;
|
||||||
private readonly IPopupEventHub _popupEvent;
|
private readonly IPopupEventHub _popupEvent;
|
||||||
|
public string PopupId { get; } = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
public event EventHandler ClosePopupRequested;
|
public event EventHandler ClosePopupRequested;
|
||||||
|
|
||||||
@ -30,7 +31,7 @@ public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable
|
|||||||
private async Task Cancel()
|
private async Task Cancel()
|
||||||
{
|
{
|
||||||
//await _popupService.ClosePopupAsync(Shell.Current);
|
//await _popupService.ClosePopupAsync(Shell.Current);
|
||||||
_popupEvent.RaiseInfoPopupClose();
|
_popupEvent.RaiseInfoPopupClose(PopupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(CanSave))]
|
[RelayCommand(CanExecute = nameof(CanSave))]
|
||||||
@ -46,5 +47,4 @@ public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable
|
|||||||
Message = (string)query[nameof(InfoPopupViewModel.Message)];
|
Message = (string)query[nameof(InfoPopupViewModel.Message)];
|
||||||
Name = (string)query[nameof(InfoPopupViewModel.Name)];
|
Name = (string)query[nameof(InfoPopupViewModel.Name)];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,12 +35,11 @@ public partial class ParticipantViewModel : BaseViewModel
|
|||||||
ParticipantObject = new Participant();
|
ParticipantObject = new Participant();
|
||||||
ParticipantList = new ObservableCollection<Participant>();
|
ParticipantList = new ObservableCollection<Participant>();
|
||||||
IsSaveCommandEnabled = true;
|
IsSaveCommandEnabled = true;
|
||||||
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
|
||||||
PopupVisad = false;
|
PopupVisad = false;
|
||||||
|
_popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Private Variables
|
#region Private Variables
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
@ -52,6 +51,7 @@ public partial class ParticipantViewModel : BaseViewModel
|
|||||||
private readonly IPopupService _popupService;
|
private readonly IPopupService _popupService;
|
||||||
private readonly IPopupEventHub _popupEvent;
|
private readonly IPopupEventHub _popupEvent;
|
||||||
private readonly InfoPopupViewModel _infoPopupViewModel;
|
private readonly InfoPopupViewModel _infoPopupViewModel;
|
||||||
|
private string _activePopupId;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -176,8 +176,12 @@ public partial class ParticipantViewModel : BaseViewModel
|
|||||||
// _popupService.ClosePopupAsync(Shell.Current).GetAwaiter().GetResult();
|
// _popupService.ClosePopupAsync(Shell.Current).GetAwaiter().GetResult();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private async void infoPopupViewModel_ClosePopupRequested(object? sender, EventArgs e)
|
private async void infoPopupViewModel_ClosePopupRequested(object? sender, PopupCloseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.PopupId != _activePopupId)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
PopupVisad = true;
|
PopupVisad = true;
|
||||||
await _popupService.ClosePopupAsync(Shell.Current);
|
await _popupService.ClosePopupAsync(Shell.Current);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,6 +60,7 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
private Collection<PlayerColumn> playerColumns;
|
private Collection<PlayerColumn> playerColumns;
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private RoundBuilderElement builderObject;
|
private RoundBuilderElement builderObject;
|
||||||
|
private string _activePopupId;
|
||||||
|
|
||||||
public bool PopupVisad { get; set; }
|
public bool PopupVisad { get; set; }
|
||||||
|
|
||||||
@ -195,8 +196,12 @@ public partial class RoundRunningViewModel : ObservableObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void infoPopupViewModel_ClosePopupRequested(object? sender, EventArgs e)
|
private async void infoPopupViewModel_ClosePopupRequested(object? sender, PopupCloseEventArgs e)
|
||||||
{
|
{
|
||||||
|
if (e.PopupId != _activePopupId)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
PopupVisad = true;
|
PopupVisad = true;
|
||||||
await _popupService.ClosePopupAsync(Shell.Current);
|
await _popupService.ClosePopupAsync(Shell.Current);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user