mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2024-11-14 09:34:21 +01:00
46 lines
1.1 KiB
Plaintext
46 lines
1.1 KiB
Plaintext
@inherits LayoutComponentBase
|
|
|
|
<MudThemeProvider @ref="@_themeProvider" Theme="@MudTheme" IsDarkMode="@DarkTheme"/>
|
|
<MudDialogProvider/>
|
|
<MudSnackbarProvider/>
|
|
|
|
<CascadingValue Value="this">
|
|
<MudLayout>
|
|
<MudMainContent>
|
|
@Body
|
|
</MudMainContent>
|
|
</MudLayout>
|
|
</CascadingValue>
|
|
|
|
@code {
|
|
public readonly MudTheme MudTheme = new MudTheme();
|
|
private MudThemeProvider? _themeProvider;
|
|
private bool _isDarkTheme = true;
|
|
|
|
public event EventHandler<bool>? OnDarkThemeChanged;
|
|
|
|
public bool DarkTheme
|
|
{
|
|
get => _isDarkTheme;
|
|
set
|
|
{
|
|
_isDarkTheme = value;
|
|
ThemeChanged();
|
|
}
|
|
}
|
|
|
|
private async void ThemeChanged()
|
|
{
|
|
//TODO: Update user settings
|
|
StateHasChanged();
|
|
}
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender && _themeProvider != null)
|
|
{
|
|
DarkTheme = await _themeProvider.GetSystemPreference();
|
|
_themeProvider.IsDarkModeChanged = EventCallback.Factory.Create<bool>(this, x => OnDarkThemeChanged?.Invoke(this, x));
|
|
}
|
|
}
|
|
} |