Implemented extendable system settings tab. Started implementing white labeling settings
This commit is contained in:
34
Moonlight.Frontend/Configuration/SystemSettingsOptions.cs
Normal file
34
Moonlight.Frontend/Configuration/SystemSettingsOptions.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Moonlight.Frontend.Configuration;
|
||||
|
||||
public class SystemSettingsOptions
|
||||
{
|
||||
public IReadOnlyList<SystemSettingsPage> Components => InnerComponents;
|
||||
|
||||
private readonly List<SystemSettingsPage> InnerComponents = new();
|
||||
|
||||
public void Add<TIcon, TComponent>(string name, string description, int order)
|
||||
where TIcon : ComponentBase where TComponent : ComponentBase
|
||||
=> Add(name, description, order, typeof(TIcon), typeof(TComponent));
|
||||
|
||||
public void Add(string name, string description, int order, Type iconComponent, Type component)
|
||||
=> InnerComponents.Add(new SystemSettingsPage(name, description, order, iconComponent, component));
|
||||
|
||||
public void Remove<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TComponent>()
|
||||
where TComponent : ComponentBase
|
||||
=> Remove(typeof(TComponent));
|
||||
|
||||
public void Remove(Type componentType)
|
||||
=> InnerComponents.RemoveAll(x => x.ComponentType == componentType);
|
||||
}
|
||||
|
||||
public record SystemSettingsPage(
|
||||
string Name,
|
||||
string Description,
|
||||
int Order,
|
||||
[property: DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
|
||||
Type IconComponentType,
|
||||
Type ComponentType
|
||||
);
|
||||
Reference in New Issue
Block a user