From 735788969a0b25ba981f750571f5e1df90ec5e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Sun, 19 Oct 2025 16:33:19 +0200 Subject: [PATCH] =?UTF-8?q?Med=20Popups=20=20och=20nytt=20system=20f=C3=B6?= =?UTF-8?q?r=20sl=C3=A4ckning,=20men=20utan=20hantering=20av=20r=C3=A4tt?= =?UTF-8?q?=20popup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/PopupEventHub.cs | 7 ++++--- .../Services/Interfaces/IPopupEventHub.cs | 5 +++-- .../Services/PopupClosingEventArgs.cs | 11 +++++++++++ .../ViewModelClasses/InfoPopupViewModel.cs | 4 ++-- .../ViewModelClasses/ParticipantViewModel.cs | 12 ++++++++---- .../ViewModelClasses/RoundRunningViewModel.cs | 7 ++++++- 6 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 GreadyPoang.Services/Services/PopupClosingEventArgs.cs diff --git a/GreadyPoang.Services/Services/Implements/PopupEventHub.cs b/GreadyPoang.Services/Services/Implements/PopupEventHub.cs index 7a5683c..7926e7e 100644 --- a/GreadyPoang.Services/Services/Implements/PopupEventHub.cs +++ b/GreadyPoang.Services/Services/Implements/PopupEventHub.cs @@ -2,10 +2,11 @@ public class PopupEventHub : IPopupEventHub { - public event EventHandler? InfoPopupCloseRequested; + public event EventHandler? InfoPopupCloseRequested; - public void RaiseInfoPopupClose() + public void RaiseInfoPopupClose(string popupId) { - InfoPopupCloseRequested?.Invoke(this, EventArgs.Empty); + InfoPopupCloseRequested?.Invoke(this, new PopupCloseEventArgs(popupId)); } + } diff --git a/GreadyPoang.Services/Services/Interfaces/IPopupEventHub.cs b/GreadyPoang.Services/Services/Interfaces/IPopupEventHub.cs index e9ab6a6..019eadf 100644 --- a/GreadyPoang.Services/Services/Interfaces/IPopupEventHub.cs +++ b/GreadyPoang.Services/Services/Interfaces/IPopupEventHub.cs @@ -2,7 +2,8 @@ public interface IPopupEventHub { - event EventHandler? InfoPopupCloseRequested; + event EventHandler? InfoPopupCloseRequested; + + void RaiseInfoPopupClose(string popupId); - void RaiseInfoPopupClose(); } \ No newline at end of file diff --git a/GreadyPoang.Services/Services/PopupClosingEventArgs.cs b/GreadyPoang.Services/Services/PopupClosingEventArgs.cs new file mode 100644 index 0000000..143785c --- /dev/null +++ b/GreadyPoang.Services/Services/PopupClosingEventArgs.cs @@ -0,0 +1,11 @@ +namespace GreadyPoang.Services; + +public class PopupCloseEventArgs : EventArgs +{ + public string PopupId { get; } + + public PopupCloseEventArgs(string popupId) + { + PopupId = popupId; + } +} diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs index d45e3d8..51a33f3 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/InfoPopupViewModel.cs @@ -9,6 +9,7 @@ public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable { private readonly IPopupService _popupService; private readonly IPopupEventHub _popupEvent; + public string PopupId { get; } = Guid.NewGuid().ToString(); public event EventHandler ClosePopupRequested; @@ -30,7 +31,7 @@ public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable private async Task Cancel() { //await _popupService.ClosePopupAsync(Shell.Current); - _popupEvent.RaiseInfoPopupClose(); + _popupEvent.RaiseInfoPopupClose(PopupId); } [RelayCommand(CanExecute = nameof(CanSave))] @@ -46,5 +47,4 @@ public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable Message = (string)query[nameof(InfoPopupViewModel.Message)]; Name = (string)query[nameof(InfoPopupViewModel.Name)]; } - } diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs index 33a3e1d..f499934 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/ParticipantViewModel.cs @@ -35,12 +35,11 @@ public partial class ParticipantViewModel : BaseViewModel ParticipantObject = new Participant(); ParticipantList = new ObservableCollection(); IsSaveCommandEnabled = true; - _popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested; PopupVisad = false; + _popupEvent.InfoPopupCloseRequested += infoPopupViewModel_ClosePopupRequested; } - - #endregion + #endregion #region Private Variables [ObservableProperty] @@ -52,6 +51,7 @@ public partial class ParticipantViewModel : BaseViewModel private readonly IPopupService _popupService; private readonly IPopupEventHub _popupEvent; private readonly InfoPopupViewModel _infoPopupViewModel; + private string _activePopupId; #endregion @@ -176,8 +176,12 @@ public partial class ParticipantViewModel : BaseViewModel // _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; await _popupService.ClosePopupAsync(Shell.Current); } diff --git a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs index 6fcfac7..01e0e75 100644 --- a/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs +++ b/GreadyPoang.ViewModelLayer/ViewModelClasses/RoundRunningViewModel.cs @@ -60,6 +60,7 @@ public partial class RoundRunningViewModel : ObservableObject private Collection playerColumns; [ObservableProperty] private RoundBuilderElement builderObject; + private string _activePopupId; 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; await _popupService.ClosePopupAsync(Shell.Current); }