diff --git a/Bitvault.Avalonia/ItemDropdownEntryView.axaml b/Bitvault.Avalonia/ItemDropdownEntryView.axaml
index eaaa648..a7e3da0 100644
--- a/Bitvault.Avalonia/ItemDropdownEntryView.axaml
+++ b/Bitvault.Avalonia/ItemDropdownEntryView.axaml
@@ -6,6 +6,94 @@
x:DataType="vm:ItemDropdownEntryViewModel"
Header="{Binding Key}">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Bitvault.Avalonia/ItemHeaderView.axaml b/Bitvault.Avalonia/ItemHeaderView.axaml
index c6af953..46b4527 100644
--- a/Bitvault.Avalonia/ItemHeaderView.axaml
+++ b/Bitvault.Avalonia/ItemHeaderView.axaml
@@ -14,11 +14,53 @@
Text="{Binding Value}"
TextAlignment="Center"
Watermark="Enter name">
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Bitvault.Avalonia/ItemMaskedTextEntryView.axaml b/Bitvault.Avalonia/ItemMaskedTextEntryView.axaml
index 5cdfec6..2121fb6 100644
--- a/Bitvault.Avalonia/ItemMaskedTextEntryView.axaml
+++ b/Bitvault.Avalonia/ItemMaskedTextEntryView.axaml
@@ -6,6 +6,59 @@
x:DataType="vm:ItemMaskedTextEntryViewModel"
Header="{Binding Key}">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Bitvault.Avalonia/ItemTextEntryView.axaml b/Bitvault.Avalonia/ItemTextEntryView.axaml
index 25d9a3d..02758c3 100644
--- a/Bitvault.Avalonia/ItemTextEntryView.axaml
+++ b/Bitvault.Avalonia/ItemTextEntryView.axaml
@@ -7,15 +7,53 @@
Header="{Binding Key}">
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/Bitvault.Avalonia/ItemView.axaml b/Bitvault.Avalonia/ItemView.axaml
index dea9409..d6dc08f 100644
--- a/Bitvault.Avalonia/ItemView.axaml
+++ b/Bitvault.Avalonia/ItemView.axaml
@@ -4,44 +4,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Bitvault"
x:DataType="vm:ItemViewModel">
-
-
-
-
-
-
-
-
(provider, factory, mediator, publisher, subscriber, disposer)
+ IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
{
[ObservableProperty]
private int index = 0;
diff --git a/Bitvault/DropdownEntryConfiguration.cs b/Bitvault/DropdownEntryConfiguration.cs
index 2bffee4..85c8015 100644
--- a/Bitvault/DropdownEntryConfiguration.cs
+++ b/Bitvault/DropdownEntryConfiguration.cs
@@ -6,5 +6,5 @@ public record DropdownEntryConfiguration :
ItemEntryConfiguration
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
- public string[]? Values { get; set; }
+ public IList Values { get; set; } = new List();
}
diff --git a/Bitvault/ItemDropdownEntryViewModel.cs b/Bitvault/ItemDropdownEntryViewModel.cs
index ddfa54e..49bbae9 100644
--- a/Bitvault/ItemDropdownEntryViewModel.cs
+++ b/Bitvault/ItemDropdownEntryViewModel.cs
@@ -2,13 +2,36 @@
namespace Bitvault;
-public partial class ItemDropdownEntryViewModel(IServiceProvider provider,
- IServiceFactory factory,
- IMediator mediator,
- IPublisher publisher,
- ISubscription subscriber,
- IDisposer disposer,
- ItemState state,
- ItemEntryConfiguration configuration,
- string? key = default,
- object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
\ No newline at end of file
+public partial class ItemDropdownEntryViewModel :
+ ItemEntryCollectionViewModel
+{
+ public ItemDropdownEntryViewModel(IServiceProvider provider,
+ IServiceFactory factory,
+ IMediator mediator,
+ IPublisher publisher,
+ ISubscription subscriber,
+ IDisposer disposer,
+ IEnumerable items,
+ ItemState state,
+ ItemEntryConfiguration configuration,
+ string key,
+ object value,
+ ItemDropdownValueViewModel selectedItem) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value)
+ {
+ SelectedItem = selectedItem;
+ }
+
+ public ItemDropdownEntryViewModel(IServiceProvider provider,
+ IServiceFactory factory,
+ IMediator mediator,
+ IPublisher publisher,
+ ISubscription subscriber,
+ IDisposer disposer,
+ IEnumerable items,
+ ItemState state,
+ ItemEntryConfiguration configuration,
+ string key,
+ object value) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value)
+ {
+ }
+}
\ No newline at end of file
diff --git a/Bitvault/ItemDropdownEntryViewModelHandler.cs b/Bitvault/ItemDropdownEntryViewModelHandler.cs
index 34e31f2..e2a254e 100644
--- a/Bitvault/ItemDropdownEntryViewModelHandler.cs
+++ b/Bitvault/ItemDropdownEntryViewModelHandler.cs
@@ -10,7 +10,18 @@ public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
{
if (args.Value is DropdownEntryConfiguration configuration)
{
- if (serviceFactory.Create([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
+ List values = [];
+ foreach (string item in configuration.Values)
+ {
+ values.Add(serviceFactory.Create(item));
+ }
+
+ string? label = configuration.Label;
+ object? value = configuration.Value;
+
+ ItemDropdownValueViewModel? selected = values.FirstOrDefault(x => x.Value is not null && x.Value.Equals($"{value}"));
+
+ if (serviceFactory.Create([values, .. args.Parameters, configuration, label, value ?? "", selected])
is ItemDropdownEntryViewModel viewModel)
{
return Task.FromResult(viewModel);
diff --git a/Bitvault/ItemDropdownValueViewModel.cs b/Bitvault/ItemDropdownValueViewModel.cs
new file mode 100644
index 0000000..26a0f95
--- /dev/null
+++ b/Bitvault/ItemDropdownValueViewModel.cs
@@ -0,0 +1,11 @@
+using Toolkit.Foundation;
+
+namespace Bitvault;
+
+public partial class ItemDropdownValueViewModel(IServiceProvider provider,
+ IServiceFactory factory,
+ IMediator mediator,
+ IPublisher publisher,
+ ISubscription subscriber,
+ IDisposer disposer,
+ string? value = null) : Observable(provider, factory, mediator, publisher, subscriber, disposer, value);
diff --git a/Bitvault/ItemEntryCollectionViewModel.cs b/Bitvault/ItemEntryCollectionViewModel.cs
new file mode 100644
index 0000000..aa17e59
--- /dev/null
+++ b/Bitvault/ItemEntryCollectionViewModel.cs
@@ -0,0 +1,77 @@
+using CommunityToolkit.Mvvm.ComponentModel;
+using Toolkit.Foundation;
+
+namespace Bitvault;
+
+public partial class ItemEntryCollectionViewModel :
+ ObservableCollection,
+ IItemEntryViewModel,
+ INotificationHandler>,
+ INotificationHandler>,
+ INotificationHandler>
+ where TItem : notnull,
+ IDisposable
+{
+ [ObservableProperty]
+ private ItemState state;
+
+ private readonly ItemEntryConfiguration configuration;
+
+ public ItemEntryCollectionViewModel(IServiceProvider provider,
+ IServiceFactory factory,
+ IMediator mediator,
+ IPublisher publisher,
+ ISubscription subscriber,
+ IDisposer disposer,
+ ItemState state,
+ ItemEntryConfiguration configuration,
+ string key,
+ object value) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
+ {
+ this.configuration = configuration;
+ State = state;
+ }
+
+ public ItemEntryCollectionViewModel(IServiceProvider provider,
+ IServiceFactory factory,
+ IMediator mediator,
+ IPublisher publisher,
+ ISubscription subscriber,
+ IDisposer disposer,
+ IEnumerable items,
+ ItemState state,
+ ItemEntryConfiguration configuration,
+ string key,
+ object value) : base(provider, factory, mediator, publisher, subscriber, disposer, items, key, value)
+ {
+ this.configuration = configuration;
+ State = state;
+ }
+
+ protected override void OnValueChanged()
+ {
+ if (configuration is not null)
+ {
+ configuration.Value = Value;
+ }
+ }
+
+ public Task Handle(UpdateEventArgs- args) =>
+ Task.FromResult(State = ItemState.Write);
+
+ public Task Handle(CancelEventArgs
- args)
+ {
+ Revert();
+
+ State = ItemState.Read;
+ return Task.CompletedTask;
+ }
+
+ public Task Handle(ConfirmEventArgs
- args)
+ {
+ Commit();
+
+ State = ItemState.Read;
+ return Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/Bitvault/ItemEntryViewModel.cs b/Bitvault/ItemEntryViewModel.cs
index c1ebc48..8e5a160 100644
--- a/Bitvault/ItemEntryViewModel.cs
+++ b/Bitvault/ItemEntryViewModel.cs
@@ -11,8 +11,8 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
IDisposer disposer,
ItemState state,
ItemEntryConfiguration configuration,
- string? key = default,
- object? value = default) :
+ string key,
+ object value) :
Observable(provider, factory, mediator, publisher, subscriber, disposer, key, value),
IItemEntryViewModel,
INotificationHandler>,
@@ -43,4 +43,4 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
State = ItemState.Read;
return Task.CompletedTask;
}
-}
+}
\ No newline at end of file
diff --git a/Bitvault/ItemHeaderViewModel.cs b/Bitvault/ItemHeaderViewModel.cs
index 87eb496..845d26a 100644
--- a/Bitvault/ItemHeaderViewModel.cs
+++ b/Bitvault/ItemHeaderViewModel.cs
@@ -25,7 +25,8 @@ public partial class ItemHeaderViewModel :
ISubscription subscriber,
IDisposer disposer,
ItemState state,
- string? value = null) : base(provider, factory, mediator, publisher, subscriber, disposer, value)
+ string key,
+ string value) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
{
State = state;
Value = value;
@@ -68,6 +69,6 @@ public partial class ItemHeaderViewModel :
return Task.CompletedTask;
}
- public Task Handle(ConfirmEventArgs args,
+ public Task Handle(ConfirmEventArgs args,
CancellationToken cancellationToken) => Task.FromResult(Value);
}
\ No newline at end of file
diff --git a/Bitvault/ItemMaskedTextEntryViewModel.cs b/Bitvault/ItemMaskedTextEntryViewModel.cs
index 5753b68..0f6e436 100644
--- a/Bitvault/ItemMaskedTextEntryViewModel.cs
+++ b/Bitvault/ItemMaskedTextEntryViewModel.cs
@@ -11,10 +11,10 @@ public partial class ItemMaskedTextEntryViewModel(IServiceProvider provider,
IDisposer disposer,
ItemState state,
ItemEntryConfiguration configuration,
- string? pattern,
- string? key = default,
- object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value)
+ string pattern,
+ string key,
+ object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value)
{
[ObservableProperty]
- private string? pattern = pattern;
+ private string pattern = pattern;
}
\ No newline at end of file
diff --git a/Bitvault/ItemPasswordEntryViewModel.cs b/Bitvault/ItemPasswordEntryViewModel.cs
index 7b415c5..9cf9c19 100644
--- a/Bitvault/ItemPasswordEntryViewModel.cs
+++ b/Bitvault/ItemPasswordEntryViewModel.cs
@@ -10,5 +10,5 @@ public partial class ItemPasswordEntryViewModel(IServiceProvider provider,
IDisposer disposer,
ItemState state,
ItemEntryConfiguration configuration,
- string? key = default,
- object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
\ No newline at end of file
+ string key,
+ object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
\ No newline at end of file
diff --git a/Bitvault/ItemTextEntryViewModel.cs b/Bitvault/ItemTextEntryViewModel.cs
index bfdc832..7cfe326 100644
--- a/Bitvault/ItemTextEntryViewModel.cs
+++ b/Bitvault/ItemTextEntryViewModel.cs
@@ -10,5 +10,5 @@ public partial class ItemTextEntryViewModel(IServiceProvider provider,
IDisposer disposer,
ItemState state,
ItemEntryConfiguration configuration,
- string? key = default,
- object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
\ No newline at end of file
+ string key,
+ object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
\ No newline at end of file
diff --git a/Bitvault/ItemViewModel.cs b/Bitvault/ItemViewModel.cs
index 412e947..d1d824d 100644
--- a/Bitvault/ItemViewModel.cs
+++ b/Bitvault/ItemViewModel.cs
@@ -49,7 +49,7 @@ public partial class ItemViewModel :
Archived = archived;
Name = name;
- Add(name, state);
+ Add("", name, state);
Add();
}