-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminDarkThemePlugin.cs
87 lines (69 loc) · 2.3 KB
/
AdminDarkThemePlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using Nop.Core.Domain.Cms;
using Nop.Services.Cms;
using Nop.Services.Common;
using Nop.Services.Configuration;
using Nop.Services.Plugins;
using Nop.Web.Framework.Infrastructure;
namespace dfdev.Plugin.Widgets.AdminDarkTheme;
/// <summary>
/// Rename this file and change to the correct type
/// </summary>
public class AdminDarkThemePlugin : BasePlugin, IMiscPlugin, IWidgetPlugin
{
#region Fields
private readonly ISettingService _settingService;
#endregion
#region Ctor
public AdminDarkThemePlugin(ISettingService settingService)
{
_settingService = settingService;
}
public bool HideInWidgetList => false;
#endregion
#region Methods
/// <summary>
/// Gets a configuration page URL
/// </summary>
public override string GetConfigurationPageUrl()
{
return string.Empty;
}
public Type GetWidgetViewComponent(string widgetZone)
{
if (widgetZone == AdminWidgetZones.HeaderNavbarAfter)
return typeof(Components.AdminDarkThemeComponent);
throw new NotImplementedException();
}
public Task<IList<string>> GetWidgetZonesAsync()
{
return Task.FromResult<IList<string>>(new List<string> { AdminWidgetZones.HeaderNavbarAfter });
}
/// <summary>
/// Install the plugin
/// </summary>
/// <returns>A task that represents the asynchronous operation</returns>
public override async Task InstallAsync()
{
await _settingService.SaveSettingAsync(new AdminDarkThemeSettings());
var widgetSettings = await _settingService.LoadSettingAsync<WidgetSettings>();
if (!widgetSettings.ActiveWidgetSystemNames.Contains("Widgets.AdminDarkTheme"))
{
widgetSettings.ActiveWidgetSystemNames.Add("Widgets.AdminDarkTheme");
await _settingService.SaveSettingAsync(widgetSettings);
}
await base.InstallAsync();
}
public override Task UpdateAsync(string currentVersion, string targetVersion)
{
return base.UpdateAsync(currentVersion, targetVersion);
}
/// <summary>
/// Uninstall the plugin
/// </summary>
/// <returns>A task that represents the asynchronous operation</returns>
public override async Task UninstallAsync()
{
await base.UninstallAsync();
}
#endregion
}