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