WIP Image imports and file access
This commit is contained in:
@@ -105,8 +105,9 @@ public partial class App : Application
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.AddHandler<ProfileImageHandler>();
|
||||||
services.AddHandler<QueryWalletHandler>();
|
services.AddHandler<QueryWalletHandler>();
|
||||||
services.AddHandler<RequestItemHandler>();
|
services.AddHandler<ItemHandler>();
|
||||||
services.AddHandler<CreateItemHandler>();
|
services.AddHandler<CreateItemHandler>();
|
||||||
services.AddHandler<DeleteItemHandler>();
|
services.AddHandler<DeleteItemHandler>();
|
||||||
services.AddHandler<UpdateItemHander>();
|
services.AddHandler<UpdateItemHander>();
|
||||||
@@ -212,7 +213,9 @@ public partial class App : Application
|
|||||||
})!);
|
})!);
|
||||||
|
|
||||||
services.AddTransient<IWalletFactory, WalletFactory>();
|
services.AddTransient<IWalletFactory, WalletFactory>();
|
||||||
|
|
||||||
services.AddHandler<CreateWalletHandler>();
|
services.AddHandler<CreateWalletHandler>();
|
||||||
|
services.AddHandler<ProfileImageHandler>();
|
||||||
|
|
||||||
services.AddSingleton<IWalletHostCollection, WalletHostCollection>();
|
services.AddSingleton<IWalletHostCollection, WalletHostCollection>();
|
||||||
services.AddInitializer<WalletInitializer>();
|
services.AddInitializer<WalletInitializer>();
|
||||||
|
|||||||
@@ -83,8 +83,8 @@
|
|||||||
</DropDownButton.Styles>
|
</DropDownButton.Styles>
|
||||||
<DropDownButton.Flyout>
|
<DropDownButton.Flyout>
|
||||||
<MenuFlyout>
|
<MenuFlyout>
|
||||||
<MenuItem Header="Import picture" />
|
<MenuItem Command="{Binding ImportCommand}" Header="Import image" />
|
||||||
<MenuItem Header="Remove picture" />
|
<MenuItem Header="Remove image" />
|
||||||
</MenuFlyout>
|
</MenuFlyout>
|
||||||
</DropDownButton.Flyout>
|
</DropDownButton.Flyout>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
@@ -27,6 +28,12 @@ public partial class CreateWalletViewModel :
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool isConfirmed;
|
private bool isConfirmed;
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
public async Task Import()
|
||||||
|
{
|
||||||
|
await Mediator.Handle<RequestEventArgs<ProfileImage>, IImageDescriptor>(Request.As<ProfileImage>());
|
||||||
|
}
|
||||||
|
|
||||||
public CreateWalletViewModel(IValidation validation,
|
public CreateWalletViewModel(IValidation validation,
|
||||||
IServiceProvider provider,
|
IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Wallet;
|
namespace Wallet;
|
||||||
|
|
||||||
public class RequestItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
|
public class ItemHandler(IDbContextFactory<WalletContext> dbContextFactory) :
|
||||||
IHandler<RequestEventArgs<Item<Guid>>, (Guid, string, string?, string, ItemConfiguration?)>
|
IHandler<RequestEventArgs<Item<Guid>>, (Guid, string, string?, string, ItemConfiguration?)>
|
||||||
{
|
{
|
||||||
public async Task<(Guid, string, string?, string, ItemConfiguration?)> Handle(RequestEventArgs<Item<Guid>> args,
|
public async Task<(Guid, string, string?, string, ItemConfiguration?)> Handle(RequestEventArgs<Item<Guid>> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (args.Value is Item<Guid> item)
|
if (args.Sender is Item<Guid> item)
|
||||||
{
|
{
|
||||||
Guid id = item.Value;
|
Guid id = item.Value;
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Wallet;
|
||||||
|
|
||||||
|
public record ProfileImage;
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using Toolkit.Foundation;
|
||||||
|
|
||||||
|
namespace Wallet;
|
||||||
|
|
||||||
|
public class ProfileImageHandler(IFileProvider fileProvider,
|
||||||
|
IImageProvider imageProvider) :
|
||||||
|
IHandler<RequestEventArgs<ProfileImage>, IImageDescriptor?>
|
||||||
|
{
|
||||||
|
public async Task<IImageDescriptor?> Handle(RequestEventArgs<ProfileImage> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user