using CommunityToolkit.Maui; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using GreadyPoang.Services; namespace GreadyPoang.ViewModelLayer; public partial class InfoPopupViewModel : ObservableObject, IQueryAttributable { private readonly IPopupService _popupService; private readonly IPopupEventHub _popupEvent; public event EventHandler ClosePopupRequested; [ObservableProperty] private string title; [ObservableProperty] private string message; [ObservableProperty] private string name; public InfoPopupViewModel(IPopupService popupService, IPopupEventHub popupEvent) { _popupService = popupService; _popupEvent = popupEvent; } [RelayCommand] private async Task Cancel() { //await _popupService.ClosePopupAsync(Shell.Current); _popupEvent.RaiseInfoPopupClose(); } [RelayCommand(CanExecute = nameof(CanSave))] void OnSave() { } bool CanSave() => string.IsNullOrWhiteSpace(Name) is false; public void ApplyQueryAttributes(IDictionary query) { Title = (string)query[nameof(InfoPopupViewModel.Title)]; Message = (string)query[nameof(InfoPopupViewModel.Message)]; Name = (string)query[nameof(InfoPopupViewModel.Name)]; } }