This commit is contained in:
TheXamlGuy
2024-05-24 08:21:49 +01:00
parent e82fa8d05f
commit 12d1392207
90 changed files with 146 additions and 168 deletions
+7 -7
View File
@@ -1,16 +1,16 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Bitvault.Data;
using HotAvalonia;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using Toolkit.Avalonia;
using Toolkit.Foundation;
using Microsoft.Extensions.DependencyInjection.Extensions;
using HotAvalonia;
using Bitvault.Data;
using System.Collections.Generic;
using System;
namespace Bitvault.Avalonia;
@@ -39,7 +39,7 @@ public partial class App : Application
services.AddHandler<ContainerActivatedHandler>();
services.AddTransient<IContainerComponent> (provider => Component.Create<ContainerComponent>(provider, args =>
services.AddTransient<IContainerComponent>(provider => Component.Create<ContainerComponent>(provider, args =>
{
args.AddServices(services =>
{
@@ -121,7 +121,7 @@ public partial class App : Application
});
})!);
services.AddTransient<IContainerFactory, ContainerFactory>();
services.AddTransient<IContainerFactory, ContainerFactory>();
services.AddHandler<CreateContainerHandler>();
services.AddSingleton<IContainerHostCollection, ContainerHostCollection>();
+4 -4
View File
@@ -21,11 +21,11 @@
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.999-cibuild0048140-alpha" />
<PackageReference Include="Avalonia.Labs.Controls" Version="11.0.10.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview1" />
<PackageReference Include="System.Reactive" Version="6.0.1-preview.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.1.0-preview5" />
<PackageReference Include="System.Reactive" Version="6.0.1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0-beta2.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.3.24172.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.3.24172.4">
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.4.24266.19" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.4.24267.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
+5 -2
View File
@@ -29,7 +29,7 @@
AutoScrollToSelectedItem="True"
ItemTemplate="{ReflectionBinding Template}"
ItemsSource="{Binding}"
SelectedItem="{Binding SelectedItem}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
SelectionMode="Single">
<ListBox.Styles>
<Style Selector="ListBoxItem">
@@ -52,7 +52,10 @@
BorderThickness="1,1,0,0"
CornerRadius="8 0 0 0">
<Grid RowDefinitions="Auto, *">
<Border Grid.Row="0" Padding="4" Height="44">
<Border
Grid.Row="0"
Height="44"
Padding="4">
<ContentControl>
<Interaction.Behaviors>
<AttachedBehaviour>
+1 -1
View File
@@ -4,7 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Bitvault"
x:DataType="vm:ItemNavigationViewModel"
IsSelected="{Binding Selected}">
IsSelected="{Binding Selected, Mode=TwoWay}">
<ListBoxItem.Resources>
<SolidColorBrush x:Key="StarredIconForegroundBrush" Color="#FFEDB120" />
</ListBoxItem.Resources>
+4 -4
View File
@@ -5,13 +5,13 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.3.24172.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.3.24172.4">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.4.24267.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.4.24267.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="9.0.0-preview.3.24172.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.3.24172.4">
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="9.0.0-preview.4.24267.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-preview.4.24267.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
-1
View File
@@ -28,7 +28,6 @@ public class ArchiveItemHandler(IValueStore<Item> valueStore,
}
catch
{
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="8.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.3.24172.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0-preview.4.24267.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Bitvault.Data\Bitvault.Data.csproj" />
-1
View File
@@ -7,6 +7,5 @@ public class CommandCollection :
{
public CommandCollection(IList<IDisposable> list) : base(list)
{
}
}
-1
View File
@@ -10,7 +10,6 @@ public partial class ConfirmItemActionViewModel(IServiceProvider provider,
ISubscription subscriber,
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
{
[RelayCommand]
public void Invoke() => Publisher.Publish(Confirm.As<Item>());
}
+1 -1
View File
@@ -12,7 +12,7 @@ public class ContainerActivatedHandler(IContainerHostCollection containers,
if (args.Value is IComponentHost container)
{
List<IComponentHost> sortedContainers = [.. containers, container];
sortedContainers = [.. sortedContainers.OrderBy(x => x.GetConfiguration< ContainerConfiguration>() is ContainerConfiguration configuration ? configuration.Name : null)];
sortedContainers = [.. sortedContainers.OrderBy(x => x.GetConfiguration<ContainerConfiguration>() is ContainerConfiguration configuration ? configuration.Name : null)];
int index = sortedContainers.IndexOf(container);
-1
View File
@@ -28,7 +28,6 @@ public class ContainerStorageFactory(IValueStore<ContainerConnection> connection
await context.Database.CloseConnectionAsync().ConfigureAwait(false);
context.Database.SetConnectionString(null);
}).ConfigureAwait(false);
}
catch
-2
View File
@@ -15,10 +15,8 @@ public record ContainerToken
public ContainerToken()
{
}
public string Name { get; } = "";
public string? Password { get; } = "";
+1 -1
View File
@@ -3,7 +3,6 @@ using Toolkit.Foundation;
namespace Bitvault;
[Aggerate(nameof(ContainerViewModel))]
public partial class ContainerViewModel(IServiceProvider provider,
IServiceFactory factory,
@@ -44,6 +43,7 @@ public partial class ContainerViewModel(IServiceProvider provider,
return Task.CompletedTask;
}
public Task Handle(NotifyEventArgs<Search> args)
{
if (args.Value is Search search)
-2
View File
@@ -24,7 +24,6 @@ public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFa
{
result = await context.AddAsync(new ItemEntry { Id = id, Name = name }, cancellationToken);
await context.SaveChangesAsync(cancellationToken);
}, cancellationToken);
if (result is not null)
@@ -34,7 +33,6 @@ public class CreateItemHandler(IDbContextFactory<ContainerDbContext> dbContextFa
}
catch
{
}
}
+2 -3
View File
@@ -1,11 +1,10 @@
using FluentAvalonia.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Toolkit.Foundation;
namespace Bitvault;
public class CreatedItemHandler(IServiceProvider serviceProvider,
ICache< Item> cache,
ICache<Item> cache,
IPublisher publisher) :
INotificationHandler<CreatedEventArgs<Item>>
{
-2
View File
@@ -28,7 +28,6 @@ public class EditItemHander(IDbContextFactory<ContainerDbContext> dbContextFacto
result.Name = name;
await context.SaveChangesAsync(cancellationToken);
}
}, cancellationToken);
if (result is not null)
@@ -38,7 +37,6 @@ public class EditItemHander(IDbContextFactory<ContainerDbContext> dbContextFacto
}
catch
{
}
}
-1
View File
@@ -27,4 +27,3 @@ public partial class FavouriteItemActionViewModel(IServiceProvider provider,
}
}
}
-1
View File
@@ -28,7 +28,6 @@ public class FavouriteItemHandler(IValueStore<Item> valueStore,
}
catch
{
}
}
}
+1 -1
View File
@@ -2,5 +2,5 @@
public record Form
{
public ICollection<FormEntry>? Entries { get; set;}
public ICollection<FormEntry>? Entries { get; set; }
}
-1
View File
@@ -3,5 +3,4 @@
public interface IItemEntryViewModel :
IDisposable
{
}
-1
View File
@@ -11,6 +11,5 @@ public partial class IconViewModel : Observable
ISubscription subscriber,
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
}
}
-1
View File
@@ -6,4 +6,3 @@ public record Item
public string? Name { get; init; } = "";
}
-1
View File
@@ -1,5 +1,4 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System.Xml.Linq;
using Toolkit.Foundation;
namespace Bitvault;
+1
View File
@@ -60,6 +60,7 @@ public partial class ItemNavigationViewModel(IServiceProvider provider,
public Task Handle(UnfavouriteEventArgs<Item> args) =>
Task.FromResult(Favourite = false);
public Task Handle(NotifyEventArgs<ItemHeaderConfiguration> args)
{
if (args.Value is ItemHeaderConfiguration configuration)
-1
View File
@@ -11,6 +11,5 @@ public partial class NoteViewModel : Observable
ISubscription subscriber,
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ public class OpenContainerHandler(ContainerConfiguration configuration,
byte[]? salt = Convert.FromBase64String(keyPart[0]);
byte[]? encryptedKey = Convert.FromBase64String(keyPart[1]);
if ( keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
if (keyVaultFactory.Create(Encoding.UTF8.GetBytes(password), encryptedKey, salt) is SecurityKey key)
{
if (await vaultStorage.Create(name, key))
{
-1
View File
@@ -11,6 +11,5 @@ public partial class PasswordViewModel : Observable
ISubscription subscriber,
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
}
}
+2 -2
View File
@@ -13,7 +13,7 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
{
List<(Guid Id, string? Name, bool Favourite, bool Archived)> items = [];
if (args.Value is QueryContainerConfiguration queryConfiguration)
if (args.Value is QueryContainerConfiguration queryConfiguration)
{
ExpressionStarter<ItemEntry> predicate =
PredicateBuilder.New<ItemEntry>(true);
@@ -33,7 +33,7 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
predicate = predicate.And(x => x.State == 2);
}
if (queryConfiguration.Query is { Length: > 0} query)
if (queryConfiguration.Query is { Length: > 0 } query)
{
predicate = predicate.And(x => EF.Functions.Like(x.Name, $"%{query}%"));
}
@@ -19,4 +19,3 @@ public partial class SearchContainerActionViewModel(IServiceProvider provider,
public void Invoke() => Publisher.Publish(Notify.As(new Search(Value)),
nameof(ContainerViewModel));
}
-1
View File
@@ -31,4 +31,3 @@ public class SecurityKeyFactory(IKeyGenerator generator,
return new SecurityKey(salt, encryptedKey, decryptedKey);
}
}
-1
View File
@@ -11,6 +11,5 @@ public partial class TextViewModel : Observable
ISubscription subscriber,
IDisposer disposer) : base(provider, factory, mediator, publisher, subscriber, disposer)
{
}
}
-1
View File
@@ -14,4 +14,3 @@ public partial class UnarchiveItemActionViewModel(IServiceProvider provider,
[RelayCommand]
public void Invoke() => Publisher.Publish(Unarchive.As<Item>());
}
-1
View File
@@ -28,7 +28,6 @@ public class UnarchiveItemHandler(IValueStore<Item> valueStore,
}
catch
{
}
}
}
@@ -14,4 +14,3 @@ public partial class UnfavouriteItemActionViewModel(IServiceProvider provider,
[RelayCommand]
public void Invoke() => Publisher.Publish(Unfavourite.As<Item>());
}
-1
View File
@@ -28,7 +28,6 @@ public class UnfavouriteItemHandler(IValueStore<Item> valueStore,
}
catch
{
}
}
}
+1 -1
Submodule Toolkit updated: 246dab4297...40a150fe80