wip
This commit is contained in:
@@ -25,8 +25,16 @@ public partial class App : Application
|
||||
public override async void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
IHost? host = DefaultHostBuilder.Create()
|
||||
.AddConfiguration<ContainerConfiguration>(args => args.Name = "Personal",
|
||||
"Vault:*")
|
||||
.AddConfiguration<ContainerConfiguration>("Locker:*")
|
||||
.AddConfiguration<ItemConfiguration>("Item:*")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Bank Account", "Item:Bank Account")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Credit Card", "Item:Credit Card")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Document", "Item:Document")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Driving Licence", "Item:Driving Licence")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Identity", "Item:Identity")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Login", "Item:Login")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Note", "Item:Note")
|
||||
.AddConfiguration<ItemConfiguration>(args => args.Name = "Password", "Item:Password")
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddAvalonia();
|
||||
@@ -37,6 +45,9 @@ public partial class App : Application
|
||||
services.AddTemplate<MainWindowViewModel, MainWindow>("MainWindow");
|
||||
}
|
||||
|
||||
services.AddScoped<IProxyService<IEnumerable<ItemConfiguration>>>(provider =>
|
||||
new ProxyService<IEnumerable<ItemConfiguration>>(provider.GetRequiredService<IEnumerable<ItemConfiguration>>()));
|
||||
|
||||
services.AddHandler<ContainerActivatedHandler>();
|
||||
|
||||
services.AddTransient<IContainerComponent>(provider => Component.Create<ContainerComponent>(provider, args =>
|
||||
@@ -48,6 +59,9 @@ public partial class App : Application
|
||||
|
||||
services.AddCache<Item>();
|
||||
|
||||
services.AddTransient(_ =>
|
||||
provider.GetRequiredService<IProxyService<IEnumerable<ItemConfiguration>>>());
|
||||
|
||||
services.AddTransient<IKeyGenerator, KeyGenerator>();
|
||||
services.AddTransient<IEncryptor, AesEncryptor>();
|
||||
services.AddTransient<IDecryptor, AesDecryptor>();
|
||||
@@ -87,15 +101,17 @@ public partial class App : Application
|
||||
services.AddScoped<ContainerViewModelConfiguration>();
|
||||
|
||||
services.AddTemplate<ContainerViewModel, ContainerView>("Container");
|
||||
services.AddTemplate<ContainerItemCollectionViewModel, ContainerItemCollectionView>("ContentItemCollection");
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
services.AddHandler<AggerateContainerItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<SearchContainerActionViewModel, SearchContainerActionView>();
|
||||
services.AddTemplate<ContainerHeaderViewModel, ContainerHeaderView>("ContainerHeader");
|
||||
|
||||
services.AddTemplate<CreateItemActionViewModel, CreateItemActionView>();
|
||||
services.AddTemplate<ContainerCategoryCollectionViewModel, ContainerCategoryCollectionView>("ContainerItemCategoryCollection");
|
||||
|
||||
services.AddHandler<AggerateContainerItemViewModelHandler>();
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("ContainerItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||
|
||||
services.AddHandler<AggerateContainerCategoryViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Main" Route="Container">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
@@ -25,8 +25,9 @@
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Left" Route="ContentItemCollection">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
</NavigateAction>
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -43,11 +43,14 @@
|
||||
<Compile Update="AddItemNavigationView.axaml.cs">
|
||||
<DependentUpon>AddItemNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ContainerCategoryCollectionView.axaml.cs">
|
||||
<DependentUpon>ContainerCategoryCollectionView.axaml</DependentUpon>
|
||||
<Compile Update="ItemCategoryNavigationView.axaml.cs">
|
||||
<DependentUpon>ItemCategoryNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ContainerItemCollectionView.axaml.cs">
|
||||
<DependentUpon>ContainerItemCollectionView.axaml</DependentUpon>
|
||||
<Compile Update="ItemCategoryCollectionView.axaml.cs">
|
||||
<DependentUpon>ItemCategoryCollectionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ItemCollectionView.axaml.cs">
|
||||
<DependentUpon>ItemCollectionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CreateItemActionView.axaml.cs">
|
||||
<DependentUpon>CreateItemActionView.axaml</DependentUpon>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
using FluentAvalonia.UI.Media.Animation;
|
||||
using Toolkit.UI.Avalonia;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerCategoryCollectionView :
|
||||
UserControl
|
||||
{
|
||||
public ContainerCategoryCollectionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -4,5 +4,6 @@ namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class CreateContainerNavigationView : SettingsExpander
|
||||
{
|
||||
public CreateContainerNavigationView() => InitializeComponent();
|
||||
public CreateContainerNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.ContainerItemCollectionView"
|
||||
x:Class="Bitvault.Avalonia.ItemCategoryCollectionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ContainerItemCollectionViewModel">
|
||||
x:DataType="vm:ItemCategoryCollectionViewModel">
|
||||
<ListBox
|
||||
Margin="2,-1,0,0"
|
||||
AutoScrollToSelectedItem="True"
|
||||
+2
-2
@@ -2,9 +2,9 @@ using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ContainerItemCollectionView :
|
||||
public partial class ItemCategoryCollectionView :
|
||||
UserControl
|
||||
{
|
||||
public ContainerItemCollectionView() =>
|
||||
public ItemCategoryCollectionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<ListBoxItem
|
||||
x:Class="Bitvault.Avalonia.ItemCategoryNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ItemCategoryNavigationViewModel"
|
||||
Content="{Binding Name}" />
|
||||
@@ -0,0 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ItemCategoryNavigationView : UserControl
|
||||
{
|
||||
public ItemCategoryNavigationView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.ContainerCategoryCollectionView"
|
||||
x:Class="Bitvault.Avalonia.ItemCollectionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ContainerCategoryCollectionViewModel">
|
||||
x:DataType="vm:ItemCollectionViewModel">
|
||||
<ListBox
|
||||
Margin="2,-1,0,0"
|
||||
AutoScrollToSelectedItem="True"
|
||||
@@ -0,0 +1,10 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class ItemCollectionView :
|
||||
UserControl
|
||||
{
|
||||
public ItemCollectionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Region="Left" Route="ContentItemCollection">
|
||||
<Parameter Key="Filter" Value="{Binding Filter}" />
|
||||
<Parameter Key="Transition" Value="FromRight" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
|
||||
@@ -2,18 +2,23 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateContainerCategoryViewModelHandler(IServiceFactory serviceFactory,
|
||||
public class AggerateContainerCategoryViewModelHandler(IProxyService<IEnumerable<ItemConfiguration>> proxyConfigurations,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemNavigationViewModel,
|
||||
ContainerViewModelConfiguration>>
|
||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<ItemNavigationViewModel,
|
||||
ContainerViewModelConfiguration> args)
|
||||
public Task Handle(AggerateEventArgs<ItemCategoryNavigationViewModel> args)
|
||||
{
|
||||
if (serviceFactory.Create<ItemNavigationViewModel>()
|
||||
is ItemNavigationViewModel viewModel)
|
||||
if (proxyConfigurations.Value is IEnumerable<ItemConfiguration> configurations)
|
||||
{
|
||||
publisher.Publish(Create.As(viewModel), nameof(ContainerCategoryCollectionViewModel));
|
||||
foreach (ItemConfiguration configuration in configurations)
|
||||
{
|
||||
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(configuration.Name)
|
||||
is ItemCategoryNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(viewModel), nameof(ItemCategoryCollectionViewModel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class AggerateContainerItemViewModelHandler(IMediator mediator,
|
||||
valueStore.Set(item);
|
||||
|
||||
cache.Add(item);
|
||||
publisher.Publish(Create.As(viewModel), nameof(ContainerItemCollectionViewModel));
|
||||
publisher.Publish(Create.As(viewModel), nameof(ItemCollectionViewModel));
|
||||
}
|
||||
|
||||
selected = false;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(nameof(ContainerCategoryCollectionViewModel))]
|
||||
public partial class ContainerCategoryCollectionViewModel :
|
||||
ObservableCollection<ItemNavigationViewModel>
|
||||
{
|
||||
public ContainerCategoryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ public class ContainerFactory(IComponentFactory componentFactory) :
|
||||
{
|
||||
public IComponentHost? Create(string name)
|
||||
{
|
||||
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Vault:{name}",
|
||||
if (componentFactory.Create<IContainerComponent, ContainerConfiguration>($"Locker:{name}",
|
||||
new ContainerConfiguration { Name = name }) is IComponentHost host)
|
||||
{
|
||||
return host;
|
||||
|
||||
@@ -37,5 +37,5 @@ public partial class FilterContainerNavigationViewModel : Observable,
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Filter(Filter)),
|
||||
nameof(ContainerItemCollectionViewModel));
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
[Aggerate(nameof(ItemCategoryCollectionViewModel))]
|
||||
public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableCollection<ItemCategoryNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private IContentTemplate template = template;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ItemCategoryNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
string name) :
|
||||
Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string name = name;
|
||||
}
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(nameof(ContainerItemCollectionViewModel))]
|
||||
public partial class ContainerItemCollectionViewModel :
|
||||
[Aggerate(nameof(ItemCollectionViewModel))]
|
||||
public partial class ItemCollectionViewModel :
|
||||
ObservableCollection<ItemNavigationViewModel>,
|
||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||
INotificationHandler<NotifyEventArgs<Search>>
|
||||
{
|
||||
private ContainerViewModelConfiguration configuration;
|
||||
|
||||
public ContainerItemCollectionViewModel(IServiceProvider provider,
|
||||
public ItemCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -17,5 +17,5 @@ public partial class SearchContainerActionViewModel(IServiceProvider provider,
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
|
||||
nameof(ContainerItemCollectionViewModel));
|
||||
nameof(ItemCollectionViewModel));
|
||||
}
|
||||
Reference in New Issue
Block a user