WIP
This commit is contained in:
@@ -177,10 +177,14 @@ public partial class App : Application
|
||||
services.AddTemplate<ItemSectionViewModel, ItemSectionView>();
|
||||
|
||||
services.AddTemplate<TextEntryViewModel, TextEntryView>();
|
||||
services.AddTemplate<MultilineTextEntryViewModel, MultilineTextEntryView>();
|
||||
|
||||
services.AddTemplate<CreateCommentEntryViewModel, CreateCommentEntryView>();
|
||||
services.AddTemplate<CommentEntryViewModel, CommentEntryView>();
|
||||
services.AddTemplate<CommentEntryCollectionViewModel, CommentEntryCollectionView>();
|
||||
|
||||
services.AddTemplate<PasswordEntryViewModel, PasswordEntryView>();
|
||||
services.AddTemplate<MaskedTextEntryViewModel, MaskedTextEntryView>();
|
||||
services.AddTemplate<DropdownEntryViewModel, DropdownEntryView>();
|
||||
services.AddTemplate<DropdownEntryCollectionViewModel, DropdownEntryCollectionView>();
|
||||
services.AddTemplate<DateEntryViewModel, DateEntryView>();
|
||||
services.AddTemplate<HyperlinkEntryViewModel, HyperlinkEntryView>();
|
||||
services.AddTemplate<PinEntryViewModel, PinEntryView>();
|
||||
@@ -209,10 +213,10 @@ public partial class App : Application
|
||||
services.AddHandler<UnfavouriteItemHandler>();
|
||||
|
||||
services.AddHandler<TextEntryViewModelHandler>(nameof(TextEntryConfiguration));
|
||||
services.AddHandler<MultilineTextEntryViewModelHandler>(nameof(MultilineTextEntryConfiguration));
|
||||
services.AddHandler<CommentEntryCollectionViewModelHandler>(nameof(CommentEntryCollectionConfiguration));
|
||||
services.AddHandler<PasswordEntryViewModelHandler>(nameof(PasswordEntryConfiguration));
|
||||
services.AddHandler<MaskedTextEntryViewModelHandler>(nameof(MaskedTextEntryConfiguration));
|
||||
services.AddHandler<DropdownEntryViewModelHandler>(nameof(DropdownEntryConfiguration));
|
||||
services.AddHandler<DropdownEntryCollectionViewModelHandler>(nameof(DropdownEntryCollectionConfiguration));
|
||||
services.AddHandler<DateEntryViewModelHandler>(nameof(DateEntryConfiguration));
|
||||
services.AddHandler<HyperlinkEntryViewModelHandler>(nameof(HyperlinkEntryConfiguration));
|
||||
services.AddHandler<PinEntryViewModelHandler>(nameof(PinEntryConfiguration));
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<SettingsExpander
|
||||
x:Class="Wallet.Avalonia.CommentEntryCollectionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:CommentEntryCollectionViewModel"
|
||||
Header="{Binding Key}"
|
||||
IsExpanded="True"
|
||||
ItemTemplate="{ReflectionBinding Template}"
|
||||
ItemsSource="{Binding}" />
|
||||
+2
-2
@@ -2,9 +2,9 @@ using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Wallet.Avalonia;
|
||||
|
||||
public partial class MultilineTextEntryView :
|
||||
public partial class CommentEntryCollectionView :
|
||||
SettingsExpander
|
||||
{
|
||||
public MultilineTextEntryView() =>
|
||||
public CommentEntryCollectionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<SettingsExpanderItem
|
||||
x:Class="Wallet.Avalonia.CommentEntryView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:CommentEntryViewModel"
|
||||
Content="{Binding Value}"
|
||||
Description="{Binding Key}" />
|
||||
@@ -0,0 +1,11 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Wallet.Avalonia
|
||||
{
|
||||
public partial class CommentEntryView :
|
||||
SettingsExpanderItem
|
||||
{
|
||||
public CommentEntryView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<SettingsExpanderItem
|
||||
x:Class="Wallet.Avalonia.CreateCommentEntryView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:CreateCommentEntryViewModel">
|
||||
<SettingsExpanderItem.Resources>
|
||||
<ControlTheme x:Key="TextBoxAddButtonStyle" TargetType="Button">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlButtonForeground}" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlButtonBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate>
|
||||
<Border
|
||||
Name="ButtonLayoutGrid"
|
||||
Margin="{DynamicResource TextBoxInnerButtonMargin}"
|
||||
Background="Transparent"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<SymbolIcon
|
||||
Name="Glyph"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="{StaticResource TextBoxIconFontSize}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Symbol="Add" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^:pointerover">
|
||||
<Style Selector="^ /template/ Border#ButtonLayoutGrid">
|
||||
<Setter Property="Background" Value="{DynamicResource TextControlButtonBackgroundPointerOver}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlButtonBorderBrushPointerOver}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ SymbolIcon#Glyph">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlButtonForegroundPointerOver}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:pressed">
|
||||
<Style Selector="^ /template/ Border#ButtonLayoutGrid">
|
||||
<Setter Property="Background" Value="{DynamicResource TextControlButtonBackgroundPressed}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource TextControlButtonBorderBrushPressed}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ SymbolIcon#Glyph">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextControlButtonForegroundPressed}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:disabled /template/ Border#ButtonLayoutGrid">
|
||||
<Setter Property="Opacity" Value="0" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
</SettingsExpanderItem.Resources>
|
||||
<TextBox
|
||||
MaxHeight="216"
|
||||
AcceptsReturn="True"
|
||||
Text="{Binding Value}"
|
||||
TextWrapping="Wrap"
|
||||
Watermark="Add a note">
|
||||
<TextBox.InnerRightContent>
|
||||
<Button
|
||||
Width="30"
|
||||
Padding="{StaticResource HelperButtonThemePadding}"
|
||||
VerticalAlignment="Stretch"
|
||||
Command="{Binding InvokeCommand}"
|
||||
Content="Add"
|
||||
CornerRadius="{DynamicResource ControlCornerRadius}"
|
||||
Focusable="False"
|
||||
IsTabStop="False"
|
||||
Theme="{StaticResource TextBoxAddButtonStyle}" />
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
</SettingsExpanderItem>
|
||||
@@ -0,0 +1,10 @@
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Wallet.Avalonia;
|
||||
|
||||
public partial class CreateCommentEntryView :
|
||||
SettingsExpanderItem
|
||||
{
|
||||
public CreateCommentEntryView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
<SettingsExpander
|
||||
x:Class="Wallet.Avalonia.DropdownEntryView"
|
||||
x:Class="Wallet.Avalonia.DropdownEntryCollectionView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:DropdownEntryViewModel"
|
||||
x:DataType="vm:DropdownEntryCollectionViewModel"
|
||||
Header="{Binding Key}"
|
||||
IsExpanded="False">
|
||||
<SettingsExpander.Resources>
|
||||
+2
-2
@@ -2,9 +2,9 @@ using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
namespace Wallet.Avalonia;
|
||||
|
||||
public partial class DropdownEntryView :
|
||||
public partial class DropdownEntryCollectionView :
|
||||
SettingsExpander
|
||||
{
|
||||
public DropdownEntryView() =>
|
||||
public DropdownEntryCollectionView() =>
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<SettingsExpander
|
||||
x:Class="Wallet.Avalonia.MultilineTextEntryView"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="using:Wallet"
|
||||
x:DataType="vm:MultilineTextEntryViewModel"
|
||||
Header="{Binding Key}"
|
||||
IsExpanded="True"
|
||||
IsToggleable="True">
|
||||
<TextBox
|
||||
Text="{Binding Value}"
|
||||
TextWrapping="Wrap"
|
||||
Watermark="Add a note">
|
||||
<TextBox.Styles>
|
||||
<Style Selector="TextBox.Write">
|
||||
<Setter Property="MaxHeight" Value="216" />
|
||||
<Setter Property="AcceptsTab" Value="True" />
|
||||
<Setter Property="AcceptsReturn" Value="True" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
<Style Selector="TextBox.Read">
|
||||
<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>
|
||||
</TextBox>
|
||||
</SettingsExpander>
|
||||
@@ -74,8 +74,8 @@
|
||||
<Compile Update="DismissItemActionView.axaml.cs">
|
||||
<DependentUpon>DismissItemActionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="DropdownEntryView.axaml.cs">
|
||||
<DependentUpon>DropdownEntryView.axaml</DependentUpon>
|
||||
<Compile Update="DropdownEntryCollectionView.axaml.cs">
|
||||
<DependentUpon>DropdownEntryCollectionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="ItemHeaderView.axaml.cs">
|
||||
<DependentUpon>ItemHeaderView.axaml</DependentUpon>
|
||||
@@ -86,6 +86,9 @@
|
||||
<Compile Update="FavouritesNavigationView.axaml.cs">
|
||||
<DependentUpon>FavouritesNavigationView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="CommentEntryCollectionView.axaml.cs">
|
||||
<DependentUpon>CommentEntryCollectionView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="TextEntryView.axaml.cs">
|
||||
<DependentUpon>TextEntryView.axaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record AttachmentEntryCollectionConfiguration :
|
||||
ItemEntryConfiguration;
|
||||
@@ -0,0 +1,17 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class AttachmentEntryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
ICollection<Comment<(string, DateTimeOffset)>> 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);
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record AttachmentEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class AttachmentEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string? value = default) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer, value);
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record CommentEntryCollectionConfiguration :
|
||||
ItemEntryConfiguration;
|
||||
@@ -0,0 +1,33 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class CommentEntryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IContentTemplate template,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
ICollection<Comment<(string, DateTimeOffset)>> 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>>>
|
||||
{
|
||||
public IContentTemplate Template { get; set; } = template;
|
||||
|
||||
public Task Handle(CreateEventArgs<Comment<string>> args)
|
||||
{
|
||||
if (args.Sender is Comment<string> comment)
|
||||
{
|
||||
Insert<CommentEntryViewModel>(0, DateTimeOffset.Now, comment.Value);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public class CommentEntryCollectionViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<CreateEventArgs<CommentEntryCollectionConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<CommentEntryCollectionConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Sender is CommentEntryCollectionConfiguration configuration)
|
||||
{
|
||||
string? label = configuration.Label;
|
||||
string? value = $"{configuration.Value}" ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<CommentEntryCollectionViewModel>(args => args.Initialize(),
|
||||
[.. args.Parameters, configuration, label, value, false, false, width])
|
||||
is CommentEntryCollectionViewModel viewModel)
|
||||
{
|
||||
|
||||
viewModel.Add<CreateCommentEntryViewModel>();
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class CommentEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
DateTimeOffset key,
|
||||
string? value = default) : Observable<DateTimeOffset, string>(provider, factory, mediator, publisher, subscriber, disposer, key, value),
|
||||
ICommentEntryViewModel;
|
||||
@@ -0,0 +1,22 @@
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public record Comment<TValue>(TValue Value);
|
||||
|
||||
public partial class CreateCommentEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer),
|
||||
ICommentEntryViewModel
|
||||
{
|
||||
[RelayCommand]
|
||||
private void Invoke()
|
||||
{
|
||||
Publisher.Publish(Create.As(new Comment<string?>(Value)));
|
||||
Value = null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public record DropdownEntryConfiguration :
|
||||
public record DropdownEntryCollectionConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
@@ -0,0 +1,43 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class DropdownEntryCollectionViewModel :
|
||||
ItemEntryCollectionViewModel<DropdownEntryViewModel, object>
|
||||
{
|
||||
public DropdownEntryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IEnumerable<DropdownEntryViewModel> items,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width,
|
||||
DropdownEntryViewModel selectedItem) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, isConcealed, isRevealed, width)
|
||||
{
|
||||
SelectedItem = selectedItem;
|
||||
}
|
||||
|
||||
public DropdownEntryCollectionViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IEnumerable<DropdownEntryViewModel> items,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, isConcealed, isRevealed, width)
|
||||
{
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -2,31 +2,31 @@
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public class DropdownEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<CreateEventArgs<DropdownEntryConfiguration>, IItemEntryViewModel?>
|
||||
public class DropdownEntryCollectionViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<CreateEventArgs<DropdownEntryCollectionConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<DropdownEntryConfiguration> args,
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<DropdownEntryCollectionConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Sender is DropdownEntryConfiguration configuration)
|
||||
if (args.Sender is DropdownEntryCollectionConfiguration configuration)
|
||||
{
|
||||
List<DropdownValueViewModel> values = [];
|
||||
values.Add(serviceFactory.Create<DropdownValueViewModel>());
|
||||
List<DropdownEntryViewModel> values = [];
|
||||
values.Add(serviceFactory.Create<DropdownEntryViewModel>());
|
||||
|
||||
foreach (string item in configuration.Values)
|
||||
{
|
||||
values.Add(serviceFactory.Create<DropdownValueViewModel>(item));
|
||||
values.Add(serviceFactory.Create<DropdownEntryViewModel>(item));
|
||||
}
|
||||
|
||||
string? label = configuration.Label;
|
||||
object? value = configuration.Value ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
DropdownValueViewModel? selected = values.FirstOrDefault(x => x.Value is not null && x.Value.Equals($"{value}"));
|
||||
DropdownEntryViewModel? selected = values.FirstOrDefault(x => x.Value is not null && x.Value.Equals($"{value}"));
|
||||
|
||||
if (serviceFactory.Create<DropdownEntryViewModel>(args => args.Initialize(),
|
||||
if (serviceFactory.Create<DropdownEntryCollectionViewModel>(args => args.Initialize(),
|
||||
[values, .. args.Parameters, configuration, label, value, false, false, width, selected ?? null])
|
||||
is DropdownEntryViewModel viewModel)
|
||||
is DropdownEntryCollectionViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
@@ -2,42 +2,10 @@
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class DropdownEntryViewModel :
|
||||
ItemEntryCollectionViewModel<DropdownValueViewModel>
|
||||
{
|
||||
public DropdownEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IEnumerable<DropdownValueViewModel> items,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width,
|
||||
DropdownValueViewModel selectedItem) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, isConcealed, isRevealed, width)
|
||||
{
|
||||
SelectedItem = selectedItem;
|
||||
}
|
||||
|
||||
public DropdownEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
IEnumerable<DropdownValueViewModel> items,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, items, state, configuration, key, value, isConcealed, isRevealed, width)
|
||||
{
|
||||
}
|
||||
}
|
||||
public partial class DropdownEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string? value = default) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer, value);
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class DropdownValueViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
string? value = null) : Observable<string>(provider, factory, mediator, publisher, subscriber, disposer, value);
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Wallet;
|
||||
|
||||
public interface ICommentEntryViewModel : IItemEntryViewModel;
|
||||
+24
-24
@@ -24,7 +24,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Date of birth"
|
||||
},
|
||||
new DropdownEntryConfiguration
|
||||
new DropdownEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Gender",
|
||||
Values = ["Male", "Female", "Non-binary", "Prefer not to say", "Other"]
|
||||
@@ -82,7 +82,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Name on account"
|
||||
},
|
||||
new DropdownEntryConfiguration
|
||||
new DropdownEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Type",
|
||||
Values = [
|
||||
@@ -157,7 +157,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Entries = new List<ItemEntryConfiguration>
|
||||
{
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -178,7 +178,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Description",
|
||||
},
|
||||
new AttachmentEntryConfiguration
|
||||
new AttachmentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Attachments",
|
||||
}
|
||||
@@ -219,11 +219,11 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Price"
|
||||
},
|
||||
new AttachmentEntryConfiguration
|
||||
new AttachmentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Ticket"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -317,7 +317,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Two-factor Authentication (2FA)"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -342,7 +342,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Expiration Date"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -391,7 +391,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Documentation URL"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Additional Notes"
|
||||
}
|
||||
@@ -428,11 +428,11 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Major/Field of Study"
|
||||
},
|
||||
new AttachmentEntryConfiguration
|
||||
new AttachmentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Attachments"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -473,7 +473,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Due Date"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -518,7 +518,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Contact Information"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -567,11 +567,11 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Contact Information"
|
||||
},
|
||||
new AttachmentEntryConfiguration
|
||||
new AttachmentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Attachments"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -616,11 +616,11 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Purpose/Details"
|
||||
},
|
||||
new AttachmentEntryConfiguration
|
||||
new AttachmentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Attachments"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -669,7 +669,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Backup Seed Phrase"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -738,7 +738,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Passport Photo"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -759,7 +759,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Cardholder"
|
||||
},
|
||||
new DropdownEntryConfiguration
|
||||
new DropdownEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Type",
|
||||
Values = ["American Express", "Discover", "Maestro", "Mastercard", "Visa"]
|
||||
@@ -807,7 +807,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Interest Rates",
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Rewards"
|
||||
}
|
||||
@@ -878,7 +878,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Remote Desktop URL"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -939,7 +939,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Backup Location"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
@@ -996,7 +996,7 @@ public record ItemConfiguration
|
||||
{
|
||||
Label = "Usage Restrictions"
|
||||
},
|
||||
new MultilineTextEntryConfiguration
|
||||
new CommentEntryCollectionConfiguration
|
||||
{
|
||||
Label = "Notes"
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
ObservableCollection<TItem, string, object>,
|
||||
public partial class ItemEntryCollectionViewModel<TItem, TValue> :
|
||||
ObservableCollection<TItem, string, TValue>,
|
||||
IItemEntryViewModel,
|
||||
INotificationHandler<UpdateEventArgs<Item>>,
|
||||
INotificationHandler<ConfirmEventArgs<Item>>,
|
||||
INotificationHandler<CancelEventArgs<Item>>
|
||||
where TItem : notnull,
|
||||
where TItem : notnull,
|
||||
IDisposable
|
||||
{
|
||||
private readonly ItemEntryConfiguration configuration;
|
||||
@@ -23,6 +23,7 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
|
||||
[ObservableProperty]
|
||||
private ItemState state;
|
||||
|
||||
[ObservableProperty]
|
||||
private double width;
|
||||
|
||||
@@ -35,7 +36,7 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
TValue value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, key, value)
|
||||
@@ -60,7 +61,7 @@ public partial class ItemEntryCollectionViewModel<TItem> :
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
object value,
|
||||
TValue value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : base(provider, factory, mediator, publisher, subscriber, disposer, items, key, value)
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
[JsonDerivedType(typeof(DropdownEntryConfiguration), typeDiscriminator: "Dropdown")]
|
||||
[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: "Image")]
|
||||
[JsonDerivedType(typeof(AttachmentEntryConfiguration), typeDiscriminator: "Attachment")]
|
||||
[JsonDerivedType(typeof(MultilineTextEntryConfiguration), typeDiscriminator: "MultilineText")]
|
||||
[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")]
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Wallet;
|
||||
|
||||
public record MultilineTextEntryConfiguration :
|
||||
ItemEntryConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public partial class MultilineTextEntryViewModel(IServiceProvider provider,
|
||||
IServiceFactory factory,
|
||||
IMediator mediator,
|
||||
IPublisher publisher,
|
||||
ISubscriber subscriber,
|
||||
IDisposer disposer,
|
||||
ItemState state,
|
||||
ItemEntryConfiguration configuration,
|
||||
string key,
|
||||
string value,
|
||||
bool isConcealed,
|
||||
bool isRevealed,
|
||||
double width) : ItemEntryViewModel<string>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, isConcealed, isRevealed, width);
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Wallet;
|
||||
|
||||
public class MultilineTextEntryViewModelHandler(IServiceFactory serviceFactory) :
|
||||
IHandler<CreateEventArgs<MultilineTextEntryConfiguration>, IItemEntryViewModel?>
|
||||
{
|
||||
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<MultilineTextEntryConfiguration> args,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (args.Sender is MultilineTextEntryConfiguration configuration)
|
||||
{
|
||||
string? label = configuration.Label;
|
||||
string? value = $"{configuration.Value}" ?? "";
|
||||
double? width = configuration.Width;
|
||||
|
||||
if (serviceFactory.Create<MultilineTextEntryViewModel>(args => args.Initialize(),
|
||||
[.. args.Parameters, configuration, label, value, false, false, width])
|
||||
is MultilineTextEntryViewModel viewModel)
|
||||
{
|
||||
return Task.FromResult<IItemEntryViewModel?>(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult<IItemEntryViewModel?>(default);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user