Initial support for masking
This commit is contained in:
@@ -6,17 +6,6 @@
|
|||||||
x:DataType="vm:ItemMaskedTextEntryViewModel"
|
x:DataType="vm:ItemMaskedTextEntryViewModel"
|
||||||
Header="{Binding Key}">
|
Header="{Binding Key}">
|
||||||
<SettingsExpander.Footer>
|
<SettingsExpander.Footer>
|
||||||
<TextBox HorizontalAlignment="Right" Text="{Binding Value}">
|
<MaskedTextBox Mask="{Binding Pattern}" Text="{Binding Value}" />
|
||||||
<Interaction.Behaviors>
|
|
||||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
|
|
||||||
<AddClassAction ClassName="Read" RemoveIfExists="True" />
|
|
||||||
<RemoveClassAction ClassName="Write" />
|
|
||||||
</DataTriggerBehavior>
|
|
||||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
|
||||||
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
|
||||||
<RemoveClassAction ClassName="Read" />
|
|
||||||
</DataTriggerBehavior>
|
|
||||||
</Interaction.Behaviors>
|
|
||||||
</TextBox>
|
|
||||||
</SettingsExpander.Footer>
|
</SettingsExpander.Footer>
|
||||||
</SettingsExpander>
|
</SettingsExpander>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<Parameter Key="Name" Value="{Binding Name}" />
|
<Parameter Key="Name" Value="{Binding Name}" />
|
||||||
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
<Parameter Key="Favourite" Value="{Binding Favourite}" />
|
||||||
<Parameter Key="Archived" Value="{Binding Archived}" />
|
<Parameter Key="Archived" Value="{Binding Archived}" />
|
||||||
|
<Parameter Key="NavigationStackEnabled" Value="{x:False}" />
|
||||||
</NavigateAction>
|
</NavigateAction>
|
||||||
</AttachedEventTriggerBehaviour>
|
</AttachedEventTriggerBehaviour>
|
||||||
</Interaction.Behaviors>
|
</Interaction.Behaviors>
|
||||||
|
|||||||
@@ -6,12 +6,16 @@
|
|||||||
x:DataType="vm:ItemTextEntryViewModel"
|
x:DataType="vm:ItemTextEntryViewModel"
|
||||||
Header="{Binding Key}">
|
Header="{Binding Key}">
|
||||||
<SettingsExpander.Footer>
|
<SettingsExpander.Footer>
|
||||||
<TextBox HorizontalAlignment="Right" Text="{Binding Value}">
|
<TextBox Text="{Binding Value}">
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
|
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Read}">
|
||||||
<AddClassAction ClassName="Read" RemoveIfExists="True" />
|
<AddClassAction ClassName="Read" RemoveIfExists="True" />
|
||||||
<RemoveClassAction ClassName="Write" />
|
<RemoveClassAction ClassName="Write" />
|
||||||
</DataTriggerBehavior>
|
</DataTriggerBehavior>
|
||||||
|
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.New}">
|
||||||
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
</DataTriggerBehavior>
|
||||||
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
||||||
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
<RemoveClassAction ClassName="Read" />
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
|||||||
@@ -98,18 +98,25 @@ public record ItemConfiguration
|
|||||||
new DropdownEntryConfiguration
|
new DropdownEntryConfiguration
|
||||||
{
|
{
|
||||||
Label = "Type",
|
Label = "Type",
|
||||||
|
Values = ["American Express", "Discover", "Maestro", "Mastercard", "Visa"],
|
||||||
},
|
},
|
||||||
new MaskedTextEntryConfiguration
|
new MaskedTextEntryConfiguration
|
||||||
{
|
{
|
||||||
Label = "Card number"
|
Label = "Card number",
|
||||||
|
Pattern = "0000-0000-0000-0000",
|
||||||
|
Value = "____-____-____-____",
|
||||||
},
|
},
|
||||||
new MaskedTextEntryConfiguration
|
new MaskedTextEntryConfiguration
|
||||||
{
|
{
|
||||||
Label = "Expiry date"
|
Label = "Expiry date",
|
||||||
|
Pattern = "00/00",
|
||||||
|
Value = "__/__",
|
||||||
},
|
},
|
||||||
new MaskedTextEntryConfiguration
|
new MaskedTextEntryConfiguration
|
||||||
{
|
{
|
||||||
Label = "Card verification code"
|
Label = "Card verification code",
|
||||||
|
Pattern = "000",
|
||||||
|
Value = "___",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public partial class ItemDropdownEntryViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? key = default,
|
string? key = default,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, configuration, key, value);
|
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||||
@@ -10,7 +10,7 @@ public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
{
|
{
|
||||||
if (args.Value is DropdownEntryConfiguration configuration)
|
if (args.Value is DropdownEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>(configuration, configuration.Label, configuration.Value ?? "")
|
if (serviceFactory.Create<ItemDropdownEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||||
is ItemDropdownEntryViewModel viewModel)
|
is ItemDropdownEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? key = default,
|
string? key = default,
|
||||||
object? value = default) :
|
object? value = default) :
|
||||||
@@ -19,7 +20,7 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
|||||||
INotificationHandler<CancelEventArgs<Item>>
|
INotificationHandler<CancelEventArgs<Item>>
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private ItemState state = ItemState.Read;
|
private ItemState state = state;
|
||||||
|
|
||||||
protected override void OnValueChanged() =>
|
protected override void OnValueChanged() =>
|
||||||
configuration.Value = Value;
|
configuration.Value = Value;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Toolkit.Foundation;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
@@ -8,6 +9,12 @@ public partial class ItemMaskedTextEntryViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
|
string? pattern,
|
||||||
string? key = default,
|
string? key = default,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, configuration, key, value);
|
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value)
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private string? pattern = pattern;
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ public class ItemMaskedTextEntryViewModelHandler(IServiceFactory serviceFactory)
|
|||||||
{
|
{
|
||||||
if (args.Value is MaskedTextEntryConfiguration configuration)
|
if (args.Value is MaskedTextEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>(configuration, configuration.Label, configuration.Value ?? "")
|
if (serviceFactory.Create<ItemMaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Pattern, configuration.Label, configuration.Value])
|
||||||
is ItemMaskedTextEntryViewModel viewModel)
|
is ItemMaskedTextEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public partial class ItemPasswordEntryViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? key = default,
|
string? key = default,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, configuration, key, value);
|
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||||
@@ -10,7 +10,7 @@ public class ItemPasswordEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
{
|
{
|
||||||
if (args.Value is PasswordEntryConfiguration configuration)
|
if (args.Value is PasswordEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemPasswordEntryViewModel>(configuration, configuration.Label, configuration.Value ?? "")
|
if (serviceFactory.Create<ItemPasswordEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||||
is ItemPasswordEntryViewModel viewModel)
|
is ItemPasswordEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public partial class ItemTextEntryViewModel(IServiceProvider provider,
|
|||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? key = default,
|
string? key = default,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, configuration, key, value);
|
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||||
@@ -10,7 +10,7 @@ public class ItemTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
{
|
{
|
||||||
if (args.Value is TextEntryConfiguration configuration)
|
if (args.Value is TextEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemTextEntryViewModel>(configuration, configuration.Label, configuration.Value ?? "")
|
if (serviceFactory.Create<ItemTextEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
||||||
is ItemTextEntryViewModel viewModel)
|
is ItemTextEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class SynchronizeItemContentFromCategoryViewModelHandler(IItemConfigurati
|
|||||||
Type messageType = typeof(CreateEventArgs<>).MakeGenericType(entryConfiguration.GetType());
|
Type messageType = typeof(CreateEventArgs<>).MakeGenericType(entryConfiguration.GetType());
|
||||||
ConstructorInfo? constructor = messageType.GetConstructor([entryConfiguration.GetType(), typeof(object[])]);
|
ConstructorInfo? constructor = messageType.GetConstructor([entryConfiguration.GetType(), typeof(object[])]);
|
||||||
|
|
||||||
if (constructor?.Invoke(new object[] { entryConfiguration, new object[] { sectionViewModel } }) is object message)
|
if (constructor?.Invoke(new object[] { entryConfiguration, new object[] { ItemState.New } }) is object message)
|
||||||
{
|
{
|
||||||
if (await mediator.Handle<object, IItemEntryViewModel?>(message,
|
if (await mediator.Handle<object, IItemEntryViewModel?>(message,
|
||||||
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class SynchronizeItemContentViewModelHandler(IDecoratorService<Item<(Guid
|
|||||||
Type messageType = typeof(CreateEventArgs<>).MakeGenericType(entryConfiguration.GetType());
|
Type messageType = typeof(CreateEventArgs<>).MakeGenericType(entryConfiguration.GetType());
|
||||||
ConstructorInfo? constructor = messageType.GetConstructor([entryConfiguration.GetType(), typeof(object[])]);
|
ConstructorInfo? constructor = messageType.GetConstructor([entryConfiguration.GetType(), typeof(object[])]);
|
||||||
|
|
||||||
if (constructor?.Invoke(new object[] { entryConfiguration, new object[] { sectionViewModel } }) is object message)
|
if (constructor?.Invoke(new object[] { entryConfiguration, new object[] { ItemState.Read } }) is object message)
|
||||||
{
|
{
|
||||||
if (await mediator.Handle<object, IItemEntryViewModel?>(message,
|
if (await mediator.Handle<object, IItemEntryViewModel?>(message,
|
||||||
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
entryConfiguration.GetType().Name) is IItemEntryViewModel entryViewModel)
|
||||||
|
|||||||
Reference in New Issue
Block a user