-
Notifications
You must be signed in to change notification settings - Fork 152
/
MTabsBar.cs
75 lines (61 loc) · 2.08 KB
/
MTabsBar.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
namespace Masa.Blazor
{
public partial class MTabsBar : MSlideGroup, IThemeable
{
[Inject]
private NavigationManager NavigationManager { get; set; } = null!;
[CascadingParameter]
public BTabs? Tabs { get; set; }
[Parameter]
public string? BackgroundColor { get; set; }
[Parameter]
public string? Color { get; set; }
protected string ComputedColor
{
get
{
if (Color != null) return Color;
return IsDark ? "white" : "primary";
}
}
private bool IndependentTheme => (IsDirtyParameter(nameof(Dark)) && Dark) || (IsDirtyParameter(nameof(Light)) && Light);
#if NET8_0_OR_GREATER
protected override void OnParametersSet()
{
base.OnParametersSet();
if (MasaBlazor.IsSsr && !IndependentTheme)
{
CascadingIsDark = MasaBlazor.Theme.Dark;
}
}
#endif
protected override StringNumber InitDefaultItemValue()
{
return Tabs?.Routable is true ? NavigationManager.Uri : base.InitDefaultItemValue();
}
protected override void SetComponentClass()
{
base.SetComponentClass();
const string prefix = "m-tabs-bar";
CssProvider
.Merge(css =>
{
css.Add(prefix)
.AddIf($"{prefix}--is-mobile", () => IsMobile)
.AddTheme(IsDark, IndependentTheme)
.AddTextColor(ComputedColor)
.AddBackgroundColor(BackgroundColor);
}, style =>
{
style.AddTextColor(ComputedColor);
style.AddBackgroundColor(BackgroundColor);
})
.Merge("content", css => { css.Add($"{prefix}__content"); });
}
public override void Unregister(IGroupable item)
{
base.Unregister(item);
Tabs?.CallSliderAfterRender();
}
}
}