Populate navigation caterogies
This commit is contained in:
@@ -8,4 +8,4 @@ public partial class AllNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string filter) : FilterWalletNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
string filter) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
@@ -8,4 +8,4 @@ public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterWalletNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
[Notification(typeof(CreateEventArgs<CategoryNavigationViewModel>), nameof(CategoriesNavigationViewModel))]
|
||||
public partial class CategoriesNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterWalletNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterNavigationViewModel<CategoryNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer, name)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class CategoryNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string filter) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, filter);
|
||||
@@ -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));
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class FilterWalletNavigationViewModel : Observable,
|
||||
IWalletNavigationViewModel,
|
||||
INotificationHandler<ActivatedEventArgs<Wallet>>,
|
||||
INotificationHandler<DeactivatedEventArgs<Wallet>>
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool activated;
|
||||
|
||||
[ObservableProperty]
|
||||
private string? filter;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
public FilterWalletNavigationViewModel(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));
|
||||
}
|
||||
@@ -8,4 +8,4 @@ public partial class StarredNavigationViewModel(IServiceProvider provider,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) : FilterWalletNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
string name) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, name);
|
||||
@@ -0,0 +1,23 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public class SynchronizeCategoriesNavigationViewModelHandler(IItemConfigurationCollection configurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<SynchronizeEventArgs<CategoryNavigationViewModel>>
|
||||
{
|
||||
public Task Handle(SynchronizeEventArgs<CategoryNavigationViewModel> args)
|
||||
{
|
||||
foreach (KeyValuePair<string, Func<ItemConfiguration>> configuration in configurations)
|
||||
{
|
||||
if (serviceFactory.Create<CategoryNavigationViewModel>(configuration.Key)
|
||||
is CategoryNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(viewModel), nameof(CategoriesNavigationViewModel));
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ public partial class WalletViewModel :
|
||||
|
||||
[ObservableProperty]
|
||||
private string filter;
|
||||
|
||||
public WalletViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
|
||||
Reference in New Issue
Block a user