Populate navigation caterogies

This commit is contained in:
TheXamlGuy
2024-06-09 15:36:52 +01:00
parent 3344762e6e
commit b5f125546f
15 changed files with 159 additions and 54 deletions
+80
View File
@@ -0,0 +1,80 @@
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));
}