Added DateEntry element
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public partial class DateEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscription subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||
@@ -0,0 +1,31 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class DateEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<CreateEventArgs<DateEntryConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<DateEntryConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Value is DateEntryConfiguration configuration)
|
||||
{
|
||||
string? label = configuration.Label;
|
||||
|
||||
if (!DateTimeOffset.TryParse($"{configuration.Value}", out DateTimeOffset value))
|
||||
{
|
||||
value = DateTimeOffset.Now;
|
||||
}
|
||||
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<DateEntryViewModel>([.. args.Parameters, configuration, label, value, width])
|
||||
is DateEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,4 @@ public partial class TextEntryViewModel(IServiceProvider provider,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||
double width) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
|
||||
|
||||
Reference in New Issue
Block a user