80 lines
2.4 KiB
C#
80 lines
2.4 KiB
C#
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Toolkit.Foundation;
|
|
|
|
namespace Wallet;
|
|
|
|
public partial class FilterNavigationViewModel :
|
|
ObservableCollection<IWalletNavigationViewModel>,
|
|
IWalletNavigationViewModel,
|
|
INotificationHandler<ActivatedEventArgs<Wallet>>,
|
|
INotificationHandler<DeactivatedEventArgs<Wallet>>
|
|
{
|
|
[ObservableProperty]
|
|
private bool activated;
|
|
|
|
[ObservableProperty]
|
|
private string? filter;
|
|
|
|
[ObservableProperty]
|
|
private bool selected;
|
|
|
|
public FilterNavigationViewModel(IServiceProvider provider,
|
|
IServiceFactory factory,
|
|
IMediator mediator,
|
|
IPublisher publisher,
|
|
ISubscription subscriber,
|
|
IDisposer disposer,
|
|
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
|
{
|
|
Filter = filter;
|
|
}
|
|
|
|
public Task Handle(DeactivatedEventArgs<Wallet> args) =>
|
|
Task.FromResult(Activated = false);
|
|
|
|
public Task Handle(ActivatedEventArgs<Wallet> args) =>
|
|
Task.FromResult(Activated = true);
|
|
|
|
[RelayCommand]
|
|
public void Invoke() => Publisher.Publish(Notify.As(new Filter(Filter)),
|
|
nameof(ItemCollectionViewModel));
|
|
}
|
|
|
|
public partial class FilterNavigationViewModel<TWalletNavigation> :
|
|
ObservableCollection<TWalletNavigation>,
|
|
IWalletNavigationViewModel,
|
|
INotificationHandler<ActivatedEventArgs<Wallet>>,
|
|
INotificationHandler<DeactivatedEventArgs<Wallet>>
|
|
where TWalletNavigation : IWalletNavigationViewModel
|
|
{
|
|
[ObservableProperty]
|
|
private bool activated;
|
|
|
|
[ObservableProperty]
|
|
private string? filter;
|
|
|
|
[ObservableProperty]
|
|
private bool selected;
|
|
|
|
public FilterNavigationViewModel(IServiceProvider provider,
|
|
IServiceFactory factory,
|
|
IMediator mediator,
|
|
IPublisher publisher,
|
|
ISubscription subscriber,
|
|
IDisposer disposer,
|
|
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
|
{
|
|
Filter = filter;
|
|
}
|
|
|
|
public Task Handle(DeactivatedEventArgs<Wallet> args) =>
|
|
Task.FromResult(Activated = false);
|
|
|
|
public Task Handle(ActivatedEventArgs<Wallet> args) =>
|
|
Task.FromResult(Activated = true);
|
|
|
|
[RelayCommand]
|
|
public void Invoke() => Publisher.Publish(Notify.As(new Filter(Filter)),
|
|
nameof(ItemCollectionViewModel));
|
|
} |