Skip to content

Commit 568d554

Browse files
move code
1 parent f892885 commit 568d554

File tree

5 files changed

+121
-110
lines changed

5 files changed

+121
-110
lines changed

Client/Modules/FileHub/RadzenThemeChanger.razor

Lines changed: 2 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@inherits ModuleBase
1+
@namespace ICTAce.FileHub
2+
@inherits ModuleBase
23

34
<RadzenTheme Theme="@RadzenTheme" />
45

@@ -507,90 +508,3 @@
507508
margin-bottom: 16px;
508509
}
509510
</style>
510-
511-
@code {
512-
[Inject]
513-
protected ISettingService SettingService { get; set; } = default!;
514-
515-
[Inject]
516-
private Radzen.ThemeService ThemeService { get; set; } = default!;
517-
518-
private string RadzenTheme { get; set; } = "default";
519-
520-
// Preview component state
521-
private bool _switchValue = true;
522-
private int _radioValue = 1;
523-
private int _sliderValue = 50;
524-
private int _stepsIndex = 1;
525-
private int _ratingValue = 4;
526-
private double _gaugeValue = 72;
527-
private bool _toggleValue = true;
528-
529-
// Sample data for DataGrid
530-
private List<SampleData> _sampleData = [
531-
new(1, "Product A", "Electronics", 299.99m, DateTime.Now.AddDays(-5), true),
532-
new(2, "Product B", "Clothing", 49.99m, DateTime.Now.AddDays(-3), true),
533-
new(3, "Product C", "Electronics", 199.99m, DateTime.Now.AddDays(-1), false),
534-
new(4, "Product D", "Home", 89.99m, DateTime.Now.AddDays(-7), true),
535-
new(5, "Product E", "Clothing", 29.99m, DateTime.Now.AddDays(-2), true),
536-
new(6, "Product F", "Home", 149.99m, DateTime.Now.AddDays(-10), false),
537-
new(7, "Product G", "Electronics", 599.99m, DateTime.Now.AddDays(-4), true),
538-
new(8, "Product H", "Clothing", 79.99m, DateTime.Now.AddDays(-6), true),
539-
];
540-
541-
private record SampleData(int Id, string Name, string Category, decimal Price, DateTime Date, bool IsActive);
542-
543-
private record ThemeOption(
544-
string Name,
545-
string Value,
546-
string Background,
547-
string Card,
548-
string Primary,
549-
string Accent,
550-
string Text,
551-
string ChartColor1,
552-
string ChartColor2,
553-
string ChartColor3,
554-
string BorderRadius);
555-
556-
private List<ThemeOption> AvailableThemes { get; } = [
557-
new("Default", "default", "#f5f5f5", "#ffffff", "#007bff", "#dc3545", "#212529", "#3700b3", "#ba68c8", "#f06292", "4"),
558-
new("Dark", "dark", "#121212", "#1e1e1e", "#90caf9", "#f48fb1", "#e0e0e0", "#3700b3", "#ba68c8", "#f06292", "4"),
559-
new("Material", "material", "#f5f5f5", "#ffffff", "#4340d2", "#e31c65", "#212121", "#3700b3", "#ba68c8", "#f06292", "4"),
560-
new("Material Dark", "material-dark", "#121212", "#1e1e1e", "#90caf9", "#f48fb1", "#e0e0e0", "#3700b3", "#ba68c8", "#f06292", "4"),
561-
new("Standard", "standard", "#f4f5f9", "#ffffff", "#1776d1", "#c3002f", "#212121", "#3d7cf4", "#64dfdf", "#f68769", "4"),
562-
new("Standard Dark", "standard-dark", "#19191a", "#242527", "#90caf9", "#f48fb1", "#e0e0e0", "#3d7cf4", "#64dfdf", "#f68769", "4"),
563-
new("Humanistic", "humanistic", "#f6f7fa", "#ffffff", "#376df5", "#e91e63", "#212121", "#376df5", "#64dfdf", "#f68769", "4"),
564-
new("Humanistic Dark", "humanistic-dark", "#28363c", "#38474e", "#90caf9", "#f48fb1", "#e0e0e0", "#376df5", "#64dfdf", "#f68769", "4"),
565-
new("Software", "software", "#f6f7fa", "#ffffff", "#4a5568", "#ed8936", "#2d3748", "#376df5", "#64dfdf", "#f68769", "4"),
566-
new("Software Dark", "software-dark", "#28363c", "#3a474d", "#63b3ed", "#f6ad55", "#e2e8f0", "#376df5", "#64dfdf", "#f68769", "4"),
567-
];
568-
569-
private Dictionary<string, string> _settings = new();
570-
571-
protected override async Task OnInitializedAsync()
572-
{
573-
await base.OnInitializedAsync();
574-
if (PageState.User != null)
575-
{
576-
_settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
577-
RadzenTheme = SettingService.GetSetting(_settings, "RadzenTheme", "default");
578-
ThemeService.SetTheme(RadzenTheme);
579-
}
580-
}
581-
582-
private async Task OnThemeSelectedAsync(string theme)
583-
{
584-
RadzenTheme = theme;
585-
586-
// Apply theme immediately
587-
ThemeService.SetTheme(theme);
588-
589-
// Save to user settings
590-
if (PageState.User != null)
591-
{
592-
SettingService.SetSetting(_settings, "RadzenTheme", theme);
593-
await SettingService.UpdateUserSettingsAsync(_settings, PageState.User.UserId);
594-
}
595-
}
596-
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Licensed to ICTAce under the MIT license.
2+
3+
namespace ICTAce.FileHub;
4+
5+
public partial class RadzenThemeChanger
6+
{
7+
[Inject]
8+
protected ISettingService SettingService { get; set; } = default!;
9+
10+
[Inject]
11+
private Radzen.ThemeService ThemeService { get; set; } = default!;
12+
13+
private string RadzenTheme { get; set; } = "default";
14+
15+
// Preview component state
16+
private bool _switchValue = true;
17+
private int _radioValue = 1;
18+
private int _sliderValue = 50;
19+
private int _stepsIndex = 1;
20+
private int _ratingValue = 4;
21+
private double _gaugeValue = 72;
22+
private bool _toggleValue = true;
23+
24+
// Sample data for DataGrid
25+
private List<SampleData> _sampleData =
26+
[
27+
new(1, "Product A", "Electronics", 299.99m, DateTime.Now.AddDays(-5), true),
28+
new(2, "Product B", "Clothing", 49.99m, DateTime.Now.AddDays(-3), true),
29+
new(3, "Product C", "Electronics", 199.99m, DateTime.Now.AddDays(-1), false),
30+
new(4, "Product D", "Home", 89.99m, DateTime.Now.AddDays(-7), true),
31+
new(5, "Product E", "Clothing", 29.99m, DateTime.Now.AddDays(-2), true),
32+
new(6, "Product F", "Home", 149.99m, DateTime.Now.AddDays(-10), false),
33+
new(7, "Product G", "Electronics", 599.99m, DateTime.Now.AddDays(-4), true),
34+
new(8, "Product H", "Clothing", 79.99m, DateTime.Now.AddDays(-6), true),
35+
];
36+
37+
private record SampleData(int Id, string Name, string Category, decimal Price, DateTime Date, bool IsActive);
38+
39+
private record ThemeOption(
40+
string Name,
41+
string Value,
42+
string Background,
43+
string Card,
44+
string Primary,
45+
string Accent,
46+
string Text,
47+
string ChartColor1,
48+
string ChartColor2,
49+
string ChartColor3,
50+
string BorderRadius);
51+
52+
private List<ThemeOption> AvailableThemes { get; } =
53+
[
54+
new("Default", "default", "#f5f5f5", "#ffffff", "#007bff", "#dc3545", "#212529", "#3700b3", "#ba68c8", "#f06292", "4"),
55+
new("Dark", "dark", "#121212", "#1e1e1e", "#90caf9", "#f48fb1", "#e0e0e0", "#3700b3", "#ba68c8", "#f06292", "4"),
56+
new("Material", "material", "#f5f5f5", "#ffffff", "#4340d2", "#e31c65", "#212121", "#3700b3", "#ba68c8", "#f06292", "4"),
57+
new("Material Dark", "material-dark", "#121212", "#1e1e1e", "#90caf9", "#f48fb1", "#e0e0e0", "#3700b3", "#ba68c8", "#f06292", "4"),
58+
new("Standard", "standard", "#f4f5f9", "#ffffff", "#1776d1", "#c3002f", "#212121", "#3d7cf4", "#64dfdf", "#f68769", "4"),
59+
new("Standard Dark", "standard-dark", "#19191a", "#242527", "#90caf9", "#f48fb1", "#e0e0e0", "#3d7cf4", "#64dfdf", "#f68769", "4"),
60+
new("Humanistic", "humanistic", "#f6f7fa", "#ffffff", "#376df5", "#e91e63", "#212121", "#376df5", "#64dfdf", "#f68769", "4"),
61+
new("Humanistic Dark", "humanistic-dark", "#28363c", "#38474e", "#90caf9", "#f48fb1", "#e0e0e0", "#376df5", "#64dfdf", "#f68769", "4"),
62+
new("Software", "software", "#f6f7fa", "#ffffff", "#4a5568", "#ed8936", "#2d3748", "#376df5", "#64dfdf", "#f68769", "4"),
63+
new("Software Dark", "software-dark", "#28363c", "#3a474d", "#63b3ed", "#f6ad55", "#e2e8f0", "#376df5", "#64dfdf", "#f68769", "4"),
64+
];
65+
66+
private Dictionary<string, string> _settings = new();
67+
68+
protected override async Task OnInitializedAsync()
69+
{
70+
await base.OnInitializedAsync();
71+
if (PageState.User != null)
72+
{
73+
_settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
74+
RadzenTheme = SettingService.GetSetting(_settings, "RadzenTheme", "default");
75+
ThemeService.SetTheme(RadzenTheme);
76+
}
77+
}
78+
79+
private async Task OnThemeSelectedAsync(string theme)
80+
{
81+
RadzenTheme = theme;
82+
83+
// Apply theme immediately
84+
ThemeService.SetTheme(theme);
85+
86+
// Save to user settings
87+
if (PageState.User != null)
88+
{
89+
SettingService.SetSetting(_settings, "RadzenTheme", theme);
90+
await SettingService.UpdateUserSettingsAsync(_settings, PageState.User.UserId);
91+
}
92+
}
93+
}
Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,5 @@
1-
@inherits ModuleBase
1+
@namespace ICTAce.FileHub
2+
@inherits ModuleBase
3+
24
<RadzenComponents />
35
<RadzenTheme Theme="default" />
4-
5-
@code {
6-
[Inject]
7-
protected ISettingService SettingService { get; set; } = default!;
8-
9-
[Inject]
10-
private Radzen.ThemeService ThemeService { get; set; } = default!;
11-
12-
protected override async Task OnInitializedAsync()
13-
{
14-
await base.OnInitializedAsync();
15-
if (PageState.User != null)
16-
{
17-
var _settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
18-
var radzenTheme = SettingService.GetSetting(_settings, "RadzenTheme", "default");
19-
ThemeService.SetTheme(radzenTheme);
20-
}
21-
}
22-
23-
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Licensed to ICTAce under the MIT license.
2+
3+
namespace ICTAce.FileHub;
4+
5+
public partial class RadzenThemeManager
6+
{
7+
[Inject]
8+
protected ISettingService SettingService { get; set; } = default!;
9+
10+
[Inject]
11+
private Radzen.ThemeService ThemeService { get; set; } = default!;
12+
13+
protected override async Task OnInitializedAsync()
14+
{
15+
await base.OnInitializedAsync();
16+
if (PageState.User != null)
17+
{
18+
var settings = await SettingService.GetUserSettingsAsync(PageState.User.UserId);
19+
var radzenTheme = SettingService.GetSetting(settings, "RadzenTheme", "default");
20+
ThemeService.SetTheme(radzenTheme);
21+
}
22+
}
23+
}

Client/Modules/FileHub/Settings.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@namespace ICTAce.FileHub
2-
@using ICTAce.FileHub.Client.Modules.FileHub
32
@inherits ModuleBase
43

54
<RadzenThemeManager />

0 commit comments

Comments
 (0)