Initial support for masking
This commit is contained in:
@@ -6,6 +6,94 @@
|
|||||||
x:DataType="vm:ItemDropdownEntryViewModel"
|
x:DataType="vm:ItemDropdownEntryViewModel"
|
||||||
Header="{Binding Key}">
|
Header="{Binding Key}">
|
||||||
<SettingsExpander.Footer>
|
<SettingsExpander.Footer>
|
||||||
<TextBox MinWidth="264" />
|
<Grid>
|
||||||
|
<ComboBox
|
||||||
|
DisplayMemberBinding="{ReflectionBinding Value}"
|
||||||
|
ItemsSource="{Binding}"
|
||||||
|
SelectedItem="{Binding SelectedItem}"
|
||||||
|
SelectedValue="{Binding Value}"
|
||||||
|
SelectedValueBinding="{ReflectionBinding Value}">
|
||||||
|
<ComboBox.Styles>
|
||||||
|
<Style Selector="ComboBox.Write">
|
||||||
|
<Setter Property="MinWidth" Value="264" />
|
||||||
|
<Setter Property="IsVisible" Value="True" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="ComboBox.Read">
|
||||||
|
<Setter Property="MinWidth" Value="0" />
|
||||||
|
<Setter Property="IsVisible" Value="False" />
|
||||||
|
</Style>
|
||||||
|
</ComboBox.Styles>
|
||||||
|
<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.New}">
|
||||||
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
</DataTriggerBehavior>
|
||||||
|
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
||||||
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
</DataTriggerBehavior>
|
||||||
|
</Interaction.Behaviors>
|
||||||
|
</ComboBox>
|
||||||
|
<TextBox Text="{Binding Value}">
|
||||||
|
<TextBox.Styles>
|
||||||
|
<Style Selector="TextBox.Write">
|
||||||
|
<Setter Property="IsVisible" Value="False" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBox.Read">
|
||||||
|
<Setter Property="MinWidth" Value="0" />
|
||||||
|
<Setter Property="IsReadOnly" Value="True" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="IsVisible" Value="True" />
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^:pointerover">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^:focus">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Styles>
|
||||||
|
|
||||||
|
<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.New}">
|
||||||
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
</DataTriggerBehavior>
|
||||||
|
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
||||||
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
</DataTriggerBehavior>
|
||||||
|
</Interaction.Behaviors>
|
||||||
|
</TextBox>
|
||||||
|
</Grid>
|
||||||
</SettingsExpander.Footer>
|
</SettingsExpander.Footer>
|
||||||
</SettingsExpander>
|
</SettingsExpander>
|
||||||
@@ -14,11 +14,53 @@
|
|||||||
Text="{Binding Value}"
|
Text="{Binding Value}"
|
||||||
TextAlignment="Center"
|
TextAlignment="Center"
|
||||||
Watermark="Enter name">
|
Watermark="Enter name">
|
||||||
|
<TextBox.Styles>
|
||||||
|
<Style Selector="TextBox.Write">
|
||||||
|
<Setter Property="MinWidth" Value="264" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBox.Read">
|
||||||
|
<Setter Property="MinWidth" Value="0" />
|
||||||
|
<Setter Property="IsReadOnly" Value="True" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^:pointerover">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^:focus">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Styles>
|
||||||
<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" />
|
||||||
|
|||||||
@@ -6,6 +6,59 @@
|
|||||||
x:DataType="vm:ItemMaskedTextEntryViewModel"
|
x:DataType="vm:ItemMaskedTextEntryViewModel"
|
||||||
Header="{Binding Key}">
|
Header="{Binding Key}">
|
||||||
<SettingsExpander.Footer>
|
<SettingsExpander.Footer>
|
||||||
<MaskedTextBox Mask="{Binding Pattern}" Text="{Binding Value}" />
|
<MaskedTextBox Mask="{Binding Pattern}" Text="{Binding Value}">
|
||||||
|
<TextBox.Styles>
|
||||||
|
<Style Selector="TextBox.Write">
|
||||||
|
<Setter Property="MinWidth" Value="264" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBox.Read">
|
||||||
|
<Setter Property="MinWidth" Value="0" />
|
||||||
|
<Setter Property="IsReadOnly" Value="True" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^:pointerover">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^:focus">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Styles>
|
||||||
|
<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.New}">
|
||||||
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
</DataTriggerBehavior>
|
||||||
|
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.Write}">
|
||||||
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
|
<RemoveClassAction ClassName="Read" />
|
||||||
|
</DataTriggerBehavior>
|
||||||
|
</Interaction.Behaviors>
|
||||||
|
</MaskedTextBox>
|
||||||
</SettingsExpander.Footer>
|
</SettingsExpander.Footer>
|
||||||
</SettingsExpander>
|
</SettingsExpander>
|
||||||
@@ -7,15 +7,53 @@
|
|||||||
Header="{Binding Key}">
|
Header="{Binding Key}">
|
||||||
<SettingsExpander.Footer>
|
<SettingsExpander.Footer>
|
||||||
<TextBox Text="{Binding Value}">
|
<TextBox Text="{Binding Value}">
|
||||||
|
<TextBox.Styles>
|
||||||
|
<Style Selector="TextBox.Write">
|
||||||
|
<Setter Property="MinWidth" Value="264" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="TextBox.Read">
|
||||||
|
<Setter Property="MinWidth" Value="0" />
|
||||||
|
<Setter Property="IsReadOnly" Value="True" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^:pointerover">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
<Style Selector="^:focus">
|
||||||
|
<Setter Property="Foreground">
|
||||||
|
<Setter.Value>
|
||||||
|
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
<Style Selector="^ /template/ Border#PART_BorderElement">
|
||||||
|
<Setter Property="Background" Value="Transparent" />
|
||||||
|
<Setter Property="BorderBrush" Value="Transparent" />
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</Style>
|
||||||
|
</TextBox.Styles>
|
||||||
<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}">
|
<DataTriggerBehavior Binding="{Binding State}" Value="{x:Static vm:ItemState.New}">
|
||||||
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
<AddClassAction ClassName="Write" RemoveIfExists="True" />
|
||||||
<RemoveClassAction ClassName="Read" />
|
<RemoveClassAction ClassName="Read" />
|
||||||
</DataTriggerBehavior>
|
</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" />
|
||||||
|
|||||||
@@ -4,44 +4,6 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="using:Bitvault"
|
xmlns:vm="using:Bitvault"
|
||||||
x:DataType="vm:ItemViewModel">
|
x:DataType="vm:ItemViewModel">
|
||||||
<UserControl.Styles>
|
|
||||||
<Style Selector="TextBox.Write">
|
|
||||||
<Setter Property="MinWidth" Value="264" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="TextBox.Read">
|
|
||||||
<Setter Property="MinWidth" Value="0" />
|
|
||||||
<Setter Property="IsReadOnly" Value="True" />
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="Foreground">
|
|
||||||
<Setter.Value>
|
|
||||||
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
<Style Selector="^:pointerover">
|
|
||||||
<Setter Property="Foreground">
|
|
||||||
<Setter.Value>
|
|
||||||
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
<Style Selector="^ /template/ Border#PART_BorderElement">
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:focus">
|
|
||||||
<Setter Property="Foreground">
|
|
||||||
<Setter.Value>
|
|
||||||
<SolidColorBrush Opacity="0.7" Color="{DynamicResource TextFillColorPrimary}" />
|
|
||||||
</Setter.Value>
|
|
||||||
</Setter>
|
|
||||||
<Style Selector="^ /template/ Border#PART_BorderElement">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
</UserControl.Styles>
|
|
||||||
<Interaction.Behaviors>
|
<Interaction.Behaviors>
|
||||||
<AttachedBehaviour>
|
<AttachedBehaviour>
|
||||||
<NavigateAction
|
<NavigateAction
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public partial class BackActionViewModel(IServiceProvider provider,
|
|||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer)
|
IDisposer disposer) : Observable(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ public record DropdownEntryConfiguration :
|
|||||||
ItemEntryConfiguration
|
ItemEntryConfiguration
|
||||||
{
|
{
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
public string[]? Values { get; set; }
|
public IList<string> Values { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,36 @@
|
|||||||
|
|
||||||
namespace Bitvault;
|
namespace Bitvault;
|
||||||
|
|
||||||
public partial class ItemDropdownEntryViewModel(IServiceProvider provider,
|
public partial class ItemDropdownEntryViewModel :
|
||||||
IServiceFactory factory,
|
ItemEntryCollectionViewModel<ItemDropdownValueViewModel>
|
||||||
IMediator mediator,
|
{
|
||||||
IPublisher publisher,
|
public ItemDropdownEntryViewModel(IServiceProvider provider,
|
||||||
ISubscription subscriber,
|
IServiceFactory factory,
|
||||||
IDisposer disposer,
|
IMediator mediator,
|
||||||
ItemState state,
|
IPublisher publisher,
|
||||||
ItemEntryConfiguration configuration,
|
ISubscription subscriber,
|
||||||
string? key = default,
|
IDisposer disposer,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
IEnumerable<ItemDropdownValueViewModel> 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<ItemDropdownValueViewModel> items,
|
||||||
|
ItemState state,
|
||||||
|
ItemEntryConfiguration configuration,
|
||||||
|
string key,
|
||||||
|
object value) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,18 @@ public class ItemDropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
|||||||
{
|
{
|
||||||
if (args.Value is DropdownEntryConfiguration configuration)
|
if (args.Value is DropdownEntryConfiguration configuration)
|
||||||
{
|
{
|
||||||
if (serviceFactory.Create<ItemDropdownEntryViewModel>([.. args.Parameters, configuration, configuration.Label, configuration.Value ?? ""])
|
List<ItemDropdownValueViewModel> values = [];
|
||||||
|
foreach (string item in configuration.Values)
|
||||||
|
{
|
||||||
|
values.Add(serviceFactory.Create<ItemDropdownValueViewModel>(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<ItemDropdownEntryViewModel>([values, .. args.Parameters, configuration, label, value ?? "", selected])
|
||||||
is ItemDropdownEntryViewModel viewModel)
|
is ItemDropdownEntryViewModel viewModel)
|
||||||
{
|
{
|
||||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||||
|
|||||||
@@ -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<string>(provider, factory, mediator, publisher, subscriber, disposer, value);
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Bitvault;
|
||||||
|
|
||||||
|
public partial class ItemEntryCollectionViewModel<TItem> :
|
||||||
|
ObservableCollection<TItem, string, object>,
|
||||||
|
IItemEntryViewModel,
|
||||||
|
INotificationHandler<UpdateEventArgs<Item>>,
|
||||||
|
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||||
|
INotificationHandler<CancelEventArgs<Item>>
|
||||||
|
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<TItem> 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<Item> args) =>
|
||||||
|
Task.FromResult(State = ItemState.Write);
|
||||||
|
|
||||||
|
public Task Handle(CancelEventArgs<Item> args)
|
||||||
|
{
|
||||||
|
Revert();
|
||||||
|
|
||||||
|
State = ItemState.Read;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(ConfirmEventArgs<Item> args)
|
||||||
|
{
|
||||||
|
Commit();
|
||||||
|
|
||||||
|
State = ItemState.Read;
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,8 +11,8 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? key = default,
|
string key,
|
||||||
object? value = default) :
|
object value) :
|
||||||
Observable<string, object>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
Observable<string, object>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||||
IItemEntryViewModel,
|
IItemEntryViewModel,
|
||||||
INotificationHandler<UpdateEventArgs<Item>>,
|
INotificationHandler<UpdateEventArgs<Item>>,
|
||||||
@@ -43,4 +43,4 @@ public partial class ItemEntryViewModel(IServiceProvider provider,
|
|||||||
State = ItemState.Read;
|
State = ItemState.Read;
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,8 @@ public partial class ItemHeaderViewModel :
|
|||||||
ISubscription subscriber,
|
ISubscription subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
ItemState state,
|
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;
|
State = state;
|
||||||
Value = value;
|
Value = value;
|
||||||
@@ -68,6 +69,6 @@ public partial class ItemHeaderViewModel :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<string?> Handle(ConfirmEventArgs<ItemHeader> args,
|
public Task<string> Handle(ConfirmEventArgs<ItemHeader> args,
|
||||||
CancellationToken cancellationToken) => Task.FromResult(Value);
|
CancellationToken cancellationToken) => Task.FromResult(Value);
|
||||||
}
|
}
|
||||||
@@ -11,10 +11,10 @@ public partial class ItemMaskedTextEntryViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? pattern,
|
string pattern,
|
||||||
string? key = default,
|
string key,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value)
|
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value)
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private string? pattern = pattern;
|
private string pattern = pattern;
|
||||||
}
|
}
|
||||||
@@ -10,5 +10,5 @@ public partial class ItemPasswordEntryViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? key = default,
|
string key,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||||
@@ -10,5 +10,5 @@ public partial class ItemTextEntryViewModel(IServiceProvider provider,
|
|||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
ItemState state,
|
ItemState state,
|
||||||
ItemEntryConfiguration configuration,
|
ItemEntryConfiguration configuration,
|
||||||
string? key = default,
|
string key,
|
||||||
object? value = default) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
object value) : ItemEntryViewModel(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value);
|
||||||
@@ -49,7 +49,7 @@ public partial class ItemViewModel :
|
|||||||
Archived = archived;
|
Archived = archived;
|
||||||
Name = name;
|
Name = name;
|
||||||
|
|
||||||
Add<ItemHeaderViewModel>(name, state);
|
Add<ItemHeaderViewModel>("", name, state);
|
||||||
Add<ItemContentViewModel>();
|
Add<ItemContentViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user