Tidy
This commit is contained in:
@@ -113,7 +113,7 @@ public partial class App : Application
|
||||
|
||||
services.AddTemplate<WalletNavigationViewModel, WalletNavigationView>();
|
||||
services.AddTemplate<AllNavigationViewModel, AllNavigationView>();
|
||||
services.AddTemplate<StarredNavigationViewModel, StarredNavigationView>();
|
||||
services.AddTemplate<FavouritesNavigationViewModel, FavouritesNavigationView>();
|
||||
services.AddTemplate<CategoriesNavigationViewModel, CategoriesNavigationView>();
|
||||
services.AddTemplate<CategoryNavigationViewModel, CategoryNavigationView>();
|
||||
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
<NavigationViewItem
|
||||
x:Class="Wallet.Avalonia.StarredNavigationView"
|
||||
x:Class="Wallet.Avalonia.FavouritesNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:StarredNavigationViewModel"
|
||||
Content="Starred"
|
||||
x:DataType="vm:FavouritesNavigationViewModel"
|
||||
Content="Favourites"
|
||||
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
@@ -0,0 +1,9 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Wallet.Avalonia;
|
||||
|
||||
public partial class FavouritesNavigationView :
|
||||
NavigationViewItem
|
||||
{
|
||||
public FavouritesNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Wallet.Avalonia;
|
||||
|
||||
public partial class StarredNavigationView : NavigationViewItem
|
||||
{
|
||||
public StarredNavigationView() => InitializeComponent();
|
||||
}
|
||||
@@ -76,6 +76,9 @@
|
||||
<Compile Update="ItemContentView.axaml.cs">
|
||||
<DependentUpon>ItemContentView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="FavouritesNavigationView.axaml.cs">
|
||||
<DependentUpon>FavouritesNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="TextEntryView.axaml.cs">
|
||||
<DependentUpon>TextEntryView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -22,7 +22,7 @@ public class ArchiveItemHandler(IDecoratorService<Item<(Guid, string)>> decorato
|
||||
bool>(new UpdateEventArgs<(Guid, int)>((id, 2)));
|
||||
|
||||
cache.Remove(item);
|
||||
publisher.Publish(Changed.As(item));
|
||||
publisher.Publish(Changed.As<Item>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
[Notification(typeof(NotifyEventArgs<Item<int>>), "Archive")]
|
||||
public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -11,15 +10,4 @@ public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
IDisposer disposer,
|
||||
int key,
|
||||
string value) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
INotificationHandler<NotifyEventArgs<Item<int>>>
|
||||
{
|
||||
public Task Handle(NotifyEventArgs<Item<int>> args)
|
||||
{
|
||||
if (args.Sender is Item<int> item)
|
||||
{
|
||||
Key = item.Value;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
INotificationHandler<NotifyEventArgs<Item<int>>>;
|
||||
@@ -1,14 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using Toolkit.Foundation;
|
||||
using Wallet.Data;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public class CountCategoriesHandler(IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
IHandler<CountEventArgs<ItemCategory>, IReadOnlyCollection<(string, int)>>
|
||||
IHandler<CountEventArgs<Item>, IReadOnlyCollection<(string, int)>>
|
||||
{
|
||||
public async Task<IReadOnlyCollection<(string, int)>> Handle(CountEventArgs<ItemCategory> args,
|
||||
public async Task<IReadOnlyCollection<(string, int)>> Handle(CountEventArgs<Item> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
using WalletContext context = await dbContextFactory.CreateDbContextAsync(cancellationToken);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class CreateItemViewModelHandler(IServiceFactory serviceFactory,
|
||||
|
||||
itemHeaderConfigurationDecorator.Set(configuration);
|
||||
|
||||
if (serviceFactory.Create<ItemViewModel>(args.Parameters) is ItemViewModel itemViewModel)
|
||||
if (serviceFactory.Create<ItemViewModel>(args => args.Initialize(), args.Parameters) is ItemViewModel itemViewModel)
|
||||
{
|
||||
itemViewModel.Add<ItemHeaderViewModel>(configuration, state, "", name);
|
||||
itemViewModel.Add<ItemContentViewModel>();
|
||||
|
||||
@@ -16,7 +16,7 @@ public class FavouriteItemHandler(IDecoratorService<Item<(Guid, string)>> decora
|
||||
(Guid id, string name) = item.Value;
|
||||
await mediator.Handle<UpdateEventArgs<(Guid, int)>, bool>(new UpdateEventArgs<(Guid, int)>((id, 1)));
|
||||
|
||||
publisher.Publish(Changed.As(item));
|
||||
publisher.Publish(Changed.As<Item>());
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -2,14 +2,11 @@
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class StarredNavigationViewModel(IServiceProvider provider,
|
||||
public partial class FavouritesNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
int key,
|
||||
string value) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
||||
{
|
||||
|
||||
}
|
||||
string value) : FilterNavigationViewModel(provider, factory, mediator, publisher, subscriber, disposer, key, value);
|
||||
@@ -4,12 +4,12 @@ namespace Wallet;
|
||||
|
||||
public class ItemChangedHandler(IMediator mediator,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ChangedEventArgs<Item<(Guid, string)>>>
|
||||
INotificationHandler<ChangedEventArgs<Item>>
|
||||
{
|
||||
public async Task Handle(ChangedEventArgs<Item<(Guid, string)>> args)
|
||||
public async Task Handle(ChangedEventArgs<Item> args)
|
||||
{
|
||||
IReadOnlyCollection<(string, int)>? categoryCounts = await mediator.Handle<CountEventArgs<ItemCategory>,
|
||||
IReadOnlyCollection<(string, int)>>(Count.As<ItemCategory>());
|
||||
IReadOnlyCollection<(string, int)>? categoryCounts = await mediator.Handle<CountEventArgs<Item>,
|
||||
IReadOnlyCollection<(string, int)>>(Count.As<Item>());
|
||||
|
||||
if (categoryCounts is { Count: > 0 } )
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ public class UnarchiveItemHandler(IDecoratorService<Item<(Guid, string)>> decora
|
||||
bool>(new UpdateEventArgs<(Guid, int)>((id, 0)));
|
||||
|
||||
cache.Add(item);
|
||||
publisher.Publish(Changed.As(item));
|
||||
publisher.Publish(Changed.As<Item>());
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -16,7 +16,7 @@ public class UnfavouriteItemHandler(IDecoratorService<Item<(Guid, string)>> deco
|
||||
(Guid id, string name) = item.Value;
|
||||
await mediator.Handle<UpdateEventArgs<(Guid, int)>, bool>(new UpdateEventArgs<(Guid, int)>((id, 0)));
|
||||
|
||||
publisher.Publish(Changed.As(item));
|
||||
publisher.Publish(Changed.As<Item>());
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -47,10 +47,12 @@ public partial class WalletNavigationViewModel :
|
||||
public Task Handle(OpenedEventArgs<Wallet> args)
|
||||
{
|
||||
Add<AllNavigationViewModel>("All", 0);
|
||||
Add<StarredNavigationViewModel>("Starred", 0);
|
||||
Add<FavouritesNavigationViewModel>("Favourites", 0);
|
||||
Add<ArchiveNavigationViewModel>("Archive", 0);
|
||||
Add<CategoriesNavigationViewModel>("Categories", 0);
|
||||
|
||||
Publisher.Publish(Changed.As<Item>());
|
||||
|
||||
Opened = true;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user