Allow subscription keys to be resolved by reflection
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<UserControl
|
<SettingsExpander
|
||||||
x:Class="Bitvault.Avalonia.AddItemNavigationView"
|
x:Class="Bitvault.Avalonia.AddItemNavigationView"
|
||||||
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"
|
||||||
<SettingsExpander Header="Add item" IsClickEnabled="True" />
|
Header="Add item"
|
||||||
</UserControl>
|
IsClickEnabled="True" />
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using Avalonia.Controls;
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
public partial class AddItemNavigationView : UserControl
|
public partial class AddItemNavigationView :
|
||||||
|
SettingsExpander
|
||||||
{
|
{
|
||||||
public AddItemNavigationView() => InitializeComponent();
|
public AddItemNavigationView() =>
|
||||||
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,6 +136,13 @@ public partial class App : Application
|
|||||||
services.AddHandler<AggregateItemContentViewModelHandler>();
|
services.AddHandler<AggregateItemContentViewModelHandler>();
|
||||||
services.AddHandler<AggregateItemContentFromCategoryViewModelHandler>();
|
services.AddHandler<AggregateItemContentFromCategoryViewModelHandler>();
|
||||||
|
|
||||||
|
services.AddTemplate<ItemSectionViewModel, ItemSectionView>();
|
||||||
|
|
||||||
|
services.AddTemplate<ItemTextEntryViewModel, ItemTextEntryView>();
|
||||||
|
services.AddTemplate<ItemPasswordEntryViewModel, ItemPasswordEntryView>();
|
||||||
|
services.AddTemplate<ItemMaskedTextEntryViewModel, ItemMaskedTextEntryView>();
|
||||||
|
services.AddTemplate<ItemDropdownEntryViewModel, ItemDropdownEntryView>();
|
||||||
|
|
||||||
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
|
||||||
|
|
||||||
services.AddTemplate<FavouriteItemActionViewModel, FavouriteItemActionView>();
|
services.AddTemplate<FavouriteItemActionViewModel, FavouriteItemActionView>();
|
||||||
@@ -146,11 +153,6 @@ public partial class App : Application
|
|||||||
services.AddTemplate<EditItemActionViewModel, EditItemActionView>();
|
services.AddTemplate<EditItemActionViewModel, EditItemActionView>();
|
||||||
services.AddTemplate<DeleteItemActionViewModel, DeleteItemActionView>();
|
services.AddTemplate<DeleteItemActionViewModel, DeleteItemActionView>();
|
||||||
|
|
||||||
services.AddTemplate<ItemTextEntryViewModel, ItemTextEntryView>();
|
|
||||||
services.AddTemplate<ItemPasswordEntryViewModel, ItemPasswordEntryView>();
|
|
||||||
services.AddTemplate<ItemMaskedTextEntryViewModel, ItemMaskedTextEntryView>();
|
|
||||||
services.AddTemplate<ItemDropdownEntryViewModel, ItemDropdownEntryView>();
|
|
||||||
|
|
||||||
services.AddHandler<ConfirmUpdateItemHandler>(nameof(ItemState.Write));
|
services.AddHandler<ConfirmUpdateItemHandler>(nameof(ItemState.Write));
|
||||||
services.AddHandler<ConfirmCreateItemHandler>(nameof(ItemState.New));
|
services.AddHandler<ConfirmCreateItemHandler>(nameof(ItemState.New));
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<SettingsExpander
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="Bitvault.Avalonia.ItemDropdownEntryView"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
xmlns:vm="using:Bitvault"
|
||||||
x:Class="Bitvault.Avalonia.ItemDropdownEntryView">
|
x:DataType="vm:ItemDropdownEntryViewModel"
|
||||||
Welcome to Avalonia!
|
Header="{Binding Key}">
|
||||||
</UserControl>
|
<SettingsExpander.Footer>
|
||||||
|
<TextBox MinWidth="264" />
|
||||||
|
</SettingsExpander.Footer>
|
||||||
|
</SettingsExpander>
|
||||||
@@ -1,12 +1,10 @@
|
|||||||
using Avalonia.Controls;
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
namespace Bitvault.Avalonia
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class ItemDropdownEntryView :
|
||||||
|
SettingsExpander
|
||||||
{
|
{
|
||||||
public partial class ItemDropdownEntryView : UserControl
|
public ItemDropdownEntryView() =>
|
||||||
{
|
InitializeComponent();
|
||||||
public ItemDropdownEntryView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<SettingsExpander
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="Bitvault.Avalonia.ItemMaskedTextEntryView"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
xmlns:vm="using:Bitvault"
|
||||||
x:Class="Bitvault.Avalonia.ItemMaskedTextEntryView">
|
x:DataType="vm:ItemMaskedTextEntryViewModel"
|
||||||
Welcome to Avalonia!
|
Header="{Binding Key}">
|
||||||
</UserControl>
|
<SettingsExpander.Footer>
|
||||||
|
<TextBox MinWidth="264" />
|
||||||
|
</SettingsExpander.Footer>
|
||||||
|
</SettingsExpander>
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
using Avalonia.Controls;
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
namespace Bitvault.Avalonia
|
namespace Bitvault.Avalonia
|
||||||
{
|
{
|
||||||
public partial class ItemMaskedTextEntryView : UserControl
|
public partial class ItemMaskedTextEntryView :
|
||||||
|
SettingsExpander
|
||||||
{
|
{
|
||||||
public ItemMaskedTextEntryView()
|
public ItemMaskedTextEntryView() =>
|
||||||
{
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<SettingsExpander
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="Bitvault.Avalonia.ItemPasswordEntryView"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
xmlns:vm="using:Bitvault"
|
||||||
x:Class="Bitvault.Avalonia.ItemPasswordEntryView">
|
x:DataType="vm:ItemPasswordEntryViewModel"
|
||||||
Welcome to Avalonia!
|
Header="{Binding Key}">
|
||||||
</UserControl>
|
<SettingsExpander.Footer>
|
||||||
|
<TextBox
|
||||||
|
MinWidth="264"
|
||||||
|
Classes="revealPasswordButton"
|
||||||
|
PasswordChar="●" />
|
||||||
|
</SettingsExpander.Footer>
|
||||||
|
</SettingsExpander>
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
using Avalonia.Controls;
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
namespace Bitvault.Avalonia
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class ItemPasswordEntryView :
|
||||||
|
SettingsExpander
|
||||||
{
|
{
|
||||||
public partial class ItemPasswordEntryView : UserControl
|
public ItemPasswordEntryView() =>
|
||||||
{
|
InitializeComponent();
|
||||||
public ItemPasswordEntryView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="Bitvault.Avalonia.ItemSectionView"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:Bitvault"
|
||||||
|
x:DataType="vm:ItemSectionViewModel">
|
||||||
|
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}" />
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class ItemSectionView :
|
||||||
|
UserControl
|
||||||
|
{
|
||||||
|
public ItemSectionView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
<SettingsExpander
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
x:Class="Bitvault.Avalonia.ItemTextEntryView"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
xmlns:vm="using:Bitvault"
|
||||||
x:Class="Bitvault.Avalonia.ItemTextEntryView">
|
x:DataType="vm:ItemTextEntryViewModel"
|
||||||
Welcome to Avalonia!
|
Header="{Binding Key}">
|
||||||
</UserControl>
|
<SettingsExpander.Footer>
|
||||||
|
<TextBox MinWidth="264" />
|
||||||
|
</SettingsExpander.Footer>
|
||||||
|
</SettingsExpander>
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
using Avalonia.Controls;
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
namespace Bitvault.Avalonia
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
|
public partial class ItemTextEntryView :
|
||||||
|
SettingsExpander
|
||||||
{
|
{
|
||||||
public partial class ItemTextEntryView : UserControl
|
public ItemTextEntryView() =>
|
||||||
{
|
InitializeComponent();
|
||||||
public ItemTextEntryView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public class AggregateItemContentFromCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
public class AggregateItemContentFromCategoryViewModelHandler(IItemConfigurationCollection configurations,
|
||||||
|
IServiceFactory serviceFactory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
INotificationHandler<AggerateEventArgs<IItemEntryViewModel, string>>
|
INotificationHandler<AggerateEventArgs<IItemEntryViewModel, string>>
|
||||||
@@ -15,12 +16,21 @@ public class AggregateItemContentFromCategoryViewModelHandler(IItemConfiguration
|
|||||||
{
|
{
|
||||||
if (factory.Invoke() is ItemConfiguration configuration)
|
if (factory.Invoke() is ItemConfiguration configuration)
|
||||||
{
|
{
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
foreach (ItemSectionConfiguration section in configuration.Sections)
|
foreach (ItemSectionConfiguration section in configuration.Sections)
|
||||||
{
|
{
|
||||||
foreach (ItemEntryConfiguration entryConfiguration in section.Entries)
|
if (serviceFactory.Create<ItemSectionViewModel>($"{nameof(ItemSection)}{index}") is ItemSectionViewModel sectionViewModel)
|
||||||
{
|
{
|
||||||
var dod = await mediator.Handle<ItemEntryConfiguration, IItemEntryViewModel?>(entryConfiguration,
|
publisher.Publish(Create.As(sectionViewModel), nameof(ItemContentViewModel));
|
||||||
entryConfiguration.GetType().Name);
|
foreach (ItemEntryConfiguration entryConfiguration in section.Entries)
|
||||||
|
{
|
||||||
|
if (await mediator.Handle<ItemEntryConfiguration, IItemEntryViewModel?>(entryConfiguration,
|
||||||
|
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||||
|
{
|
||||||
|
publisher.Publish(Create.As(entryViewModel), $"{nameof(ItemSection)}{index}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,22 +8,16 @@ public class ConfirmCreateItemHandler(IMediator mediator,
|
|||||||
{
|
{
|
||||||
public async Task Handle(ConfirmEventArgs<Item> args)
|
public async Task Handle(ConfirmEventArgs<Item> args)
|
||||||
{
|
{
|
||||||
ItemHeaderConfiguration? configuration = await mediator.Handle<ConfirmEventArgs<Item>,
|
string? name = await mediator.Handle<ConfirmEventArgs<Item>,
|
||||||
ItemHeaderConfiguration>(args);
|
string?>(args, nameof(ItemHeader));
|
||||||
|
|
||||||
if (configuration is not null)
|
if (name is not null)
|
||||||
{
|
{
|
||||||
publisher.Publish(Notify.As(configuration));
|
|
||||||
|
|
||||||
Guid id = Guid.NewGuid();
|
Guid id = Guid.NewGuid();
|
||||||
|
|
||||||
string? name = configuration.Name;
|
|
||||||
string? category = configuration.Name;
|
|
||||||
|
|
||||||
publisher.Publish(Created.As(new Item<(Guid, string)>((id, name))));
|
publisher.Publish(Created.As(new Item<(Guid, string)>((id, name))));
|
||||||
|
|
||||||
await mediator.Handle<CreateEventArgs<(Guid, string, string,
|
await mediator.Handle<CreateEventArgs<(Guid, string, string,
|
||||||
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, string, ItemConfiguration)>((id, name, category,
|
ItemConfiguration)>, bool>(new CreateEventArgs<(Guid, string, string, ItemConfiguration)>((id, name, "",
|
||||||
new ItemConfiguration())));
|
new ItemConfiguration())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
[Notification(typeof(AggerateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
|
||||||
[Notification(typeof(CreateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
[Notification(typeof(CreateEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||||
[Notification(typeof(InsertEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
[Notification(typeof(InsertEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||||
[Notification(typeof(MoveToEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
[Notification(typeof(MoveToEventArgs<ItemNavigationViewModel>), nameof(ItemCollectionViewModel))]
|
||||||
|
|||||||
@@ -45,12 +45,24 @@ public record ItemConfiguration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public static ItemConfiguration Login => new()
|
public static ItemConfiguration Login => new()
|
||||||
{
|
{
|
||||||
Sections = new List<ItemSectionConfiguration>
|
Sections = new List<ItemSectionConfiguration>
|
||||||
{
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Entries = new List<ItemEntryConfiguration>
|
||||||
|
{
|
||||||
|
new TextEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Username"
|
||||||
|
},
|
||||||
|
new PasswordEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Password"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,7 +70,16 @@ public record ItemConfiguration
|
|||||||
{
|
{
|
||||||
Sections = new List<ItemSectionConfiguration>
|
Sections = new List<ItemSectionConfiguration>
|
||||||
{
|
{
|
||||||
|
new()
|
||||||
|
{
|
||||||
|
Entries = new List<ItemEntryConfiguration>
|
||||||
|
{
|
||||||
|
new PasswordEntryConfiguration
|
||||||
|
{
|
||||||
|
Label = "Password"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record ItemContent;
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
|
[Notification(typeof(CreateEventArgs<ItemSectionViewModel>), nameof(ItemContentViewModel))]
|
||||||
public partial class ItemContentViewModel(IServiceProvider provider,
|
public partial class ItemContentViewModel(IServiceProvider provider,
|
||||||
IServiceFactory factory, IMediator mediator,
|
IServiceFactory factory, IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
@@ -9,7 +10,7 @@ public partial class ItemContentViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IContentTemplate template,
|
IContentTemplate template,
|
||||||
ItemState state = ItemState.Read) :
|
ItemState state = ItemState.Read) :
|
||||||
ObservableCollection<IItemEntryViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
ObservableCollection<ItemSectionViewModel>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||||
IItemEntryViewModel,
|
IItemEntryViewModel,
|
||||||
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
INotificationHandler<NotifyEventArgs<ItemCategory<string>>>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public partial class ItemDropdownEntryViewModel(IServiceProvider provider,
|
|||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) :
|
IDisposer disposer,
|
||||||
Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
string? key = default,
|
||||||
|
object? value = default) : Observable<string, object?>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||||
IItemEntryViewModel;
|
IItemEntryViewModel;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
public Task<IItemEntryViewModel?> Handle(DropdownEntryConfiguration args,
|
public Task<IItemEntryViewModel?> Handle(DropdownEntryConfiguration args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>() is ItemDropdownEntryViewModel viewModel)
|
if (serviceFactory.Create<ItemDropdownEntryViewModel>(args.Label, args.Value ?? new object()) is ItemDropdownEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record ItemHeader;
|
||||||
@@ -3,9 +3,11 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class ItemHeaderViewModel : Observable<string, string>,
|
[Notification(typeof(ConfirmEventArgs<Item>), nameof(ItemHeader))]
|
||||||
|
public partial class ItemHeaderViewModel :
|
||||||
|
Observable<string, string>,
|
||||||
IHandler<ValidationEventArgs<Item>, bool>,
|
IHandler<ValidationEventArgs<Item>, bool>,
|
||||||
IHandler<ConfirmEventArgs<Item>, ItemHeaderConfiguration>,
|
IHandler<ConfirmEventArgs<Item>, string?>,
|
||||||
INotificationHandler<UpdateEventArgs<Item>>,
|
INotificationHandler<UpdateEventArgs<Item>>,
|
||||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||||
INotificationHandler<CancelEventArgs<Item>>,
|
INotificationHandler<CancelEventArgs<Item>>,
|
||||||
@@ -38,9 +40,6 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
|||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ItemHeaderConfiguration> Handle(ConfirmEventArgs<Item> args,
|
|
||||||
CancellationToken cancellationToken) => Task.FromResult(new ItemHeaderConfiguration { Name = Value! });
|
|
||||||
|
|
||||||
public Task Handle(UpdateEventArgs<Item> args) =>
|
public Task Handle(UpdateEventArgs<Item> args) =>
|
||||||
Task.FromResult(State = ItemState.Write);
|
Task.FromResult(State = ItemState.Write);
|
||||||
|
|
||||||
@@ -69,4 +68,7 @@ public partial class ItemHeaderViewModel : Observable<string, string>,
|
|||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task<string?> Handle(ConfirmEventArgs<Item> args,
|
||||||
|
CancellationToken cancellationToken) => Task.FromResult(Value);
|
||||||
}
|
}
|
||||||
@@ -7,5 +7,7 @@ public partial class ItemMaskedTextEntryViewModel(IServiceProvider provider,
|
|||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
IDisposer disposer,
|
||||||
|
string? key = default,
|
||||||
|
object? value = default) : Observable<string, object?>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||||
IItemEntryViewModel;
|
IItemEntryViewModel;
|
||||||
@@ -8,7 +8,7 @@ public class ItemMaskedTextEntryViewModelHandler(IServiceFactory serviceFactory)
|
|||||||
public Task<IItemEntryViewModel?> Handle(MaskedTextEntryConfiguration args,
|
public Task<IItemEntryViewModel?> Handle(MaskedTextEntryConfiguration args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>() is ItemMaskedTextEntryViewModel viewModel)
|
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>(args.Label, args.Value ?? new object()) is ItemMaskedTextEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,5 +7,7 @@ public partial class ItemPasswordEntryViewModel(IServiceProvider provider,
|
|||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
IDisposer disposer,
|
||||||
|
string? key = default,
|
||||||
|
object? value = default) : Observable<string, object?>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||||
IItemEntryViewModel;
|
IItemEntryViewModel;
|
||||||
@@ -8,7 +8,7 @@ public class ItemPasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
public Task<IItemEntryViewModel?> Handle(PasswordEntryConfiguration args,
|
public Task<IItemEntryViewModel?> Handle(PasswordEntryConfiguration args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemPasswordEntryViewModel>() is ItemPasswordEntryViewModel viewModel)
|
if (serviceFactory.Create<ItemPasswordEntryViewModel>(args.Label, args.Value ?? new object()) is ItemPasswordEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public record ItemSection;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
[Notification(typeof(CreateEventArgs<IItemEntryViewModel>), nameof(Section))]
|
||||||
|
public partial class ItemSectionViewModel(IServiceProvider provider,
|
||||||
|
IServiceFactory factory,
|
||||||
|
IMediator mediator,
|
||||||
|
IPublisher publisher,
|
||||||
|
ISubscription subscriber,
|
||||||
|
IDisposer disposer,
|
||||||
|
string section) : ObservableCollection<IItemEntryViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private string section = section;
|
||||||
|
}
|
||||||
@@ -7,5 +7,7 @@ public partial class ItemTextEntryViewModel(IServiceProvider provider,
|
|||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer),
|
IDisposer disposer,
|
||||||
|
string? key = default,
|
||||||
|
string? value = default) : Observable<string, string>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||||
IItemEntryViewModel;
|
IItemEntryViewModel;
|
||||||
@@ -8,7 +8,7 @@ public class ItemTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
public Task<IItemEntryViewModel?> Handle(TextEntryConfiguration args,
|
public Task<IItemEntryViewModel?> Handle(TextEntryConfiguration args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemTextEntryViewModel>() is ItemTextEntryViewModel viewModel)
|
if (serviceFactory.Create<ItemTextEntryViewModel>(args.Label, args.Value ?? "") is ItemTextEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user