wrapped custom widget items in containers so we have more control of the surrounding, i.e. divider

This commit is contained in:
TheXamlGuy
2024-01-10 19:25:16 +00:00
parent 197454ba1e
commit d7d90b3d54
45 changed files with 352 additions and 110 deletions
@@ -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);
+2 -2
View File
@@ -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 -3
View File
@@ -1,5 +1,3 @@
namespace Hyperbar;
public interface IWidgetComponentViewModel
{
}
public interface IWidgetComponentViewModel;
+1 -3
View File
@@ -1,5 +1,3 @@
namespace Hyperbar;
public interface IWidgetView
{
}
public interface IWidgetView;
+1 -3
View File
@@ -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)
{
+12
View File
@@ -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;
}
+1 -1
View File
@@ -4,7 +4,7 @@ using CommunityToolkit.Mvvm.Input;
namespace Hyperbar;
public partial class WidgetButtonViewModel :
WidgetComponentViewModelBase
WidgetComponentViewModel
{
[ObservableProperty]
private string? icon;
@@ -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;
}