Ensure we have value reverting working in the itementries
This commit is contained in:
@@ -11,6 +11,8 @@ public class DropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
if (args.Sender is DropdownEntryConfiguration configuration)
|
||||
{
|
||||
List<DropdownValueViewModel> values = [];
|
||||
values.Add(serviceFactory.Create<DropdownValueViewModel>());
|
||||
|
||||
foreach (string item in configuration.Values)
|
||||
{
|
||||
values.Add(serviceFactory.Create<DropdownValueViewModel>(item));
|
||||
|
||||
@@ -13,10 +13,18 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
where TItem : notnull,
|
||||
IDisposable
|
||||
{
|
||||
private readonly ItemEntryConfiguration configuration;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isConcealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isRevealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private ItemState state;
|
||||
|
||||
private readonly ItemEntryConfiguration configuration;
|
||||
[ObservableProperty]
|
||||
private double width;
|
||||
|
||||
public ItemEntryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
@@ -38,19 +46,10 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
IsConcealed = isConcealed;
|
||||
IsRevealed = isRevealed;
|
||||
Width = width;
|
||||
|
||||
Track(nameof(Value), () => Value, x => Value = x);
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isConcealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isRevealed;
|
||||
|
||||
|
||||
[ObservableProperty]
|
||||
private double width;
|
||||
|
||||
|
||||
public ItemEntryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -69,15 +68,11 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
this.configuration = configuration;
|
||||
|
||||
State = state;
|
||||
IsConcealed = isConcealed;
|
||||
IsRevealed = isRevealed;
|
||||
Width = width;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (configuration is not null)
|
||||
{
|
||||
configuration.Value = Value;
|
||||
}
|
||||
Track(nameof(Value), () => Value, x => Value = x);
|
||||
}
|
||||
|
||||
public Task Handle(UpdateEventArgs<Item> args) =>
|
||||
@@ -99,13 +94,20 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (configuration is not null)
|
||||
{
|
||||
configuration.Value = Value;
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Copy() => Publisher.Publish(Write.As(new Clipboard<object>($"{Value}")));
|
||||
|
||||
[RelayCommand]
|
||||
private void Hide() => IsRevealed = false;
|
||||
|
||||
[RelayCommand]
|
||||
private void Reveal() => IsRevealed = true;
|
||||
|
||||
[RelayCommand]
|
||||
private void Copy() => Publisher.Publish(Write.As(new Clipboard<object>($"{Value}")));
|
||||
}
|
||||
@@ -4,7 +4,15 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class ItemEntryViewModel<TValue>(IServiceProvider provider,
|
||||
public partial class ItemEntryViewModel<TValue> :
|
||||
Observable<string, TValue>,
|
||||
IItemEntryViewModel,
|
||||
INotificationHandler<ConfirmEventArgs<ItemEntry>>,
|
||||
INotificationHandler<UpdateEventArgs<ItemEntry>>,
|
||||
INotificationHandler<CancelEventArgs<ItemEntry>>
|
||||
where TValue : notnull
|
||||
{
|
||||
public ItemEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
@@ -16,25 +24,31 @@ public partial class ItemEntryViewModel<TValue>(IServiceProvider provider,
|
||||
TValue value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) :
|
||||
Observable<string, TValue>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
IItemEntryViewModel,
|
||||
INotificationHandler<ConfirmEventArgs<ItemEntry>>,
|
||||
INotificationHandler<UpdateEventArgs<ItemEntry>>,
|
||||
INotificationHandler<CancelEventArgs<ItemEntry>>
|
||||
where TValue : notnull
|
||||
{
|
||||
[ObservableProperty]
|
||||
private bool isConcealed = isConcealed;
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
|
||||
State = state;
|
||||
IsConcealed = isConcealed;
|
||||
IsRevealed = isRevealed;
|
||||
Width = width;
|
||||
|
||||
Track(nameof(Value), () => Value, x => Value = x);
|
||||
}
|
||||
|
||||
private readonly ItemEntryConfiguration configuration;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isRevealed = isRevealed;
|
||||
private bool isConcealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private ItemState state = state;
|
||||
private bool isRevealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private double width = width;
|
||||
private ItemState state;
|
||||
|
||||
[ObservableProperty]
|
||||
private double width;
|
||||
|
||||
public Task Handle(UpdateEventArgs<ItemEntry> args) =>
|
||||
Task.FromResult(State = ItemState.Write);
|
||||
@@ -55,8 +69,13 @@ public partial class ItemEntryViewModel<TValue>(IServiceProvider provider,
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged() =>
|
||||
protected override void OnValueChanged()
|
||||
{
|
||||
if (configuration is not null)
|
||||
{
|
||||
configuration.Value = Value;
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void Hide() => IsRevealed = false;
|
||||
|
||||
Reference in New Issue
Block a user