Some refactoring

This commit is contained in:
TheXamlGuy
2024-06-09 22:41:58 +01:00
parent b5f125546f
commit be6924f49e
37 changed files with 204 additions and 107 deletions
+1 -1
View File
@@ -24,7 +24,7 @@
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="True" />
</ConditionalExpression>
</ConditionAction.Condition>
<NavigateAction Region="Left" Route="ContentItemCollection">
<NavigateAction Region="Left" Route="ItemCollection">
<Parameter Key="Filter" Value="{Binding Filter}" />
<Parameter Key="Transition" Value="FromRight" />
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
+6 -3
View File
@@ -120,12 +120,12 @@ public partial class App : Application
services.AddTemplate<OpenWalletViewModel, OpenWalletView>("OpenWallet");
services.AddScoped<WalletViewModelConfiguration>();
services.AddScoped<ItemCollectionConfiguration>();
services.AddTemplate<WalletViewModel, WalletView>("Wallet");
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ItemCollection");
services.AddHandler<SynchronizeItemViewModelHandler>();
services.AddHandler<SynchronizeItemCollectionViewModelHandler>();
services.AddTemplate<WalletHeaderViewModel, WalletHeaderView>("WalletHeader");
services.AddTemplate<BackActionViewModel, BackActionView>();
@@ -146,9 +146,12 @@ public partial class App : Application
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
services.AddTemplate<EmptyItemCollectionViewModel, EmptyItemCollectionView>("EmptyItemCollection");
services.AddScoped<IDecoratorService<ItemHeaderConfiguration>, DecoratorService<ItemHeaderConfiguration>>();
services.AddScoped<IDecoratorService<ItemConfiguration>, DecoratorService<ItemConfiguration>>();
services.AddTemplate<ItemViewModel, ItemView>("Item");
services.AddHandler<CreateItemViewModelHandler>("Item");
services.AddTemplate<ItemHeaderViewModel, ItemHeaderView>();
services.AddTemplate<ItemContentViewModel, ItemContentView>();
+1 -1
View File
@@ -24,7 +24,7 @@
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="True" />
</ConditionalExpression>
</ConditionAction.Condition>
<NavigateAction Region="Left" Route="ContentItemCollection">
<NavigateAction Region="Left" Route="ItemCollection">
<Parameter Key="Filter" Value="{Binding Filter}" />
<Parameter Key="Transition" Value="FromRight" />
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
@@ -5,4 +5,5 @@
xmlns:vm="using:Wallet"
x:DataType="vm:CategoriesNavigationViewModel"
Content="Categories"
MenuItemsSource="{Binding}" />
MenuItemsSource="{Binding}"
SelectsOnInvoked="False" />
+29 -1
View File
@@ -4,4 +4,32 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Wallet"
x:DataType="vm:CategoryNavigationViewModel"
Content="{Binding Filter}" />
Content="{Binding Filter}"
IsSelected="{Binding Selected}">
<Interaction.Behaviors>
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
<ConditionAction>
<ConditionAction.Condition>
<ConditionalExpression ForwardChaining="And">
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
</ConditionalExpression>
</ConditionAction.Condition>
<NavigateAction Region="Main" Route="Wallet">
<Parameter Key="Filter" Value="{Binding Filter}" />
</NavigateAction>
</ConditionAction>
<ConditionAction>
<ConditionAction.Condition>
<ConditionalExpression ForwardChaining="And">
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="True" />
</ConditionalExpression>
</ConditionAction.Condition>
<NavigateAction Region="Left" Route="ItemCollection">
<Parameter Key="Filter" Value="{Binding Filter}" />
<Parameter Key="Transition" Value="FromRight" />
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
</NavigateAction>
</ConditionAction>
</DataTriggerBehavior>
</Interaction.Behaviors>
</NavigationViewItem>
+2 -2
View File
@@ -14,11 +14,11 @@
Region="{Binding Named, StringFormat='{}{0}:Content'}"
Route="Item"
Scope="self">
<Parameter Key="FromCategory" Value="{x:False}" />
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
<Parameter Key="Name" Value="{Binding Name}" />
<Parameter Key="FromCategory" Value="{x:False}" />
<Parameter Key="Favourite" Value="{Binding Favourite}" />
<Parameter Key="Archived" Value="{Binding Archived}" />
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
<Parameter Key="NavigationStackEnabled" Value="{x:False}" />
</NavigateAction>
</AttachedEventTriggerBehaviour>
+1 -1
View File
@@ -24,7 +24,7 @@
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="True" />
</ConditionalExpression>
</ConditionAction.Condition>
<NavigateAction Region="Left" Route="ContentItemCollection">
<NavigateAction Region="Left" Route="ItemCollection">
<Parameter Key="Filter" Value="{Binding Filter}" />
<Parameter Key="Transition" Value="FromRight" />
<Parameter Key="NavigationStackEnabled" Value="{x:True}" />
+1 -1
View File
@@ -26,7 +26,7 @@
<Interaction.Behaviors>
<AttachedBehaviour>
<NavigateRegionAction Name="Left">
<NavigateAction Region="Left" Route="ContentItemCollection">
<NavigateAction Region="Left" Route="ItemCollection">
<Parameter Key="Filter" Value="{Binding Filter}" />
</NavigateAction>
</NavigateRegionAction>
+6 -3
View File
@@ -4,21 +4,24 @@ namespace Wallet;
public class ConfirmCreateItemHandler(IMediator mediator,
IDecoratorService<ItemConfiguration> itemConfigurationDecorator,
IDecoratorService<ItemHeaderConfiguration> itemHeaderConfiguration,
IPublisher publisher) :
INotificationHandler<ConfirmEventArgs<Item>>
{
public async Task Handle(ConfirmEventArgs<Item> args)
{
if (itemConfigurationDecorator.Service is ItemConfiguration configuration)
if (itemHeaderConfiguration.Service is ItemHeaderConfiguration headerConfiguration &&
itemConfigurationDecorator.Service is ItemConfiguration itemConfiguration)
{
string? name = await mediator.Handle<ConfirmEventArgs<ItemHeader>, string>(Confirm.As<ItemHeader>());
string? name = headerConfiguration?.Name;
if (name is not null)
{
Guid id = Guid.NewGuid();
publisher.Publish(Created.As(new Item<(Guid, string)>((id, name))));
await mediator.Handle<CreateEventArgs<(Guid, string, string,
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, string, ItemConfiguration)>((id, name, "", configuration)));
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, string,
ItemConfiguration)>((id, name, "", itemConfiguration)));
}
}
}
+6 -6
View File
@@ -4,18 +4,18 @@ namespace Wallet;
public class ConfirmUpdateItemHandler(IDecoratorService<Item<(Guid, string)>> itemDecorator,
IDecoratorService<ItemConfiguration> itemConfigurationDecorator,
IDecoratorService<ItemHeaderConfiguration> itemHeaderConfiguration,
IMediator mediator,
IPublisher publisher) :
INotificationHandler<ConfirmEventArgs<Item>>
{
public async Task Handle(ConfirmEventArgs<Item> args)
{
if (itemDecorator?.Service is Item<(Guid, string)> item &&
itemConfigurationDecorator.Service is ItemConfiguration configuration)
if (itemDecorator?.Service is Item<(Guid, string)> item &&
itemHeaderConfiguration.Service is ItemHeaderConfiguration headerConfiguration &&
itemConfigurationDecorator.Service is ItemConfiguration itemConfiguration)
{
string? name = await mediator.Handle<ConfirmEventArgs<ItemHeader>,
string>(Confirm.As<ItemHeader>());
string? name = headerConfiguration?.Name;
if (name is not null)
{
publisher.Publish(Notify.As(new ItemHeader<string>(name)));
@@ -28,7 +28,7 @@ public class ConfirmUpdateItemHandler(IDecoratorService<Item<(Guid, string)>> it
itemDecorator.Set(newItem);
await mediator.Handle<UpdateEventArgs<Item<(Guid, string, ItemConfiguration)>>, bool>(new UpdateEventArgs<Item<(Guid, string,
ItemConfiguration)>>(new Item<(Guid, string, ItemConfiguration)>((id, name, configuration))));
ItemConfiguration)>>(new Item<(Guid, string, ItemConfiguration)>((id, name, itemConfiguration))));
}
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ public class CreateItemHandler(IDbContextFactory<WalletContext> dbContextFactory
public async Task<bool> Handle(CreateEventArgs<(Guid, string, string, ItemConfiguration)> args,
CancellationToken cancellationToken)
{
if (args.Value is (Guid id, string name, string category, ItemConfiguration configuration))
if (args.Sender is (Guid id, string name, string category, ItemConfiguration configuration))
{
try
{
+43
View File
@@ -0,0 +1,43 @@
using System.Xml.Linq;
using Toolkit.Foundation;
namespace Wallet;
public class CreateItemViewModelHandler(IServiceFactory serviceFactory,
IDecoratorService<ItemHeaderConfiguration> itemHeaderConfigurationDecorator) :
IHandler<CreateEventArgs<ItemViewModel>, ItemViewModel?>
{
public Task<ItemViewModel?> Handle(CreateEventArgs<ItemViewModel> args,
CancellationToken cancellationToken)
{
string? name = "";
ItemState? state = null;
if (args.Parameters is { Length: 5 })
{
(name, bool _, bool _, bool _, state) = args.Parameters.CreateValueTuple<string, bool, bool, bool, ItemState>();
}
if (args.Parameters is { Length: 2 })
{
(bool _, state) = args.Parameters.CreateValueTuple<bool, ItemState>();
}
ItemHeaderConfiguration configuration = new()
{
Name = name
};
itemHeaderConfigurationDecorator.Set(configuration);
if (serviceFactory.Create<ItemViewModel>(args.Parameters) is ItemViewModel itemViewModel)
{
itemViewModel.Add<ItemHeaderViewModel>(configuration, state, "", name);
itemViewModel.Add<ItemContentViewModel>();
return Task.FromResult<ItemViewModel?>(itemViewModel);
}
return Task.FromResult(default(ItemViewModel));
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ public class CreateWalletHandler(IWalletFactory componentFactory,
public async Task<bool> Handle(CreateEventArgs<Wallet<(string, string)>> args,
CancellationToken cancellationToken)
{
if (args.Value is Wallet <(string, string)> Wallet)
if (args.Sender is Wallet <(string, string)> Wallet)
{
if (Wallet.Value is (string name, string password) &&
name is { Length: > 0 } &&
+1 -1
View File
@@ -8,7 +8,7 @@ public class DateEntryViewModelHandler(IServiceFactory serviceFactory) :
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<DateEntryConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Value is DateEntryConfiguration configuration)
if (args.Sender is DateEntryConfiguration configuration)
{
string? label = configuration.Label;
+1 -1
View File
@@ -8,7 +8,7 @@ public class DropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<DropdownEntryConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Value is DropdownEntryConfiguration configuration)
if (args.Sender is DropdownEntryConfiguration configuration)
{
List<DropdownValueViewModel> values = [];
foreach (string item in configuration.Values)
+2 -10
View File
@@ -1,5 +1,4 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Toolkit.Foundation;
namespace Wallet;
@@ -35,10 +34,6 @@ public partial class FilterNavigationViewModel :
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> :
@@ -46,7 +41,8 @@ public partial class FilterNavigationViewModel<TWalletNavigation> :
IWalletNavigationViewModel,
INotificationHandler<ActivatedEventArgs<Wallet>>,
INotificationHandler<DeactivatedEventArgs<Wallet>>
where TWalletNavigation : IWalletNavigationViewModel
where TWalletNavigation :
IWalletNavigationViewModel
{
[ObservableProperty]
private bool activated;
@@ -73,8 +69,4 @@ public partial class FilterNavigationViewModel<TWalletNavigation> :
public Task Handle(ActivatedEventArgs<Wallet> args) =>
Task.FromResult(Activated = true);
[RelayCommand]
public void Invoke() => Publisher.Publish(Notify.As(new Filter(Filter)),
nameof(ItemCollectionViewModel));
}
+7
View File
@@ -0,0 +1,7 @@
namespace Wallet;
public interface IItemViewModel :
IDisposable
{
}
@@ -1,6 +1,6 @@
namespace Wallet;
public record WalletViewModelConfiguration
public record ItemCollectionConfiguration
{
public string? Filter { get; set; } = "All";
+5 -5
View File
@@ -16,7 +16,7 @@ public partial class ItemCollectionViewModel :
[ObservableProperty]
public string? named;
private WalletViewModelConfiguration configuration;
private ItemCollectionConfiguration configuration;
public ItemCollectionViewModel(IServiceProvider provider,
IServiceFactory factory,
@@ -26,7 +26,7 @@ public partial class ItemCollectionViewModel :
IDisposer disposer,
IContentTemplate template,
NamedComponent named,
WalletViewModelConfiguration configuration,
ItemCollectionConfiguration configuration,
string? filter = null) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
Template = template;
@@ -39,7 +39,7 @@ public partial class ItemCollectionViewModel :
public Task Handle(NotifyEventArgs<Filter> args)
{
if (args.Value is Filter filter)
if (args.Sender is Filter filter)
{
configuration = configuration with { Filter = filter.Value };
Fetch(true);
@@ -50,7 +50,7 @@ public partial class ItemCollectionViewModel :
public Task Handle(NotifyEventArgs<Search<string>> args)
{
if (args.Value is Search<string> search)
if (args.Sender is Search<string> search)
{
configuration = configuration with { Query = search.Value };
Fetch(true);
@@ -71,5 +71,5 @@ public partial class ItemCollectionViewModel :
}
protected override SynchronizeExpression BuildAggregateExpression() =>
new(Synchronize.As<ItemNavigationViewModel, WalletViewModelConfiguration>(configuration));
new(Synchronize.As<ItemNavigationViewModel, ItemCollectionConfiguration>(configuration));
}
+8 -7
View File
@@ -16,16 +16,17 @@ public partial class ItemCommandHeaderViewModel(IServiceProvider provider,
public Task Handle(NotifyEventArgs<ItemCommandHeaderCollection> args)
{
Clear();
if (args.Value is ItemCommandHeaderCollection commandCollection)
if (args.Sender is ItemCommandHeaderCollection commandCollection)
{
foreach (IDisposable command in commandCollection)
Clear(args =>
{
Add(command);
}
foreach (IDisposable command in commandCollection)
{
args.Add(command);
}
});
}
return Task.CompletedTask;
}
}
+6 -6
View File
@@ -11,18 +11,18 @@ public partial class ItemContentViewModel(IServiceProvider provider,
IContentTemplate template) :
ObservableCollection<ItemSectionViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
IItemEntryViewModel,
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>,
IItemViewModel
{
public IContentTemplate Template { get; set; } = template;
public Task Handle(NotifyEventArgs<ItemCategory<string>> args)
{
if (args.Value is ItemCategory<string> category)
if (args.Sender is ItemCategory<string> category
&& category.Value is string value)
{
if (category.Value is string value)
{
Fetch(() => new SynchronizeExpression(new SynchronizeEventArgs<IItemEntryViewModel, string>(value)), true);
}
Fetch(() => new SynchronizeExpression(new SynchronizeEventArgs<IItemEntryViewModel,
string>(value)), true);
}
return Task.CompletedTask;
+1 -1
View File
@@ -10,7 +10,7 @@ public class ItemCreatedHandler(IServiceProvider serviceProvider,
{
public Task Handle(CreatedEventArgs<Item<(Guid, string)>> args)
{
if (args.Value is Item<(Guid, string)> item)
if (args.Sender is Item<(Guid, string)> item)
{
(Guid id, string name) = item.Value;
+1 -1
View File
@@ -2,4 +2,4 @@
public record ItemHeader<TValue>(TValue Value);
public record ItemHeader;
public record ItemHeader;
+6
View File
@@ -0,0 +1,6 @@
namespace Wallet;
public class ItemHeaderConfiguration
{
public string? Name { get; set; }
}
+16 -13
View File
@@ -8,10 +8,11 @@ public partial class ItemHeaderViewModel :
INotificationHandler<UpdateEventArgs<Item>>,
INotificationHandler<ConfirmEventArgs<Item>>,
INotificationHandler<CancelEventArgs<Item>>,
IHandler<ValidationEventArgs<ItemHeader>, bool>,
IHandler<ConfirmEventArgs<ItemHeader>, string?>,
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>,
IItemViewModel
{
private readonly ItemHeaderConfiguration configuration;
[ObservableProperty]
private string? category;
@@ -24,22 +25,19 @@ public partial class ItemHeaderViewModel :
IPublisher publisher,
ISubscription subscriber,
IDisposer disposer,
ItemHeaderConfiguration configuration,
ItemState state,
string key,
string value) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
{
this.configuration = configuration;
State = state;
Value = value;
Track(nameof(Value), () => Value, newValue => Value = newValue);
}
public Task<bool> Handle(ValidationEventArgs<ItemHeader> args,
CancellationToken cancellationToken)
{
return Task.FromResult(true);
}
public Task Handle(UpdateEventArgs<Item> args) =>
Task.FromResult(State = ItemState.Write);
@@ -51,6 +49,14 @@ public partial class ItemHeaderViewModel :
return Task.CompletedTask;
}
protected override void OnValueChanged()
{
if (configuration is not null)
{
configuration.Name = Value;
}
}
public Task Handle(ConfirmEventArgs<Item> args)
{
Commit();
@@ -61,14 +67,11 @@ public partial class ItemHeaderViewModel :
public Task Handle(NotifyEventArgs<ItemCategory<string>> args)
{
if (args.Value is ItemCategory<string> category)
if (args.Sender is ItemCategory<string> category)
{
Category = category.Value;
}
return Task.CompletedTask;
}
public Task<string> Handle(ConfirmEventArgs<ItemHeader> args,
CancellationToken cancellationToken) => Task.FromResult(Value);
}
+1 -1
View File
@@ -68,7 +68,7 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
public Task Handle(NotifyEventArgs<ItemHeader<string>> args)
{
if (args.Value is ItemHeader<string> header)
if (args.Sender is ItemHeader<string> header)
{
Name = header.Value;
}
+22 -21
View File
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
namespace Wallet;
public partial class ItemViewModel :
ObservableCollection,
ObservableCollection<IItemViewModel>,
INotificationHandler<ConfirmEventArgs<Item>>,
INotificationHandler<UpdateEventArgs<Item>>,
INotificationHandler<CancelEventArgs<Item>>
@@ -16,16 +16,16 @@ public partial class ItemViewModel :
private bool favourite;
[ObservableProperty]
private ItemState state;
[ObservableProperty]
private string named;
private bool fromCategory;
[ObservableProperty]
private string name;
[ObservableProperty]
private bool fromCategory;
private string named;
[ObservableProperty]
private ItemState state;
public ItemViewModel(IServiceProvider provider,
IServiceFactory factory,
@@ -35,11 +35,11 @@ public partial class ItemViewModel :
IDisposer disposer,
IContentTemplate template,
NamedComponent named,
ItemState state = ItemState.Read,
bool fromCategory = false,
string name = "",
bool fromCategory = false,
bool favourite = false,
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
bool archived = false,
ItemState state = ItemState.Read) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
Template = template;
Named = $"{named}";
@@ -48,13 +48,19 @@ public partial class ItemViewModel :
Favourite = favourite;
Archived = archived;
Name = name;
Add<ItemHeaderViewModel>("", name, state);
Add<ItemContentViewModel>();
}
public IContentTemplate Template { get; set; }
public override void Dispose()
{
GC.SuppressFinalize(this);
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new
List<IDisposable>())));
base.Dispose();
}
public Task Handle(UpdateEventArgs<Item> args)
{
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
@@ -67,14 +73,6 @@ public partial class ItemViewModel :
return Task.CompletedTask;
}
public override void Dispose()
{
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new
List<IDisposable>())));
base.Dispose();
}
public Task Handle(CancelEventArgs<Item> args)
{
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
@@ -95,7 +93,7 @@ public partial class ItemViewModel :
Factory.Create<EditItemActionViewModel>(),
Factory.Create<ArchiveItemActionViewModel>(),
})));
Publisher.Publish(Confirm.As<Item>(),
State is ItemState.New ? nameof(ItemState.New) : nameof(ItemState.Write));
@@ -135,4 +133,7 @@ public partial class ItemViewModel :
return base.OnActivated();
}
protected override SynchronizeExpression BuildAggregateExpression() =>
new(Synchronize.As<IItemViewModel, (string, string, ItemState)>(("", Name, State)));
}
+1 -1
View File
@@ -8,7 +8,7 @@ public class MaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<MaskedTextEntryConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Value is MaskedTextEntryConfiguration configuration)
if (args.Sender is MaskedTextEntryConfiguration configuration)
{
string? label = configuration.Label;
object? value = configuration.Value ?? "";
+1 -1
View File
@@ -8,7 +8,7 @@ public class MultilineTextEntryViewModelHandler(IServiceFactory serviceFactory)
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<MultilineTextEntryConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Value is MultilineTextEntryConfiguration configuration)
if (args.Sender is MultilineTextEntryConfiguration configuration)
{
string? label = configuration.Label;
object? value = configuration.Value ?? "";
+1 -1
View File
@@ -11,7 +11,7 @@ public class OpenWalletHandler(IConfigurationDescriptor<WalletConfiguration> des
public async Task<bool> Handle(ActivateEventArgs<Wallet<string>> args,
CancellationToken cancellationToken)
{
if (args.Value is Wallet<string> Wallet &&
if (args.Sender is Wallet<string> Wallet &&
descriptor.Name is { Length: > 0 } name &&
Wallet.Value is { Length: > 0 } password)
{
+1 -1
View File
@@ -8,7 +8,7 @@ public class PasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<PasswordEntryConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Value is PasswordEntryConfiguration configuration)
if (args.Sender is PasswordEntryConfiguration configuration)
{
string? label = configuration.Label;
object? value = configuration.Value ?? "";
+13 -4
View File
@@ -19,20 +19,29 @@ public class QueryWalletHandler(IDbContextFactory<WalletContext> dbContextFactor
ExpressionStarter<ItemEntry> predicate =
PredicateBuilder.New<ItemEntry>(true);
if (filter is { Length: <= 0 })
{
return items;
}
if (filter == "All")
{
predicate = predicate.And(x => x.State != 2);
}
if (filter == "Starred")
else if (filter == "Starred")
{
predicate = predicate.And(x => x.State != 2 && x.State == 1);
}
if (filter == "Archive")
else if (filter == "Archive")
{
predicate = predicate.And(x => x.State == 2);
}
else
{
predicate = predicate.And(x => x.State != 2)
.And(x => EF.Functions.Like(x.Category, $"%{filter}%"));
}
if (text is { Length: > 0 })
{
@@ -3,16 +3,16 @@ using Toolkit.Foundation;
namespace Wallet;
public class SynchronizeItemViewModelHandler(IMediator mediator,
public class SynchronizeItemCollectionViewModelHandler(IMediator mediator,
IServiceProvider serviceProvider,
ICache<Item<(Guid, string)>> cache,
IPublisher publisher) :
INotificationHandler<SynchronizeEventArgs<ItemNavigationViewModel, WalletViewModelConfiguration>>
INotificationHandler<SynchronizeEventArgs<ItemNavigationViewModel, ItemCollectionConfiguration>>
{
public async Task Handle(SynchronizeEventArgs<ItemNavigationViewModel,
WalletViewModelConfiguration> args)
ItemCollectionConfiguration> args)
{
if (args.Value is WalletViewModelConfiguration configuration)
if (args.Value is ItemCollectionConfiguration configuration)
{
cache.Clear();
bool selected = true;
@@ -4,7 +4,7 @@ using Toolkit.Foundation;
namespace Wallet;
public class SynchronizeItemContentFromCategoryViewModelHandler(IItemConfigurationCollection configurations,
IDecoratorService<ItemConfiguration> decoratorItemConfiguration,
IDecoratorService<ItemConfiguration> itemConfigurationDecorator,
IServiceFactory serviceFactory,
IMediator mediator,
IPublisher publisher) :
@@ -18,7 +18,7 @@ public class SynchronizeItemContentFromCategoryViewModelHandler(IItemConfigurati
{
if (configurationFactory.Invoke() is ItemConfiguration configuration)
{
decoratorItemConfiguration.Set(configuration);
itemConfigurationDecorator.Set(configuration);
foreach (ItemSectionConfiguration configurationSection in configuration.Sections)
{
string id = $"{nameof(ItemSection)}:{Guid.NewGuid()}";
+1 -1
View File
@@ -8,7 +8,7 @@ public class TextEntryViewModelHandler(IServiceFactory serviceFactory) :
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<TextEntryConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Value is TextEntryConfiguration configuration)
if (args.Sender is TextEntryConfiguration configuration)
{
string? label = configuration.Label;
object? value = configuration.Value ?? "";
+1 -1
View File
@@ -9,7 +9,7 @@ public class WalletActivatedHandler(IWalletHostCollection Wallets,
{
public Task Handle(ActivatedEventArgs<IComponentHost> args)
{
if (args.Value is IComponentHost Wallet)
if (args.Sender is IComponentHost Wallet)
{
List<IComponentHost> sortedWallets = [.. Wallets, Wallet];
sortedWallets = [.. sortedWallets.OrderBy(x => x.Services.GetRequiredService<IConfigurationDescriptor<WalletConfiguration>>() is
+1 -1
View File
@@ -18,7 +18,7 @@ public partial class WalletHeaderViewModel(IServiceProvider provider,
{
Clear();
if (args.Value is WalletCommandHeaderCollection commandCollection)
if (args.Sender is WalletCommandHeaderCollection commandCollection)
{
foreach (IDisposable command in commandCollection)
{