tidy up ui

This commit is contained in:
TheXamlGuy
2024-06-10 21:34:42 +01:00
parent 7caca96b05
commit c4ba9615a3
14 changed files with 80 additions and 14 deletions
+2
View File
@@ -167,6 +167,7 @@ public partial class App : Application
services.AddTemplate<DropdownEntryViewModel, DropdownEntryView>(); services.AddTemplate<DropdownEntryViewModel, DropdownEntryView>();
services.AddTemplate<DateEntryViewModel, DateEntryView>(); services.AddTemplate<DateEntryViewModel, DateEntryView>();
services.AddTemplate<HyperlinkEntryViewModel, HyperlinkEntryView>(); services.AddTemplate<HyperlinkEntryViewModel, HyperlinkEntryView>();
services.AddTemplate<PinEntryViewModel, PinEntryView>();
services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader"); services.AddTemplate<ItemCommandHeaderViewModel, ItemCommandHeaderView>("ItemCommandHeader");
@@ -195,6 +196,7 @@ public partial class App : Application
services.AddHandler<DropdownEntryViewModelHandler>(nameof(DropdownEntryConfiguration)); services.AddHandler<DropdownEntryViewModelHandler>(nameof(DropdownEntryConfiguration));
services.AddHandler<DateEntryViewModelHandler>(nameof(DateEntryConfiguration)); services.AddHandler<DateEntryViewModelHandler>(nameof(DateEntryConfiguration));
services.AddHandler<HyperlinkEntryViewModelHandler>(nameof(HyperlinkEntryConfiguration)); services.AddHandler<HyperlinkEntryViewModelHandler>(nameof(HyperlinkEntryConfiguration));
services.AddHandler<PinEntryViewModelHandler>(nameof(PinEntryConfiguration));
services.AddHandler<ItemCreatedHandler>(ServiceLifetime.Singleton); services.AddHandler<ItemCreatedHandler>(ServiceLifetime.Singleton);
services.AddHandler<ItemModifiedHandler>(ServiceLifetime.Singleton); services.AddHandler<ItemModifiedHandler>(ServiceLifetime.Singleton);
+4 -1
View File
@@ -33,7 +33,10 @@
</DataTriggerBehavior> </DataTriggerBehavior>
</Interaction.Behaviors> </Interaction.Behaviors>
</TextBox> </TextBox>
<HyperlinkButton Command="{Binding InvokeCommand}" Content="{Binding Value}"> <HyperlinkButton
Padding="0"
Command="{Binding InvokeCommand}"
Content="{Binding Value}">
<HyperlinkButton.Styles> <HyperlinkButton.Styles>
<Style Selector="HyperlinkButton.Write"> <Style Selector="HyperlinkButton.Write">
<Setter Property="IsVisible" Value="False" /> <Setter Property="IsVisible" Value="False" />
+1 -1
View File
@@ -25,7 +25,7 @@
</ConditionAction> </ConditionAction>
</DataTriggerBehavior> </DataTriggerBehavior>
</Interaction.Behaviors> </Interaction.Behaviors>
<ScrollViewer Padding="12,12,12,0"> <ScrollViewer Padding="12,0,12,0">
<ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}"> <ItemsControl ItemTemplate="{ReflectionBinding Template}" ItemsSource="{Binding}">
<ItemsControl.ItemsPanel> <ItemsControl.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>
@@ -8,4 +8,7 @@
<NavigateAction Region="Main" Route="Manage" /> <NavigateAction Region="Main" Route="Manage" />
</EventTriggerBehavior> </EventTriggerBehavior>
</Interaction.Behaviors> </Interaction.Behaviors>
<NavigationViewItem.IconSource>
<PathIconSource Data="M692.224,655.36C684.032,655.36 677.547,657.749 672.768,662.528C667.989,667.307 665.6,673.451 665.6,680.96C665.6,688.469 667.989,694.613 672.768,699.392C677.547,704.171 683.349,706.56 690.176,706.56L743.424,706.56C750.251,706.56 756.053,704.171 760.832,699.392C765.611,694.613 768,688.469 768,680.96C768,673.451 765.611,667.307 760.832,662.528C756.053,657.749 750.251,655.36 743.424,655.36ZM153.6,321.536C153.6,301.056 161.109,283.307 176.128,268.288C191.147,253.269 209.579,245.76 231.424,245.76L716.8,245.76C745.472,245.76 769.707,255.659 789.504,275.456C809.301,295.253 819.2,319.488 819.2,348.16L819.2,362.496C835.584,370.688 848.213,382.976 857.088,399.36C865.963,415.744 870.4,432.811 870.4,450.56L870.4,860.16C870.4,888.832 860.501,913.067 840.704,932.864C820.907,952.661 796.672,962.56 768,962.56L282.624,962.56C247.125,962.56 216.747,949.931 191.488,924.672C166.229,899.413 153.6,869.717 153.6,835.584ZM716.8,296.96L231.424,296.96C223.232,296.96 216.747,299.349 211.968,304.128C207.189,308.907 204.8,315.051 204.8,322.56C204.8,330.069 207.189,336.213 211.968,340.992C216.747,345.771 223.232,348.16 231.424,348.16L768,348.16C768,334.507 762.88,322.56 752.64,312.32C742.4,302.08 730.453,296.96 716.8,296.96ZM231.424,399.36C221.867,399.36 212.992,397.995 204.8,395.264L204.8,833.536C204.8,855.381 212.309,873.813 227.328,888.832C242.347,903.851 260.779,911.36 282.624,911.36L768,911.36C781.653,911.36 793.6,906.24 803.84,896C814.08,885.76 819.2,873.813 819.2,860.16L819.2,450.56C819.2,436.907 814.08,424.96 803.84,414.72C793.6,404.48 781.653,399.36 768,399.36Z" />
</NavigationViewItem.IconSource>
</NavigationViewItem> </NavigationViewItem>
+4 -1
View File
@@ -4,7 +4,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Wallet" xmlns:vm="using:Wallet"
x:DataType="vm:ManageViewModel"> x:DataType="vm:ManageViewModel">
<ScrollViewer Padding="12" HorizontalAlignment="Stretch"> <ScrollViewer
Margin="0,44,0,0"
Padding="12,0,12,12"
HorizontalAlignment="Stretch">
<ItemsControl <ItemsControl
MaxWidth="768" MaxWidth="768"
ItemTemplate="{ReflectionBinding Template}" ItemTemplate="{ReflectionBinding Template}"
+8
View File
@@ -0,0 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Wallet.Avalonia.PinEntryView">
Welcome to Avalonia!
</UserControl>
+10
View File
@@ -0,0 +1,10 @@
using Toolkit.UI.Controls.Avalonia;
namespace Wallet.Avalonia;
public partial class PinEntryView :
SettingsExpander
{
public PinEntryView() =>
InitializeComponent();
}
@@ -82,7 +82,6 @@
<ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" /> <ComparisonCondition LeftOperand="{Binding Activated}" RightOperand="False" />
</ConditionalExpression> </ConditionalExpression>
</ConditionAction.Condition> </ConditionAction.Condition>
<NavigateAction Region="Main" Route="Wallet" />
<InvokeNavigationViewItemAction /> <InvokeNavigationViewItemAction />
</ConditionAction> </ConditionAction>
</AttachedEventTriggerBehaviour> </AttachedEventTriggerBehaviour>
+1 -4
View File
@@ -51,10 +51,7 @@
BorderThickness="1,1,0,0" BorderThickness="1,1,0,0"
CornerRadius="8 0 0 0"> CornerRadius="8 0 0 0">
<Grid RowDefinitions="Auto, *"> <Grid RowDefinitions="Auto, *">
<Border <Border Grid.Row="0" Padding="4">
Grid.Row="0"
Height="44"
Padding="4">
<ContentControl> <ContentControl>
<Interaction.Behaviors> <Interaction.Behaviors>
<AttachedBehaviour> <AttachedBehaviour>
+5 -4
View File
@@ -798,11 +798,12 @@ public record ItemConfiguration
{ {
Entries = new List<ItemEntryConfiguration> Entries = new List<ItemEntryConfiguration>
{ {
new TextEntryConfiguration
{
Label = "Pin"
},
new PinEntryConfiguration new PinEntryConfiguration
{
Label = "Pin",
Maximum = 4
},
new TextEntryConfiguration
{ {
Label = "Credit Limit", Label = "Credit Limit",
}, },
+1 -1
View File
@@ -11,7 +11,7 @@ public class MaskedTextEntryViewModelHandler(IServiceFactory serviceFactory) :
if (args.Sender is MaskedTextEntryConfiguration configuration) if (args.Sender is MaskedTextEntryConfiguration configuration)
{ {
string? label = configuration.Label; string? label = configuration.Label;
object? value = configuration.Value ?? ""; string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width; double? width = configuration.Width;
if (serviceFactory.Create<MaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Pattern, label, value, width]) if (serviceFactory.Create<MaskedTextEntryViewModel>([.. args.Parameters, configuration, configuration.Pattern, label, value, width])
-1
View File
@@ -7,4 +7,3 @@ public record PinEntryConfiguration :
public int Maximum { get; set; } public int Maximum { get; set; }
} }
+15
View File
@@ -0,0 +1,15 @@
using Toolkit.Foundation;
namespace Wallet;
public partial class PinEntryViewModel(IServiceProvider provider,
IServiceFactory factory,
IMediator mediator,
IPublisher publisher,
ISubscription subscriber,
IDisposer disposer,
ItemState state,
ItemEntryConfiguration configuration,
string key,
string value,
double width) : ItemEntryViewModel<string>(provider, factory, mediator, publisher, subscriber, disposer, state, configuration, key, value, width);
+26
View File
@@ -0,0 +1,26 @@
using Toolkit.Foundation;
namespace Wallet;
public class PinEntryViewModelHandler(IServiceFactory serviceFactory) :
IHandler<CreateEventArgs<PinEntryConfiguration>, IItemEntryViewModel?>
{
public Task<IItemEntryViewModel?> Handle(CreateEventArgs<PinEntryConfiguration> args,
CancellationToken cancellationToken)
{
if (args.Sender is PinEntryConfiguration configuration)
{
string? label = configuration.Label;
string? value = $"{configuration.Value}" ?? "";
double? width = configuration.Width;
if (serviceFactory.Create<PinEntryViewModel>([.. args.Parameters, configuration, label, value, width])
is PinEntryViewModel viewModel)
{
return Task.FromResult<IItemEntryViewModel?>(viewModel);
}
}
return Task.FromResult<IItemEntryViewModel?>(default);
}
}