Improved json support
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record AttachmentEntryCollectionConfiguration :
|
||||
ItemEntryConfiguration;
|
||||
ItemEntryConfiguration<string>;
|
||||
@@ -9,9 +9,9 @@ public partial class AttachmentEntryCollectionViewModel(IServiceProvider provide
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<ICollection<Comment>> configuration,
|
||||
string key,
|
||||
ICollection<Comment<(string, DateTimeOffset)>> value,
|
||||
ICollection<Comment> value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : ItemEntryCollectionViewModel<AttachmentEntryViewModel, ICollection<Comment<(string, DateTimeOffset)>>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
|
||||
double width) : ItemEntryCollectionViewModel<AttachmentEntryViewModel, ICollection<Comment>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
|
||||
|
||||
@@ -1,19 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Toolkit.Foundation;
|
||||
using Wallet.Data;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public class CloseWalletHandler(IDecoratorService<WalletConnection> walletConnectionDecorator,
|
||||
IDbContextFactory<WalletContext> dbContextFactory) :
|
||||
public class CloseWalletHandler(IDecoratorService<WalletConnection> walletConnectionDecorator) :
|
||||
IHandler<CloseEventArgs<Wallet>, bool>
|
||||
{
|
||||
public async Task<bool> Handle(CloseEventArgs<Wallet> args,
|
||||
public Task<bool> Handle(CloseEventArgs<Wallet> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
walletConnectionDecorator.Set(null);
|
||||
|
||||
return true;
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record Comment
|
||||
{
|
||||
public DateTimeOffset DateTime { get; set; }
|
||||
|
||||
public string? Text { get; set; }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record CommentEntryCollectionConfiguration :
|
||||
ItemEntryConfiguration;
|
||||
ItemEntryConfiguration<ICollection<Comment>>;
|
||||
@@ -10,21 +10,22 @@ public partial class CommentEntryCollectionViewModel(IServiceProvider provider,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
ItemEntryConfiguration<ICollection<Comment>> configuration,
|
||||
string key,
|
||||
ICollection<Comment<(string, DateTimeOffset)>> value,
|
||||
ICollection<Comment> value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : ItemEntryCollectionViewModel<ICommentEntryViewModel, ICollection<Comment<(string, DateTimeOffset)>>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width),
|
||||
INotificationHandler<CreateEventArgs<Comment<string>>>
|
||||
double width) : ItemEntryCollectionViewModel<ICommentEntryViewModel, ICollection<Comment>>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width),
|
||||
INotificationHandler<CreateEventArgs<Comment>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(CreateEventArgs<Comment<string>> args)
|
||||
public Task Handle(CreateEventArgs<Comment> args)
|
||||
{
|
||||
if (args.Sender is Comment<string> comment)
|
||||
if (args.Sender is Comment comment)
|
||||
{
|
||||
Insert<CommentEntryViewModel>(0, DateTimeOffset.Now, comment.Value);
|
||||
Insert<CommentEntryViewModel>(0, comment.DateTime, comment.Text);
|
||||
Value.Add(comment);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class CommentEntryCollectionViewModelHandler(IServiceFactory serviceFacto
|
||||
if (args.Sender is CommentEntryCollectionConfiguration configuration)
|
||||
{
|
||||
string? label = configuration.Label;
|
||||
string? value = $"{configuration.Value}" ?? "";
|
||||
List<Comment> value = new List<Comment>();
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<CommentEntryCollectionViewModel>(args => args.Initialize(),
|
||||
|
||||
@@ -3,8 +3,6 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public record Comment<TValue>(TValue Value);
|
||||
|
||||
public partial class CreateCommentEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -16,7 +14,7 @@ public partial class CreateCommentEntryViewModel(IServiceProvider provider,
|
||||
[RelayCommand]
|
||||
private void Invoke()
|
||||
{
|
||||
Publisher.Publish(Create.As(new Comment<string?>(Value)));
|
||||
Publisher.Publish(Create.As(new Comment { Text = Value, DateTime = DateTimeOffset.Now }));
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record CurrencyEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
ItemEntryConfiguration<string>;
|
||||
@@ -1,7 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record DateEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
ItemEntryConfiguration<DateTimeOffset?>;
|
||||
@@ -9,9 +9,9 @@ public partial class DateEntryViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<DateTimeOffset?> configuration,
|
||||
string key,
|
||||
DateTimeOffset value,
|
||||
DateTimeOffset? value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : ItemEntryViewModel<DateTimeOffset>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
|
||||
double width) : ItemEntryViewModel<DateTimeOffset?>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
|
||||
|
||||
@@ -12,11 +12,7 @@ public class DateEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
{
|
||||
string? label = configuration.Label;
|
||||
|
||||
if (!DateTimeOffset.TryParse($"{configuration.Value}", out DateTimeOffset value))
|
||||
{
|
||||
value = DateTimeOffset.Now;
|
||||
}
|
||||
|
||||
DateTimeOffset? value = configuration.Value is not null ? configuration.Value : DateTimeOffset.Now;
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<DateEntryViewModel>(args => args.Initialize(),
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record DropdownEntryCollectionConfiguration :
|
||||
ItemEntryConfiguration
|
||||
ItemEntryConfiguration<object>
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public IList<string> Values { get; set; } = new List<string>();
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ public partial class DropdownEntryCollectionViewModel :
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IEnumerable<DropdownEntryViewModel> items,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
ItemState state,
|
||||
DropdownEntryCollectionConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
bool isConcealed,
|
||||
@@ -32,7 +32,7 @@ public partial class DropdownEntryCollectionViewModel :
|
||||
IDisposer disposer,
|
||||
IEnumerable<DropdownEntryViewModel> items,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
DropdownEntryCollectionConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
bool isConcealed,
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record Hyperlink(string Value);
|
||||
public record Hyperlink(string? Value);
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record HyperlinkEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
ItemEntryConfiguration<string>;
|
||||
@@ -10,7 +10,7 @@ public partial class HyperlinkEntryViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<string> configuration,
|
||||
string key,
|
||||
string value,
|
||||
double width,
|
||||
|
||||
@@ -1,8 +1,37 @@
|
||||
namespace Wallet;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public interface IItemEntryConfiguration
|
||||
namespace Wallet;
|
||||
|
||||
[JsonDerivedType(typeof(DropdownEntryCollectionConfiguration), typeDiscriminator: "Dropdown")]
|
||||
[JsonDerivedType(typeof(MaskedTextEntryConfiguration), typeDiscriminator: "MaskedText")]
|
||||
[JsonDerivedType(typeof(NumberEntryConfiguration), typeDiscriminator: "Number")]
|
||||
[JsonDerivedType(typeof(PasswordEntryConfiguration), typeDiscriminator: "Password")]
|
||||
[JsonDerivedType(typeof(TextEntryConfiguration), typeDiscriminator: "Text")]
|
||||
[JsonDerivedType(typeof(ImageEntryConfiguration), typeDiscriminator: "Images")]
|
||||
[JsonDerivedType(typeof(AttachmentEntryCollectionConfiguration), typeDiscriminator: "Attachments")]
|
||||
[JsonDerivedType(typeof(CommentEntryCollectionConfiguration), typeDiscriminator: "Comments")]
|
||||
[JsonDerivedType(typeof(CurrencyEntryConfiguration), typeDiscriminator: "Currency")]
|
||||
[JsonDerivedType(typeof(DateEntryConfiguration), typeDiscriminator: "Date")]
|
||||
[JsonDerivedType(typeof(HyperlinkEntryConfiguration), typeDiscriminator: "Hyperlink")]
|
||||
[JsonDerivedType(typeof(PinEntryConfiguration), typeDiscriminator: "Pin")]
|
||||
public interface IItemEntryConfiguration<TValue> :
|
||||
IItemEntryConfiguration
|
||||
{
|
||||
string? Label { get; set; }
|
||||
|
||||
object? Value { get; set; }
|
||||
TValue? Value { get; set; }
|
||||
}
|
||||
|
||||
[JsonDerivedType(typeof(DropdownEntryCollectionConfiguration), typeDiscriminator: "Dropdown")]
|
||||
[JsonDerivedType(typeof(MaskedTextEntryConfiguration), typeDiscriminator: "MaskedText")]
|
||||
[JsonDerivedType(typeof(NumberEntryConfiguration), typeDiscriminator: "Number")]
|
||||
[JsonDerivedType(typeof(PasswordEntryConfiguration), typeDiscriminator: "Password")]
|
||||
[JsonDerivedType(typeof(TextEntryConfiguration), typeDiscriminator: "Text")]
|
||||
[JsonDerivedType(typeof(ImageEntryConfiguration), typeDiscriminator: "Images")]
|
||||
[JsonDerivedType(typeof(AttachmentEntryCollectionConfiguration), typeDiscriminator: "Attachments")]
|
||||
[JsonDerivedType(typeof(CommentEntryCollectionConfiguration), typeDiscriminator: "Comments")]
|
||||
[JsonDerivedType(typeof(CurrencyEntryConfiguration), typeDiscriminator: "Currency")]
|
||||
[JsonDerivedType(typeof(DateEntryConfiguration), typeDiscriminator: "Date")]
|
||||
[JsonDerivedType(typeof(HyperlinkEntryConfiguration), typeDiscriminator: "Hyperlink")]
|
||||
[JsonDerivedType(typeof(PinEntryConfiguration), typeDiscriminator: "Pin")]
|
||||
public interface IItemEntryConfiguration;
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record ImageEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
ItemEntryConfiguration<string>;
|
||||
|
||||
+22
-23
@@ -10,7 +10,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -76,7 +76,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new NumberEntryConfiguration
|
||||
{
|
||||
@@ -155,7 +155,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
@@ -172,7 +172,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new ()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -193,7 +193,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new ItemSectionConfiguration
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -238,7 +238,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -295,7 +295,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -332,7 +332,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new PasswordEntryConfiguration
|
||||
{
|
||||
@@ -357,7 +357,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -406,7 +406,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -447,7 +447,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -488,7 +488,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -533,7 +533,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -586,7 +586,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -635,7 +635,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -684,7 +684,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -753,7 +753,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -792,7 +792,7 @@ public record ItemConfiguration
|
||||
},
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new PinEntryConfiguration
|
||||
{
|
||||
@@ -815,7 +815,7 @@ public record ItemConfiguration
|
||||
},
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -840,7 +840,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -893,7 +893,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -954,7 +954,7 @@ public record ItemConfiguration
|
||||
{
|
||||
new()
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
Entries = new List<IItemEntryConfiguration>
|
||||
{
|
||||
new TextEntryConfiguration
|
||||
{
|
||||
@@ -1004,5 +1004,4 @@ public record ItemConfiguration
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -7,13 +7,14 @@ namespace Wallet;
|
||||
public partial class ItemEntryCollectionViewModel<TItem, TValue> :
|
||||
ObservableCollection<TItem, string, TValue>,
|
||||
IItemEntryViewModel,
|
||||
IHandler<ValidateEventArgs<ItemEntry>, bool>,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||
INotificationHandler<CancelEventArgs<Item>>
|
||||
where TItem : notnull,
|
||||
IDisposable
|
||||
{
|
||||
private readonly ItemEntryConfiguration configuration;
|
||||
private readonly IItemEntryConfiguration<TValue> configuration;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isConcealed;
|
||||
@@ -34,7 +35,7 @@ public partial class ItemEntryCollectionViewModel<TItem, TValue> :
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<TValue> configuration,
|
||||
string key,
|
||||
TValue value,
|
||||
bool isConcealed,
|
||||
@@ -59,7 +60,7 @@ public partial class ItemEntryCollectionViewModel<TItem, TValue> :
|
||||
IDisposer disposer,
|
||||
IEnumerable<TItem> items,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<TValue> configuration,
|
||||
string key,
|
||||
TValue value,
|
||||
bool isConcealed,
|
||||
@@ -95,12 +96,15 @@ public partial class ItemEntryCollectionViewModel<TItem, TValue> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
public async Task<bool> Handle(ValidateEventArgs<ItemEntry> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (configuration is not null)
|
||||
{
|
||||
configuration.Value = Value;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
@@ -14,15 +14,15 @@ namespace Wallet;
|
||||
[JsonDerivedType(typeof(DateEntryConfiguration), typeDiscriminator: "Date")]
|
||||
[JsonDerivedType(typeof(HyperlinkEntryConfiguration), typeDiscriminator: "Hyperlink")]
|
||||
[JsonDerivedType(typeof(PinEntryConfiguration), typeDiscriminator: "Pin")]
|
||||
public record ItemEntryConfiguration :
|
||||
IItemEntryConfiguration
|
||||
public record ItemEntryConfiguration<TValue> :
|
||||
IItemEntryConfiguration<TValue>
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public string? Label { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public object? Value { get; set; }
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public TValue? Value { get; set; }
|
||||
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public double? Width { get; set; } = 296;
|
||||
}
|
||||
@@ -7,11 +7,25 @@ namespace Wallet;
|
||||
public partial class ItemEntryViewModel<TValue> :
|
||||
Observable<string, TValue>,
|
||||
IItemEntryViewModel,
|
||||
IHandler<ValidateEventArgs<ItemEntry>, bool>,
|
||||
INotificationHandler<ConfirmEventArgs<ItemEntry>>,
|
||||
INotificationHandler<UpdateEventArgs<ItemEntry>>,
|
||||
INotificationHandler<CancelEventArgs<ItemEntry>>
|
||||
where TValue : notnull
|
||||
{
|
||||
private readonly IItemEntryConfiguration<TValue> configuration;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isConcealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isRevealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private ItemState state;
|
||||
|
||||
[ObservableProperty]
|
||||
private double width;
|
||||
|
||||
public ItemEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
@@ -19,7 +33,7 @@ public partial class ItemEntryViewModel<TValue> :
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<TValue> configuration,
|
||||
string key,
|
||||
TValue value,
|
||||
bool isConcealed,
|
||||
@@ -36,20 +50,6 @@ public partial class ItemEntryViewModel<TValue> :
|
||||
Track(nameof(Value), () => Value, x => Value = x);
|
||||
}
|
||||
|
||||
private readonly ItemEntryConfiguration configuration;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isConcealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool isRevealed;
|
||||
|
||||
[ObservableProperty]
|
||||
private ItemState state;
|
||||
|
||||
[ObservableProperty]
|
||||
private double width;
|
||||
|
||||
public Task Handle(UpdateEventArgs<ItemEntry> args) =>
|
||||
Task.FromResult(State = ItemState.Write);
|
||||
|
||||
@@ -69,20 +69,23 @@ public partial class ItemEntryViewModel<TValue> :
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
protected override void OnValueChanged()
|
||||
public async Task<bool> Handle(ValidateEventArgs<ItemEntry> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (configuration is not null)
|
||||
{
|
||||
configuration.Value = Value;
|
||||
}
|
||||
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
[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}")));
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using System.Xml.Linq;
|
||||
using Toolkit.Foundation;
|
||||
using Wallet.Data;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
|
||||
public record ItemSectionConfiguration
|
||||
{
|
||||
public IList<ItemEntryConfiguration> Entries { get; set; } = new List<ItemEntryConfiguration>();
|
||||
public IList<IItemEntryConfiguration> Entries { get; set; } = new List<IItemEntryConfiguration>();
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record MaskedTextEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
ItemEntryConfiguration<string>
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public string? Pattern { get; set; }
|
||||
|
||||
@@ -10,7 +10,7 @@ public partial class MaskedTextEntryViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<string> configuration,
|
||||
string pattern,
|
||||
string key,
|
||||
string value,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record NumberEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
ItemEntryConfiguration<string>
|
||||
{
|
||||
public int MinLength { get; set; }
|
||||
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record PasswordEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
ItemEntryConfiguration<string>;
|
||||
@@ -9,7 +9,7 @@ public partial class PasswordEntryViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
IItemEntryConfiguration<string> configuration,
|
||||
string key,
|
||||
string value,
|
||||
bool isConcealed,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record PinEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
ItemEntryConfiguration<string>
|
||||
{
|
||||
public int Minimum { get; set; }
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public partial class PinEntryViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
PinEntryConfiguration configuration,
|
||||
string key,
|
||||
string value,
|
||||
double width,
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record TextEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
ItemEntryConfiguration<string>;
|
||||
@@ -9,7 +9,7 @@ public partial class TextEntryViewModel(IServiceProvider provider,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
TextEntryConfiguration configuration,
|
||||
string key,
|
||||
string value,
|
||||
bool isConcealed,
|
||||
|
||||
Reference in New Issue
Block a user