Add wallet profile image loading
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Toolkit.Avalonia;
|
|||||||
public class ImageReader(IImageResizer imageResizer) :
|
public class ImageReader(IImageResizer imageResizer) :
|
||||||
IImageReader
|
IImageReader
|
||||||
{
|
{
|
||||||
public async Task<IImageDescriptor> Get(Stream stream,
|
public IImageDescriptor Get(Stream stream,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
bool maintainAspectRatio)
|
bool maintainAspectRatio)
|
||||||
|
|||||||
@@ -6,14 +6,15 @@ public class AppService(IEnumerable<IInitialization> initializers,
|
|||||||
IPublisher publisher) :
|
IPublisher publisher) :
|
||||||
IHostedService
|
IHostedService
|
||||||
{
|
{
|
||||||
public async Task StartAsync(CancellationToken cancellationToken)
|
public Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
foreach (IInitialization initializer in initializers)
|
foreach (IInitialization initializer in initializers)
|
||||||
{
|
{
|
||||||
await initializer.Initialize();
|
initializer.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
publisher.Publish<StartedEventArgs>();
|
publisher.Publish<StartedEventArgs>();
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record CancelEventArgs<TSender>(TSender sender);
|
public record CancelEventArgs<TSender>(TSender Sender);
|
||||||
@@ -14,7 +14,8 @@ public class ComponentHost(IServiceProvider services,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public TConfiguration? GetConfiguration<TConfiguration>() where TConfiguration : ComponentConfiguration
|
public TConfiguration? GetConfiguration<TConfiguration>()
|
||||||
|
where TConfiguration : ComponentConfiguration
|
||||||
{
|
{
|
||||||
return Services.GetService<TConfiguration>();
|
return Services.GetService<TConfiguration>();
|
||||||
}
|
}
|
||||||
@@ -23,7 +24,7 @@ public class ComponentHost(IServiceProvider services,
|
|||||||
{
|
{
|
||||||
foreach (IInitialization initializer in initializers)
|
foreach (IInitialization initializer in initializers)
|
||||||
{
|
{
|
||||||
await initializer.Initialize();
|
initializer.Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (IHostedService service in hostedServices)
|
foreach (IHostedService service in hostedServices)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
@@ -9,7 +10,7 @@ public class ComponentInitializer(IEnumerable<IComponent> components,
|
|||||||
IServiceProvider provider) :
|
IServiceProvider provider) :
|
||||||
IInitialization
|
IInitialization
|
||||||
{
|
{
|
||||||
public async Task Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
foreach (IComponent component in components)
|
foreach (IComponent component in components)
|
||||||
{
|
{
|
||||||
@@ -45,7 +46,7 @@ public class ComponentInitializer(IEnumerable<IComponent> components,
|
|||||||
provider.GetRequiredService<IServiceProvider>()));
|
provider.GetRequiredService<IServiceProvider>()));
|
||||||
|
|
||||||
hosts.Add(host);
|
hosts.Add(host);
|
||||||
await host.StartAsync();
|
host.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ public class ConfigurationInitializer<TConfiguration>(IConfigurationReader<TConf
|
|||||||
where TConfiguration :
|
where TConfiguration :
|
||||||
class
|
class
|
||||||
{
|
{
|
||||||
public Task Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
if (!reader.TryRead(out TConfiguration? configuration))
|
if (!reader.TryRead(out TConfiguration? configuration))
|
||||||
{
|
{
|
||||||
@@ -21,6 +21,5 @@ public class ConfigurationInitializer<TConfiguration>(IConfigurationReader<TConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
publisher.PublishUI(new ActivatedEventArgs<TConfiguration>(configuration));
|
publisher.PublishUI(new ActivatedEventArgs<TConfiguration>(configuration));
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
|
public interface IAsyncInitialization
|
||||||
|
{
|
||||||
|
Task Initialize();
|
||||||
|
}
|
||||||
@@ -4,5 +4,5 @@ public interface IConfigurationInitializer<TConfiguration>
|
|||||||
where TConfiguration :
|
where TConfiguration :
|
||||||
class
|
class
|
||||||
{
|
{
|
||||||
Task Initialize();
|
void Initialize();
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public interface IImageReader
|
public interface IImageReader
|
||||||
{
|
{
|
||||||
Task<IImageDescriptor> Get(Stream stream,
|
IImageDescriptor Get(Stream stream,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
bool maintainAspectRatio = false);
|
bool maintainAspectRatio = false);
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
|
|
||||||
public interface IInitialization
|
public interface IInitialization
|
||||||
{
|
{
|
||||||
Task Initialize();
|
void Initialize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,17 +56,15 @@ public partial class Observable(IServiceProvider provider,
|
|||||||
Disposer.Dispose(this);
|
Disposer.Dispose(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual Task Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
if (IsInitialized)
|
if (IsInitialized)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsInitialized = true;
|
IsInitialized = true;
|
||||||
|
|
||||||
Subscriber.Subscribe(this);
|
Subscriber.Subscribe(this);
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
|
|||||||
@@ -157,8 +157,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TItem Add<T>(params object?[] parameters)
|
public TItem Add<T>(params object?[] parameters)
|
||||||
where T :
|
where T : TItem
|
||||||
TItem
|
|
||||||
{
|
{
|
||||||
T? item = Factory.Create<T>(args =>
|
T? item = Factory.Create<T>(args =>
|
||||||
{
|
{
|
||||||
@@ -416,19 +415,17 @@ public partial class ObservableCollection<TItem> :
|
|||||||
IsCompatibleObject(value) ?
|
IsCompatibleObject(value) ?
|
||||||
IndexOf((TItem)value!) : -1;
|
IndexOf((TItem)value!) : -1;
|
||||||
|
|
||||||
public virtual Task Initialize()
|
public virtual void Initialize()
|
||||||
{
|
{
|
||||||
if (IsInitialized)
|
if (IsInitialized)
|
||||||
{
|
{
|
||||||
return Task.CompletedTask;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsInitialized = true;
|
IsInitialized = true;
|
||||||
|
|
||||||
Subscriber.Subscribe(this);
|
Subscriber.Subscribe(this);
|
||||||
Synchronize();
|
Synchronize();
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TItem Insert<T>(int index = 0,
|
public TItem Insert<T>(int index = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user