diff --git a/Wallet.Avalonia/App.axaml.cs b/Wallet.Avalonia/App.axaml.cs index b601254..b91cbfa 100644 --- a/Wallet.Avalonia/App.axaml.cs +++ b/Wallet.Avalonia/App.axaml.cs @@ -105,8 +105,9 @@ public partial class App : Application } }); + services.AddHandler(); services.AddHandler(); - services.AddHandler(); + services.AddHandler(); services.AddHandler(); services.AddHandler(); services.AddHandler(); @@ -212,7 +213,9 @@ public partial class App : Application })!); services.AddTransient(); + services.AddHandler(); + services.AddHandler(); services.AddSingleton(); services.AddInitializer(); diff --git a/Wallet.Avalonia/CreateWalletView.axaml b/Wallet.Avalonia/CreateWalletView.axaml index 6841d89..2e31d30 100644 --- a/Wallet.Avalonia/CreateWalletView.axaml +++ b/Wallet.Avalonia/CreateWalletView.axaml @@ -83,8 +83,8 @@ - - + + , IImageDescriptor>(Request.As()); + } + public CreateWalletViewModel(IValidation validation, IServiceProvider provider, IServiceFactory factory, diff --git a/Wallet/RequestItemHandler.cs b/Wallet/ItemHandler.cs similarity index 92% rename from Wallet/RequestItemHandler.cs rename to Wallet/ItemHandler.cs index 388e76f..c64a250 100644 --- a/Wallet/RequestItemHandler.cs +++ b/Wallet/ItemHandler.cs @@ -5,13 +5,13 @@ using Toolkit.Foundation; namespace Wallet; -public class RequestItemHandler(IDbContextFactory dbContextFactory) : +public class ItemHandler(IDbContextFactory dbContextFactory) : IHandler>, (Guid, string, string?, string, ItemConfiguration?)> { public async Task<(Guid, string, string?, string, ItemConfiguration?)> Handle(RequestEventArgs> args, CancellationToken cancellationToken) { - if (args.Value is Item item) + if (args.Sender is Item item) { Guid id = item.Value; diff --git a/Wallet/ProfileImage.cs b/Wallet/ProfileImage.cs new file mode 100644 index 0000000..44633e9 --- /dev/null +++ b/Wallet/ProfileImage.cs @@ -0,0 +1,3 @@ +namespace Wallet; + +public record ProfileImage; diff --git a/Wallet/ProfileImageHandler.cs b/Wallet/ProfileImageHandler.cs new file mode 100644 index 0000000..00f9d84 --- /dev/null +++ b/Wallet/ProfileImageHandler.cs @@ -0,0 +1,22 @@ +using Toolkit.Foundation; + +namespace Wallet; + +public class ProfileImageHandler(IFileProvider fileProvider, + IImageProvider imageProvider) : + IHandler, IImageDescriptor?> +{ + public async Task Handle(RequestEventArgs args, + CancellationToken cancellationToken) + { + if (await fileProvider.SelectFiles(new FileFilter("Image files", ["jpg", "jpeg", "png"])) is { Count: 1 } files) + { + if (files.FirstOrDefault() is string file) + { + return await imageProvider.Get(file, 100, 100, true); + } + } + + return default; + } +}