wip
This commit is contained in:
@@ -68,6 +68,7 @@ public partial class App : Application
|
||||
|
||||
services.AddTransient<ISecurityKeyFactory, SecurityKeyFactory>();
|
||||
services.AddTransient<ILockerStorageFactory, LockerStorageFactory>();
|
||||
|
||||
services.TryAddSingleton<IValueStore<SecurityKey>, ValueStore<SecurityKey>>();
|
||||
services.TryAddSingleton<IValueStore<LockerConnection>, ValueStore<LockerConnection>>();
|
||||
|
||||
@@ -99,7 +100,7 @@ public partial class App : Application
|
||||
|
||||
services.AddTemplate<LockerViewModel, LockerView>("Locker");
|
||||
services.AddTemplate<ItemCollectionViewModel, ItemCollectionView>("ContentItemCollection");
|
||||
services.AddHandler<AggerateLockerItemViewModelHandler>();
|
||||
services.AddHandler<AggerateItemViewModelHandler>();
|
||||
|
||||
services.AddTemplate<LockerHeaderViewModel, LockerHeaderView>("LockerHeader");
|
||||
services.AddTemplate<BackActionViewModel, BackActionView>();
|
||||
@@ -109,7 +110,7 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemCategoryCollectionViewModel, ItemCategoryCollectionView>("ItemCategoryCollection");
|
||||
services.AddTemplate<ItemCategoryNavigationViewModel, ItemCategoryNavigationView>();
|
||||
|
||||
services.AddHandler<AggerateLockerItemCategoryViewModelHandler>();
|
||||
services.AddHandler<AggerateItemCategoryViewModelHandler>();
|
||||
|
||||
services.AddTemplate<ItemNavigationViewModel, ItemNavigationView>();
|
||||
services.AddTemplate<ItemViewModel, ItemView>("Item");
|
||||
@@ -133,14 +134,16 @@ public partial class App : Application
|
||||
|
||||
services.AddScoped<IValueStore<Item<(Guid, string)>>, ValueStore<Item<(Guid, string)>>>();
|
||||
|
||||
services.AddHandler<ConfirmItemHandler>();
|
||||
services.AddHandler<ConfirmUpdateItemHandler>(nameof(Update));
|
||||
services.AddHandler<ConfirmCreateItemHandler>(nameof(Create));
|
||||
|
||||
services.AddHandler<ArchiveItemHandler>();
|
||||
services.AddHandler<UnarchiveItemHandler>();
|
||||
services.AddHandler<FavouriteItemHandler>();
|
||||
services.AddHandler<UnfavouriteItemHandler>();
|
||||
|
||||
services.AddHandler<CreatedItemHandler>(ServiceLifetime.Singleton);
|
||||
services.AddHandler<ModifiedItemHandler>(ServiceLifetime.Singleton);
|
||||
services.AddHandler<ItemCreatedHandler>(ServiceLifetime.Singleton);
|
||||
services.AddHandler<ItemModifiedHandler>(ServiceLifetime.Singleton);
|
||||
});
|
||||
})!);
|
||||
|
||||
|
||||
@@ -11,9 +11,6 @@
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<DefineConstants>$(DefineConstants);ENABLE_XAML_HOT_RELOAD</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Remove="Assets\Class1.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Condition="$(DefineConstants.Contains(ENABLE_XAML_HOT_RELOAD))" Include="Avalonia.Markup.Xaml.Loader" Version="11.1.0-beta2" />
|
||||
<PackageReference Condition="$(DefineConstants.Contains(ENABLE_XAML_HOT_RELOAD))" Include="HotAvalonia" Version="1.1.1" />
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="FromCategory" Value="{x:True}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Write}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.New}" />
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="FromCategory" Value="{x:True}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Write}" />
|
||||
</NavigateAction>
|
||||
</EventTriggerBehavior>
|
||||
|
||||
@@ -3,8 +3,25 @@
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:DataType="vm:ItemCategoryNavigationViewModel"
|
||||
IsSelected="{Binding Selected, Mode=TwoWay}">
|
||||
x:DataType="vm:ItemCategoryNavigationViewModel">
|
||||
<Interaction.Behaviors>
|
||||
<AttachedBehaviour>
|
||||
<ConditionAction>
|
||||
<ConditionAction.Condition>
|
||||
<ConditionalExpression ForwardChaining="And">
|
||||
<ComparisonCondition LeftOperand="{Binding Selected}" RightOperand="True" />
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</ConditionAction>
|
||||
</AttachedBehaviour>
|
||||
<DataTriggerBehavior
|
||||
Binding="{Binding Selected}"
|
||||
ComparisonCondition="Equal"
|
||||
Value="True">
|
||||
<InvokeCommandAction Command="{Binding InvokeCommand}" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<Grid Background="Transparent" ColumnDefinitions="Auto,*">
|
||||
<PersonPicture
|
||||
Grid.Column="0"
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
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="Favourite" Value="{Binding Favourite}" />
|
||||
@@ -32,7 +31,6 @@
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="FromCategory" Value="{x:False}" />
|
||||
<Parameter Key="Name" Value="{Binding Name}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Read}" />
|
||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||
|
||||
@@ -22,19 +22,7 @@
|
||||
</ConditionalExpression>
|
||||
</ConditionAction.Condition>
|
||||
<NavigateBackAction Region="Left" />
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior
|
||||
Binding="{Binding SelectedItem}"
|
||||
ComparisonCondition="Equal"
|
||||
Value="{x:Null}">
|
||||
<NavigateAction
|
||||
Region="{Binding Named, StringFormat='{}{0}:Content'}"
|
||||
Route="Item"
|
||||
Scope="self">
|
||||
<Parameter Key="FromCategory" Value="{x:True}" />
|
||||
<Parameter Key="State" Value="{x:Static vm:ItemState.Write}" />
|
||||
</NavigateAction>
|
||||
</ConditionAction>
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<ScrollViewer Padding="12,12,12,0">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
x:Class="Bitvault.Avalonia.LockerNavigationView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:vm="using:Bitvault"
|
||||
x:Name="NavigationViewItem"
|
||||
x:DataType="vm:LockerNavigationViewModel"
|
||||
@@ -85,8 +86,29 @@
|
||||
<InvokeNavigationViewItemAction />
|
||||
</ConditionAction>
|
||||
</AttachedEventTriggerBehaviour>
|
||||
<DataTriggerBehavior Binding="{Binding Opened}" Value="False">
|
||||
<RemoveClassAction ClassName="Closed" />
|
||||
<AddClassAction ClassName="Closed" RemoveIfExists="True" />
|
||||
</DataTriggerBehavior>
|
||||
<DataTriggerBehavior Binding="{Binding Opened}" Value="True">
|
||||
<RemoveClassAction ClassName="Opened" />
|
||||
<AddClassAction ClassName="Opened" RemoveIfExists="True" />
|
||||
</DataTriggerBehavior>
|
||||
</Interaction.Behaviors>
|
||||
<NavigationViewItem.IconSource>
|
||||
<PathIconSource Data="M512,757.76C525.653,757.76 537.6,752.64 547.84,742.4C558.08,732.16 563.2,720.213 563.2,706.56C563.2,692.907 558.08,680.96 547.84,670.72C537.6,660.48 525.653,655.36 512,655.36C498.347,655.36 486.4,660.48 476.16,670.72C465.92,680.96 460.8,692.907 460.8,706.56C460.8,720.213 465.92,732.16 476.16,742.4C486.4,752.64 498.347,757.76 512,757.76ZM307.2,399.36L358.4,399.36L358.4,348.16C358.4,305.835 373.419,269.653 403.456,239.616C433.493,209.579 469.675,194.56 512,194.56C554.325,194.56 590.507,209.579 620.544,239.616C650.581,269.653 665.6,305.835 665.6,348.16L665.6,399.36L716.8,399.36C759.125,399.36 795.307,414.379 825.344,444.416C855.381,474.453 870.4,510.635 870.4,552.96L870.4,860.16C870.4,902.485 855.381,938.667 825.344,968.704C795.307,998.741 759.125,1013.76 716.8,1013.76L307.2,1013.76C264.875,1013.76 228.693,998.741 198.656,968.704C168.619,938.667 153.6,902.485 153.6,860.16L153.6,552.96C153.6,510.635 168.619,474.453 198.656,444.416C228.693,414.379 264.875,399.36 307.2,399.36ZM512,245.76C483.328,245.76 459.093,255.659 439.296,275.456C419.499,295.253 409.6,319.488 409.6,348.16L409.6,399.36L614.4,399.36L614.4,348.16C614.4,319.488 604.501,295.253 584.704,275.456C564.907,255.659 540.672,245.76 512,245.76ZM819.2,552.96C819.2,524.288 809.301,500.053 789.504,480.256C769.707,460.459 745.472,450.56 716.8,450.56L307.2,450.56C278.528,450.56 254.293,460.459 234.496,480.256C214.699,500.053 204.8,524.288 204.8,552.96L204.8,860.16C204.8,888.832 214.699,913.067 234.496,932.864C254.293,952.661 278.528,962.56 307.2,962.56L716.8,962.56C745.472,962.56 769.707,952.661 789.504,932.864C809.301,913.067 819.2,888.832 819.2,860.16Z" />
|
||||
</NavigationViewItem.IconSource>
|
||||
<NavigationViewItem.Styles>
|
||||
<Style Selector="ui|NavigationViewItem.Closed">
|
||||
<Setter Property="IconSource">
|
||||
<Setter.Value>
|
||||
<PathIconSource Data="M512,757.76C525.653,757.76 537.6,752.64 547.84,742.4C558.08,732.16 563.2,720.213 563.2,706.56C563.2,692.907 558.08,680.96 547.84,670.72C537.6,660.48 525.653,655.36 512,655.36C498.347,655.36 486.4,660.48 476.16,670.72C465.92,680.96 460.8,692.907 460.8,706.56C460.8,720.213 465.92,732.16 476.16,742.4C486.4,752.64 498.347,757.76 512,757.76ZM307.2,399.36L358.4,399.36L358.4,348.16C358.4,305.835 373.419,269.653 403.456,239.616C433.493,209.579 469.675,194.56 512,194.56C554.325,194.56 590.507,209.579 620.544,239.616C650.581,269.653 665.6,305.835 665.6,348.16L665.6,399.36L716.8,399.36C759.125,399.36 795.307,414.379 825.344,444.416C855.381,474.453 870.4,510.635 870.4,552.96L870.4,860.16C870.4,902.485 855.381,938.667 825.344,968.704C795.307,998.741 759.125,1013.76 716.8,1013.76L307.2,1013.76C264.875,1013.76 228.693,998.741 198.656,968.704C168.619,938.667 153.6,902.485 153.6,860.16L153.6,552.96C153.6,510.635 168.619,474.453 198.656,444.416C228.693,414.379 264.875,399.36 307.2,399.36ZM512,245.76C483.328,245.76 459.093,255.659 439.296,275.456C419.499,295.253 409.6,319.488 409.6,348.16L409.6,399.36L614.4,399.36L614.4,348.16C614.4,319.488 604.501,295.253 584.704,275.456C564.907,255.659 540.672,245.76 512,245.76ZM819.2,552.96C819.2,524.288 809.301,500.053 789.504,480.256C769.707,460.459 745.472,450.56 716.8,450.56L307.2,450.56C278.528,450.56 254.293,460.459 234.496,480.256C214.699,500.053 204.8,524.288 204.8,552.96L204.8,860.16C204.8,888.832 214.699,913.067 234.496,932.864C254.293,952.661 278.528,962.56 307.2,962.56L716.8,962.56C745.472,962.56 769.707,952.661 789.504,932.864C809.301,913.067 819.2,888.832 819.2,860.16Z" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style Selector="ui|NavigationViewItem.Opened">
|
||||
<Setter Property="IconSource">
|
||||
<Setter.Value>
|
||||
<PathIconSource Data="M512,757.76C525.653,757.76 537.6,752.64 547.84,742.4C558.08,732.16 563.2,720.213 563.2,706.56C563.2,692.907 558.08,680.96 547.84,670.72C537.6,660.48 525.653,655.36 512,655.36C498.347,655.36 486.4,660.48 476.16,670.72C465.92,680.96 460.8,692.907 460.8,706.56C460.8,720.213 465.92,732.16 476.16,742.4C486.4,752.64 498.347,757.76 512,757.76ZM768,194.56C739.328,194.56 715.093,204.459 695.296,224.256C675.499,244.053 665.6,268.288 665.6,296.96L665.6,399.36L716.8,399.36C759.125,399.36 795.307,414.379 825.344,444.416C855.381,474.453 870.4,510.635 870.4,552.96L870.4,860.16C870.4,902.485 855.381,938.667 825.344,968.704C795.307,998.741 759.125,1013.76 716.8,1013.76L307.2,1013.76C264.875,1013.76 228.693,998.741 198.656,968.704C168.619,938.667 153.6,902.485 153.6,860.16L153.6,552.96C153.6,510.635 168.619,474.453 198.656,444.416C228.693,414.379 264.875,399.36 307.2,399.36L614.4,399.36L614.4,296.96C614.4,254.635 629.419,218.453 659.456,188.416C689.493,158.379 725.675,143.36 768,143.36C810.325,143.36 846.507,158.379 876.544,188.416C906.581,218.453 921.6,254.635 921.6,296.96L921.6,321.536C921.6,329.728 919.211,336.213 914.432,340.992C909.653,345.771 903.509,348.16 896,348.16C888.491,348.16 882.347,345.771 877.568,340.992C872.789,336.213 870.4,330.411 870.4,323.584L870.4,296.96C870.4,268.288 860.501,244.053 840.704,224.256C820.907,204.459 796.672,194.56 768,194.56ZM716.8,450.56L307.2,450.56C278.528,450.56 254.293,460.459 234.496,480.256C214.699,500.053 204.8,524.288 204.8,552.96L204.8,860.16C204.8,888.832 214.699,913.067 234.496,932.864C254.293,952.661 278.528,962.56 307.2,962.56L716.8,962.56C745.472,962.56 769.707,952.661 789.504,932.864C809.301,913.067 819.2,888.832 819.2,860.16L819.2,552.96C819.2,524.288 809.301,500.053 789.504,480.256C769.707,460.459 745.472,450.56 716.8,450.56Z" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</NavigationViewItem.Styles>
|
||||
</NavigationViewItem>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
FooterMenuItemsSource="{Binding Footer}"
|
||||
MenuItemTemplate="{Binding Template}"
|
||||
MenuItemsSource="{Binding}"
|
||||
IsSettingsVisible="False"
|
||||
SelectedItem="{Binding SelectedItem}"
|
||||
SelectionFollowsFocus="True">
|
||||
<NavigationView.Resources>
|
||||
|
||||
@@ -15,6 +15,8 @@ public record ItemEntry
|
||||
|
||||
public int State { get; set; } = 0;
|
||||
|
||||
public required string Category { get; set; }
|
||||
|
||||
public ICollection<TagEntry>? Tags { get; }
|
||||
|
||||
public ICollection<BlobEntry>? Blobs { get; }
|
||||
|
||||
+4
-2
@@ -2,19 +2,21 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateLockerItemCategoryViewModelHandler(IEnumerable<IConfigurationDescriptor<ItemConfiguration>> descriptors,
|
||||
public class AggerateItemCategoryViewModelHandler(IEnumerable<IConfigurationDescriptor<ItemConfiguration>> descriptors,
|
||||
IServiceFactory serviceFactory,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<AggerateEventArgs<ItemCategoryNavigationViewModel>>
|
||||
{
|
||||
public Task Handle(AggerateEventArgs<ItemCategoryNavigationViewModel> args)
|
||||
{
|
||||
bool selected = true;
|
||||
foreach (IConfigurationDescriptor<ItemConfiguration> descriptor in descriptors)
|
||||
{
|
||||
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(descriptor.Name)
|
||||
if (serviceFactory.Create<ItemCategoryNavigationViewModel>(descriptor.Name, selected)
|
||||
is ItemCategoryNavigationViewModel viewModel)
|
||||
{
|
||||
publisher.Publish(Create.As(viewModel), nameof(ItemCategoryCollectionViewModel));
|
||||
selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class AggerateLockerItemViewModelHandler(IMediator mediator,
|
||||
public class AggerateItemViewModelHandler(IMediator mediator,
|
||||
IServiceProvider serviceProvider,
|
||||
ICache<Item<(Guid, string)>> cache,
|
||||
IPublisher publisher) :
|
||||
@@ -45,7 +45,5 @@ public class AggerateLockerItemViewModelHandler(IMediator mediator,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var d = cache;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ConfirmCreateItemHandler(IMediator mediator,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ConfirmEventArgs<Item>>
|
||||
{
|
||||
public async Task Handle(ConfirmEventArgs<Item> args)
|
||||
{
|
||||
ItemHeaderConfiguration? configuration = await mediator.Handle<ConfirmEventArgs<Item>,
|
||||
ItemHeaderConfiguration>(args);
|
||||
|
||||
if (configuration is not null)
|
||||
{
|
||||
publisher.Publish(Notify.As(configuration));
|
||||
|
||||
Guid id = Guid.NewGuid();
|
||||
|
||||
string? name = configuration.Name;
|
||||
string? category = configuration.Name;
|
||||
|
||||
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, category,
|
||||
new ItemConfiguration())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,10 @@ public partial class ConfirmItemActionViewModel(IServiceProvider provider,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
IDisposer disposer,
|
||||
ItemState state) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Confirm.As<Item>());
|
||||
public void Invoke() => Publisher.Publish(Confirm.As<Item>(),
|
||||
state is ItemState.New ? nameof(Create) : nameof(Update));
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ConfirmItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
public class ConfirmUpdateItemHandler(IValueStore<Item<(Guid, string)>> store,
|
||||
IMediator mediator,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ConfirmEventArgs<Item>>
|
||||
@@ -16,33 +16,19 @@ public class ConfirmItemHandler(IValueStore<Item<(Guid, string)>> valueStore,
|
||||
{
|
||||
publisher.Publish(Notify.As(configuration));
|
||||
|
||||
if (valueStore?.Value is Item<(Guid, string)> item)
|
||||
if (store?.Value is Item<(Guid, string)> item)
|
||||
{
|
||||
(Guid id, string _) = item.Value;
|
||||
|
||||
string? name = configuration.Name;
|
||||
|
||||
Item<(Guid, string)> newItem = new((id, name));
|
||||
publisher.Publish(Modified.As(item, newItem));
|
||||
|
||||
valueStore.Set(newItem);
|
||||
store.Set(newItem);
|
||||
|
||||
await mediator.Handle<UpdateEventArgs<(Guid, string, ItemConfiguration)>, bool>(new UpdateEventArgs<(Guid, string,
|
||||
ItemConfiguration)>((id, name, new ItemConfiguration())));
|
||||
}
|
||||
else
|
||||
{
|
||||
Guid id = Guid.NewGuid();
|
||||
string? name = configuration.Name;
|
||||
|
||||
bool Success = await mediator.Handle<CreateEventArgs<(Guid, string,
|
||||
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, ItemConfiguration)>((id, name, new ItemConfiguration())));
|
||||
|
||||
if (Success)
|
||||
{
|
||||
publisher.Publish(Created.As(new Item<(Guid, string)>((id, name))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,12 @@ using Toolkit.Foundation;
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory) :
|
||||
IHandler<CreateEventArgs<(Guid, string, ItemConfiguration)>, bool>
|
||||
IHandler<CreateEventArgs<(Guid, string, string, ItemConfiguration)>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CreateEventArgs<(Guid, string, ItemConfiguration)> args,
|
||||
public async Task<bool> Handle(CreateEventArgs<(Guid, string, string, ItemConfiguration)> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is (Guid id, string name, ItemConfiguration configuration))
|
||||
if (args.Value is (Guid id, string name, string category, ItemConfiguration configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -20,7 +20,7 @@ public class CreateItemHandler(IDbContextFactory<LockerContext> dbContextFactory
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
result = await context.AddAsync(new ItemEntry { Id = id, Name = name }, cancellationToken);
|
||||
result = await context.AddAsync(new ItemEntry { Id = id, Name = name, Category = category }, cancellationToken);
|
||||
await context.SaveChangesAsync(cancellationToken);
|
||||
}, cancellationToken);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(nameof(ItemCategoryCollectionViewModel))]
|
||||
[Aggerate(typeof(CreateEventArgs<ItemCategoryNavigationViewModel>), nameof(ItemCategoryCollectionViewModel))]
|
||||
public partial class ItemCategoryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
@@ -21,4 +22,6 @@ public partial class ItemCategoryNavigationViewModel(IServiceProvider provider,
|
||||
[ObservableProperty]
|
||||
private bool selected = selected;
|
||||
|
||||
[RelayCommand]
|
||||
public void Invoke() => Publisher.Publish(Notify.As(new ItemCategory<string>(Name)));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,10 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(nameof(ItemCollectionViewModel))]
|
||||
[Aggerate(typeof(AggerateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(CreateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(InsertEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
[Notification(typeof(MoveToEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||
public partial class ItemCollectionViewModel :
|
||||
ObservableCollection<ItemNavigationViewModel>,
|
||||
INotificationHandler<NotifyEventArgs<Filter>>,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(nameof(ItemContentViewModel))]
|
||||
//[Aggerate(nameof(ItemContentViewModel))]
|
||||
public partial class ItemContentViewModel :
|
||||
ObservableCollection<IItemEntryViewModel>,
|
||||
IItemEntryViewModel,
|
||||
@@ -21,8 +21,14 @@ public partial class ItemContentViewModel :
|
||||
|
||||
public IContentTemplate Template { get; set; }
|
||||
|
||||
protected override IAggerate OnAggerate(object? key)
|
||||
{
|
||||
return base.OnAggerate(key);
|
||||
}
|
||||
|
||||
|
||||
public Task Handle(NotifyEventArgs<ItemCategory<string>> args)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class CreatedItemHandler(IServiceProvider serviceProvider,
|
||||
public class ItemCreatedHandler(IServiceProvider serviceProvider,
|
||||
ICache<Item<(Guid, string)>> cache,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<CreatedEventArgs<Item<(Guid, string)>>>
|
||||
@@ -9,8 +9,12 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||
INotificationHandler<CancelEventArgs<Item>>,
|
||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>,
|
||||
IItemEntryViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? category;
|
||||
|
||||
[ObservableProperty]
|
||||
private ItemState state;
|
||||
|
||||
@@ -56,4 +60,14 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
||||
State = ItemState.Read;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(NotifyEventArgs<ItemCategory<string>> args)
|
||||
{
|
||||
if (args.Value is ItemCategory<string> category)
|
||||
{
|
||||
Category = category.Value;
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class ModifiedItemHandler(IServiceProvider serviceProvider,
|
||||
public class ItemModifiedHandler(IServiceProvider serviceProvider,
|
||||
IPublisher publisher) :
|
||||
INotificationHandler<ModifiedEventArgs<Item<(Guid, string)>>>
|
||||
{
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
public enum ItemState
|
||||
{
|
||||
New,
|
||||
Read,
|
||||
Write
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Notification(typeof(ConfirmEventArgs<Item>), nameof(Create))]
|
||||
public partial class ItemViewModel :
|
||||
ObservableCollection<IItemEntryViewModel>,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
@@ -42,10 +43,10 @@ public partial class ItemViewModel :
|
||||
bool favourite = false,
|
||||
bool archived = false) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||
{
|
||||
FromCategory = fromCategory;
|
||||
Named = $"{named}";
|
||||
Template = template;
|
||||
Named = $"{named}";
|
||||
State = state;
|
||||
FromCategory = fromCategory;
|
||||
Favourite = favourite;
|
||||
Archived = archived;
|
||||
Name = name;
|
||||
@@ -60,7 +61,7 @@ public partial class ItemViewModel :
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<ConfirmItemActionViewModel>(ItemState.Write),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
|
||||
@@ -70,9 +71,12 @@ public partial class ItemViewModel :
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>())));
|
||||
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>
|
||||
@@ -109,11 +113,11 @@ public partial class ItemViewModel :
|
||||
}
|
||||
else
|
||||
{
|
||||
if (State is ItemState.Write)
|
||||
if (State is ItemState.Write or ItemState.New)
|
||||
{
|
||||
Publisher.Publish(Notify.As(Factory.Create<ItemCommandHeaderCollection>(new List<IDisposable>
|
||||
{
|
||||
Factory.Create<ConfirmItemActionViewModel>(),
|
||||
Factory.Create<ConfirmItemActionViewModel>(State),
|
||||
Factory.Create<DismissItemActionViewModel>(),
|
||||
})));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
[Aggerate(nameof(MainViewModel))]
|
||||
[Aggerate(typeof(CreateEventArgs<IMainNavigationViewModel>), nameof(MainViewModel))]
|
||||
public partial class MainViewModel :
|
||||
ObservableCollection<IMainNavigationViewModel>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user