wrapped custom widget items in containers so we have more control of the surrounding, i.e. divider
This commit is contained in:
@@ -96,7 +96,7 @@ public static class IServiceCollectionExtensions
|
||||
key ??= contentType.Name;
|
||||
|
||||
services.AddTransient(contentType);
|
||||
services.TryAddTransient(templateType);
|
||||
services.AddTransient(templateType);
|
||||
|
||||
services.AddKeyedTransient(contentType, key);
|
||||
services.AddKeyedTransient(templateType, key);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Hyperbar;
|
||||
public class Mediator(IServiceProvider provider) :
|
||||
IMediator
|
||||
{
|
||||
private readonly ConditionalWeakTable<Type, dynamic> addedHandlers = [];
|
||||
private readonly List<KeyValuePair<Type, dynamic>> addedHandlers = [];
|
||||
|
||||
public ValueTask PublishAsync<TNotification>(TNotification notification,
|
||||
CancellationToken cancellationToken = default)
|
||||
@@ -78,7 +78,7 @@ public class Mediator(IServiceProvider provider) :
|
||||
if (interfaceType.GetGenericArguments() is { Length: 1 } arguments)
|
||||
{
|
||||
Type notificationType = arguments[0];
|
||||
addedHandlers.Add(notificationType, subject);
|
||||
addedHandlers.Add(new KeyValuePair<Type, dynamic>(notificationType, subject));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IWidgetComponentViewModel
|
||||
{
|
||||
}
|
||||
public interface IWidgetComponentViewModel;
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IWidgetView
|
||||
{
|
||||
}
|
||||
public interface IWidgetView;
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IWidgetViewModel
|
||||
{
|
||||
}
|
||||
public interface IWidgetViewModel;
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
|
||||
public class ObservableCollectionViewModel<TItem> :
|
||||
ObservableCollection<TItem>,
|
||||
INotificationHandler<CollectionChanged<IEnumerable<TItem>>>
|
||||
{
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
private SynchronizationContext? context;
|
||||
private readonly SynchronizationContext? context;
|
||||
|
||||
public ObservableCollectionViewModel(IServiceFactory serviceFactory,
|
||||
IMediator mediator)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public partial class WidgetBarViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<WidgetContainerViewModel> items) :
|
||||
ObservableCollectionViewModel<WidgetContainerViewModel>(serviceFactory, mediator, items),
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using CommunityToolkit.Mvvm.Input;
|
||||
namespace Hyperbar;
|
||||
|
||||
public partial class WidgetButtonViewModel :
|
||||
WidgetComponentViewModelBase
|
||||
WidgetComponentViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? icon;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public partial class WidgetComponentViewModelBase(ITemplateFactory templateFactory) :
|
||||
public partial class WidgetComponentViewModel(ITemplateFactory templateFactory) :
|
||||
ObservableObject,
|
||||
IWidgetComponentViewModel,
|
||||
ITemplatedViewModel
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public class WidgetContainerViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<IWidgetViewModel> items) :
|
||||
ObservableCollectionViewModel<IWidgetViewModel>(serviceFactory, mediator, items),
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
Reference in New Issue
Block a user