WIP
This commit is contained in:
@@ -2,4 +2,13 @@
|
||||
x:Class="Bitvault.Avalonia.AllNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Content="All" />
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:AllNavigationViewModel"
|
||||
Content="All"
|
||||
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
|
||||
@@ -12,23 +12,10 @@ namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
public override void Initialize() => AvaloniaXamlLoader.Load(this);
|
||||
|
||||
public override async void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
//var command = connection.CreateCommand();
|
||||
//command.CommandText = "SELECT quote($newPassword);";
|
||||
//command.Parameters.AddWithValue("$newPassword", "Test123");
|
||||
//var quotedNewPassword = (string)command.ExecuteScalar();
|
||||
|
||||
//command.CommandText = "PRAGMA rekey = " + quotedNewPassword;
|
||||
//command.Parameters.Clear();
|
||||
//command.ExecuteNonQuery();
|
||||
|
||||
|
||||
IHost? host = DefaultHostBuilder.Create()
|
||||
.AddConfiguration<VaultConfiguration>(args => args.Name = "Personal",
|
||||
"Vault:*")
|
||||
@@ -75,8 +62,14 @@ public partial class App : Application
|
||||
services.AddTemplate<CategoriesNavigationViewModel, CategoriesNavigationView>();
|
||||
services.AddTemplate<ArchiveNavigationViewModel, ArchiveNavigationView>();
|
||||
|
||||
services.AddTemplate<OpenVaultViewModel, OpenView>("OpenVault");
|
||||
|
||||
services.AddTemplate<VaultViewModel, VaultView>("Vault");
|
||||
services.AddTemplate<OpenVaultViewModel, OpenVaultView>("Open");
|
||||
services.AddHandler<VaultViewModelHandler>();
|
||||
|
||||
services.AddTemplate<LockerNavigationViewModel, LockerNavigationView>();
|
||||
|
||||
services.AddTemplate<VaultCommandViewModel, VaultCommandView>("VaultCommands");
|
||||
});
|
||||
})!);
|
||||
|
||||
@@ -87,7 +80,8 @@ public partial class App : Application
|
||||
services.AddInitializer<VaultCollectionInitializer>();
|
||||
|
||||
services.AddTemplate<MainViewModel, MainView>("Main");
|
||||
services.AddHandler<VaultNavigationViewModelHandler>();
|
||||
services.AddHandler<MainViewModelHandler>();
|
||||
|
||||
services.AddTransient<FooterViewModel>();
|
||||
|
||||
services.AddTemplate<ManageNavigationViewModel, ManageNavigationView>();
|
||||
|
||||
@@ -2,4 +2,13 @@
|
||||
x:Class="Bitvault.Avalonia.ArchiveNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Content="Archive" />
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ArchiveNavigationViewModel"
|
||||
Content="Archive"
|
||||
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
|
||||
@@ -32,11 +32,14 @@
|
||||
<ProjectReference Include="..\Toolkit\Toolkit.UI.Controls.Avalonia\Toolkit.UI.Controls.Avalonia.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="OpenVaultView.axaml.cs">
|
||||
<DependentUpon>OpenVaultView.axaml</DependentUpon>
|
||||
<Compile Update="OpenView.axaml.cs">
|
||||
<DependentUpon>OpenView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ManageNavigationView.axaml.cs">
|
||||
<DependentUpon>ManageNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="VaultNavigationView.axaml.cs">
|
||||
<DependentUpon>VaultNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
<ListBoxItem
|
||||
x:Class="Bitvault.Avalonia.LockerNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
Welcome to Avalonia!
|
||||
</ListBoxItem>
|
||||
@@ -0,0 +1,12 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia
|
||||
{
|
||||
public partial class LockerNavigationView : UserControl
|
||||
{
|
||||
public LockerNavigationView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class OpenVaultView : UserControl
|
||||
{
|
||||
public OpenVaultView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.OpenVaultView"
|
||||
x:Class="Bitvault.Avalonia.OpenView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class OpenView : UserControl
|
||||
{
|
||||
public OpenView() => InitializeComponent();
|
||||
}
|
||||
@@ -2,4 +2,14 @@
|
||||
x:Class="Bitvault.Avalonia.StarredNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Content="Starred" />
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:StarredNavigationViewModel"
|
||||
Content="Starred"
|
||||
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||
<Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<UserControl
|
||||
x:Class="Bitvault.Avalonia.VaultCommandView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
d:DesignHeight="450"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
Welcome to Avalonia!
|
||||
</UserControl>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
public partial class VaultCommandView : UserControl
|
||||
{
|
||||
public VaultCommandView() => InitializeComponent();
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="Open" />
|
||||
<NavigateAction Context="Main" Route="OpenVault" />
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior Binding="{Binding Opened}" Value="True">
|
||||
@@ -30,7 +30,7 @@
|
||||
<NavigateAction Context="Main" Route="Vault" />
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
<EventTriggerBehavior EventName="Tapped">
|
||||
<DataTriggerBehavior Binding="{Binding Selected}" Value="True">
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
@@ -39,7 +39,7 @@
|
||||
<ComparisonCondition LeftOperand="{Binding #NavigationViewItem.IsChildSelected}" RightOperand="False" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="Open" />
|
||||
<NavigateAction Context="Main" Route="OpenVault" />
|
||||
</ConditionAction>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
@@ -51,6 +51,6 @@
|
||||
</ConditionAction.Condition>
|
||||
<NavigateAction Context="Main" Route="Vault" />
|
||||
</ConditionAction>
|
||||
</EventTriggerBehavior>
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
</NavigationViewItem>
|
||||
|
||||
@@ -2,10 +2,45 @@
|
||||
x:Class="Bitvault.Avalonia.VaultView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
|
||||
<Grid ColumnDefinitions="1*, Auto, 2*">
|
||||
<ListBox Grid.Column="0" />
|
||||
<GridSplitter Grid.Column="1" />
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:VaultViewModel">
|
||||
<UserControl.Resources>
|
||||
<x:Double x:Key="ButtonWidth">40</x:Double>
|
||||
<x:Double x:Key="ButtonHeight">36</x:Double>
|
||||
<SolidColorBrush x:Key="ButtonBackground" Color="{DynamicResource SubtleFillColorTransparent}" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver" Color="{DynamicResource SubtleFillColorSecondary}" />
|
||||
<SolidColorBrush x:Key="ButtonBackgroundPressed" Color="{DynamicResource SubtleFillColorTertiary}" />
|
||||
</UserControl.Resources>
|
||||
<Grid ColumnDefinitions="1*,Auto,2*">
|
||||
<Grid Grid.Column="0" RowDefinitions="Auto,*">
|
||||
<Grid
|
||||
Height="40"
|
||||
Margin="0,4,0,0"
|
||||
ColumnDefinitions="*,Auto">
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
VerticalAlignment="Center"
|
||||
BorderThickness="0"
|
||||
Content=""
|
||||
FontFamily="{DynamicResource SymbolThemeFontFamily}"
|
||||
FontSize="16" />
|
||||
</Grid>
|
||||
<ListBox
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Margin="0,-1,0,0"
|
||||
ItemTemplate="{ReflectionBinding Template}"
|
||||
ItemsSource="{Binding}" />
|
||||
</Grid>
|
||||
<GridSplitter Grid.Column="1" Background="Transparent" />
|
||||
<Rectangle
|
||||
Grid.Column="1"
|
||||
Width="1"
|
||||
HorizontalAlignment="Center"
|
||||
Fill="{DynamicResource DividerStrokeColorDefaultBrush}"
|
||||
IsHitTestVisible="False" />
|
||||
<Frame Grid.Row="1" Grid.Column="2" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault.Avalonia;
|
||||
|
||||
[NavigationTarget("Header")]
|
||||
public partial class VaultView : UserControl
|
||||
{
|
||||
public VaultView() => InitializeComponent();
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AllNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IVaultNavigationViewModel;
|
||||
public partial class AllNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IVaultNavigationViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Changed.As(new VaultCategory("All")));
|
||||
}
|
||||
@@ -1,12 +1,21 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
public partial class ArchiveNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IVaultNavigationViewModel;
|
||||
IVaultNavigationViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Changed.As(new VaultCategory("Archive")));
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record Category
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
//using Microsoft.Extensions.Hosting;
|
||||
//using Toolkit.Foundation;
|
||||
|
||||
//namespace Bitvault;
|
||||
|
||||
//public class CreateVaultStorageHandler(IHostEnvironment environment,
|
||||
// IKeyGenerator generator,
|
||||
// IKeyDeriver deriver,
|
||||
// IEncryptor encryptor,
|
||||
// IDecryptor decryptor,
|
||||
// IDbContextFactory<VaultDbContext> dbContextFactory,
|
||||
// IWritableConfiguration<VaultConfiguration> writer) : IHandler<Create<VaultStorage>, bool>
|
||||
//{
|
||||
// public async Task<bool> Handle(Create<VaultStorage> args, CancellationToken cancellationToken)
|
||||
// {
|
||||
// if (args.Value is VaultStorage vault)
|
||||
// {
|
||||
// if (vault.Name is { Length: > 0 } name && vault.Password is { Length: > 0 } password)
|
||||
// {
|
||||
// byte[] salt = generator.Generate(16);
|
||||
// byte[] key = generator.Generate(32);
|
||||
|
||||
// byte[] derivedKey = deriver.DeriveKey(password, salt);
|
||||
|
||||
// byte[] encryptedKey = encryptor.Encrypt(key, derivedKey);
|
||||
// byte[] decryptedKey = decryptor.Decrypt(encryptedKey, derivedKey);
|
||||
|
||||
// Array.Clear(encryptedKey, 0, encryptedKey.Length);
|
||||
|
||||
// using VaultDbContext context = dbContextFactory.CreateDbContext();
|
||||
// context.Database.SetConnectionString($"Data Source={Path.Combine(environment.ContentRootPath, name)}.vault;Mode=ReadWriteCreate;Password={Convert.ToBase64String(decryptedKey)}");
|
||||
|
||||
// try
|
||||
// {
|
||||
// await context.Database.EnsureCreatedAsync(cancellationToken);
|
||||
// writer.Write(args =>
|
||||
// {
|
||||
// var f = args.Name;
|
||||
// });
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// Array.Clear(decryptedKey, 0, decryptedKey.Length);
|
||||
|
||||
// // Derive the key for encryption
|
||||
|
||||
// //byte[] encryptionKey = deriver.DeriveKey(password, salt);
|
||||
|
||||
// //// Derive the key for decryption
|
||||
// //byte[] decryptionKey = deriver.DeriveKey(password, salt);
|
||||
|
||||
// //// Compare keys to ensure they're the same
|
||||
// //bool areKeysEqual = encryptionKey.SequenceEqual(decryptionKey);
|
||||
|
||||
// ////byte[] derivedKey = deriver.DeriveKey(password, salt);
|
||||
// //string? encrypted = encryptor.Encrypt(password, derivedKey);
|
||||
|
||||
// //var storedSalt = Convert.ToBase64String(salt);
|
||||
|
||||
|
||||
// //byte[] derivedKey2 = deriver.DeriveKey(password, salt);
|
||||
|
||||
// //var d = decryptor.Decrypt(encrypted, derivedKey2);
|
||||
|
||||
// // Generate a hash
|
||||
// //string hash = hasher.HashPassword(password);
|
||||
|
||||
// //string[] parts = hash.Split(':');
|
||||
|
||||
// //// Store the salt only
|
||||
// //string storedSalt = parts[0];
|
||||
|
||||
// //// Use the hash as the password
|
||||
// //string storedHash = parts[1];
|
||||
|
||||
// //context.Database.SetConnectionString($"Data Source={Path.Combine(environment.ContentRootPath, name)}.vault;Mode=ReadWriteCreate;Password={storedHash}");
|
||||
// //await context.Database.EnsureCreatedAsync();
|
||||
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public record Document
|
||||
{
|
||||
public byte[]? Blob { get; set; }
|
||||
|
||||
public DocumentType Type { get; set; }
|
||||
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public enum DocumentType
|
||||
{
|
||||
Form,
|
||||
File
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record Form
|
||||
{
|
||||
public ICollection<FormEntry>? Entries { get; set;}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormEntry;
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormField : FormEntry
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public object? Value { get; set; }
|
||||
|
||||
public FormFieldType Type { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public enum FormFieldType
|
||||
{
|
||||
Attachments,
|
||||
Date,
|
||||
Masked,
|
||||
Note,
|
||||
Number,
|
||||
Options,
|
||||
Password,
|
||||
Phone,
|
||||
Text,
|
||||
Time,
|
||||
Url
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record FormGroup : FormEntry
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public ICollection<FormField>? Fields { get; set; }
|
||||
}
|
||||
+11
-1
@@ -8,4 +8,14 @@ public record Locker
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public int State { get; set; }
|
||||
|
||||
public ICollection<Tag>? Tags { get; }
|
||||
|
||||
public Category? Category { get; }
|
||||
|
||||
public ICollection<Document>? Documents { get; }
|
||||
}
|
||||
@@ -7,5 +7,9 @@ public class LockerNavigationViewModel(IServiceProvider provider,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer);
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultNavigationViewModelHandler(IPublisher publisher,
|
||||
public class MainViewModelHandler(IPublisher publisher,
|
||||
IVaultHostCollection vaults) :
|
||||
INotificationHandler<Enumerate<IMainNavigationViewModel>>
|
||||
{
|
||||
@@ -2,11 +2,33 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class ManageNavigationViewModel :
|
||||
ObservableViewModel,
|
||||
IMainNavigationViewModel
|
||||
public partial class ManageNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IMainNavigationViewModel;
|
||||
|
||||
public partial class VaultCommandViewModel : ObservableCollectionViewModel
|
||||
{
|
||||
public ManageNavigationViewModel(IServiceProvider provider,
|
||||
public VaultCommandViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
Add<SearchVaultCommandViewModel>();
|
||||
Add<CreateLockerCommandViewModel>();
|
||||
}
|
||||
}
|
||||
|
||||
public partial class SearchVaultCommandViewModel :
|
||||
ObservableCollectionViewModel
|
||||
{
|
||||
public SearchVaultCommandViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -14,4 +36,17 @@ public partial class ManageNavigationViewModel :
|
||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public partial class CreateLockerCommandViewModel :
|
||||
ObservableCollectionViewModel
|
||||
{
|
||||
public CreateLockerCommandViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,21 @@
|
||||
using Toolkit.Foundation;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class StarredNavigationViewModel(IServiceProvider provider,
|
||||
public partial class StarredNavigationViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
IVaultNavigationViewModel;
|
||||
IVaultNavigationViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool selected;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Changed.As(new VaultCategory("Starred")));
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class Tag
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Bitvault;
|
||||
|
||||
public record VaultCategory(string Name);
|
||||
@@ -2,12 +2,25 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultDbContext: DbContext
|
||||
public class VaultDbContext(DbContextOptions<VaultDbContext> options) :
|
||||
DbContext(options)
|
||||
{
|
||||
public DbSet<Category> Categories { get; set; }
|
||||
|
||||
public DbSet<Document> Documents { get; set; }
|
||||
|
||||
public DbSet<Locker> Lockers { get; set; }
|
||||
|
||||
public VaultDbContext(DbContextOptions<VaultDbContext> options): base(options)
|
||||
{
|
||||
public DbSet<Tag> Tags { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Locker>()
|
||||
.HasMany(x => x.Tags)
|
||||
.WithOne();
|
||||
|
||||
modelBuilder.Entity<Locker>()
|
||||
.HasMany(x => x.Documents)
|
||||
.WithOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultViewModel(IServiceProvider provider,
|
||||
[Notification(nameof(VaultViewModel))]
|
||||
public partial class VaultViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) :
|
||||
ObservableViewModel(provider, factory, mediator, publisher, subscriber, disposer);
|
||||
IDisposer disposer,
|
||||
IContentTemplate template) : ObservableCollectionViewModel<LockerNavigationViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class VaultViewModelHandler(IServiceFactory factory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<Enumerate<LockerNavigationViewModel>>
|
||||
{
|
||||
public async Task Handle(Enumerate<LockerNavigationViewModel> args,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
for (int i = 0; i < 5000; i++)
|
||||
{
|
||||
if (factory.Create<LockerNavigationViewModel>() is LockerNavigationViewModel viewModel)
|
||||
{
|
||||
await publisher.Publish(new Create<LockerNavigationViewModel>(viewModel),
|
||||
nameof(VaultViewModel), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user