public MainLayout() { Themes = new MudTheme[] { new(), // default new() // dark { Palette = new Palette() { Black = "#27272f", Background = "#32333d", BackgroundGrey = "#27272f", Surface = "#373740", DrawerBackground = "#27272f", DrawerText = "rgba(255,255,255, 0.50)", DrawerIcon = "rgba(255,255,255, 0.50)", AppbarBackground = "#27272f", AppbarText = "rgba(255,255,255, 0.70)", TextPrimary = "rgba(255,255,255, 0.70)", TextSecondary = "rgba(255,255,255, 0.50)", ActionDefault = "#adadb1", ActionDisabled = "rgba(255,255,255, 0.26)", ActionDisabledBackground = "rgba(255,255,255, 0.12)" }, }, }; _currentTheme = Themes[0]; }
private async Task ToggleTheme() { _isLightMode = !_isLightMode; _currentTheme = !_isLightMode?GenerateDarkTheme() : new MudTheme(); await OnThemeToggled.InvokeAsync(_currentTheme); }
protected override async Task OnInitializedAsync() { _interceptor.RegisterEvent(); currentTheme = await _preferenceManager.GetCurrentThemeAsync(); hubConnection = hubConnection.TryInitialize(_navigationManager); await hubConnection.StartAsync(); hubConnection.On <string, string>("ReceiveChatNotification", (message, userId) => { if (CurrentUserId == userId) { _snackBar.Add(message, Severity.Info); } }); hubConnection.On("RegenerateTokens", async() => { try { var token = await _authenticationManager.TryForceRefreshToken(); if (!string.IsNullOrEmpty(token)) { _snackBar.Add("Refreshed Token.", Severity.Success); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); } } catch (Exception ex) { Console.WriteLine(ex.Message); _snackBar.Add("You are Logged Out.", Severity.Error); await _authenticationManager.Logout(); _navigationManager.NavigateTo("/"); } }); }
private async Task DarkMode() { bool isDarkMode = await _clientPreferenceManager.ToggleDarkModeAsync(); _currentTheme = isDarkMode ? BlazorHeroTheme.DefaultTheme : BlazorHeroTheme.DarkTheme; }
protected override async Task OnInitializedAsync() { _currentTheme = BlazorHeroTheme.DefaultTheme; _currentTheme = await _clientPreferenceManager.GetCurrentThemeAsync(); _rightToLeft = await _clientPreferenceManager.IsRTL(); _interceptor.RegisterEvent(); }
public void RotateTheme() { int current = Themes.IndexOf(_currentTheme); int next = current == -1 ? 0 : current + 1 >= Themes.Count ? 0 : current + 1; _currentTheme = Themes[next]; }
public static MudTheme DocsTheme() { var theme = new MudTheme() { Palette = DocsLightPalette, PaletteDark = DocsDarkPalette, LayoutProperties = new LayoutProperties() }; return(theme); }
private void SwithTheme() { if (_currentTheme == _defaultTheme) { _currentTheme = _darkTheme; } else { _currentTheme = _defaultTheme; } }
private async Task DarkMode() { bool isDarkMode = await _preferenceManager.ToggleDarkModeAsync(); if (isDarkMode) { currentTheme = BlazorHeroTheme.DefaultTheme; } else { currentTheme = BlazorHeroTheme.DarkTheme; } }
public static MudTheme LandingPageTheme() { var theme = new MudTheme() { Palette = LandingPageLightPalette, PaletteDark = LandingPageDarkPalette, Shadows = LandingPageShadows, LayoutProperties = LandingPageLayoutProperties, ZIndex = new ZIndex(), Typography = LandingPageTypography }; return(theme); }
protected override async Task OnInitializedAsync() { currentTheme = BlazorHeroTheme.DefaultTheme; currentTheme = await _clientPreferenceManager.GetCurrentThemeAsync(); _interceptor.RegisterEvent(); hubConnection = hubConnection.TryInitialize(_navigationManager); await hubConnection.StartAsync(); hubConnection.On <string, string, string>(ApplicationConstants.SignalR.ReceiveChatNotification, (message, receiverUserId, senderUserId) => { if (CurrentUserId == receiverUserId) { _jsRuntime.InvokeAsync <string>("PlayAudio", "notification"); _snackBar.Add(message, Severity.Info, config => { config.VisibleStateDuration = 10000; config.HideTransitionDuration = 500; config.ShowTransitionDuration = 500; config.Action = "Chat?"; config.ActionColor = Color.Primary; config.Onclick = snackbar => { _navigationManager.NavigateTo($"chat/{senderUserId}"); return(Task.CompletedTask); }; }); } }); hubConnection.On(ApplicationConstants.SignalR.ReceiveRegenerateTokens, async() => { try { var token = await _authenticationManager.TryForceRefreshToken(); if (!string.IsNullOrEmpty(token)) { _snackBar.Add("Refreshed Token.", Severity.Success); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); } } catch (Exception ex) { Console.WriteLine(ex.Message); _snackBar.Add("You are Logged Out.", Severity.Error); await _authenticationManager.Logout(); _navigationManager.NavigateTo("/"); } }); }
protected override async Task OnInitializedAsync() { _interceptor.RegisterEvent(); currentTheme = await _preferenceManager.GetCurrentThemeAsync(); hubConnection = hubConnection.TryInitialize(_navigationManager); await hubConnection.StartAsync(); hubConnection.On <string, string>("ReceiveChatNotification", (message, userId) => { if (CurrentUserId == userId) { _snackBar.Add(message, Severity.Info); } }); }
protected override async Task OnInitializedAsync() { _interceptor.RegisterEvent(); currentTheme = await _preferenceManager.GetCurrentThemeAsync(); hubConnection = new HubConnectionBuilder() .WithUrl(_navigationManager.ToAbsoluteUri("/chatHub")) .Build(); hubConnection.On <string, string>("ReceiveChatNotification", (message, userId) => { if (CurrentUserId == userId) { _snackBar.Add(message, Severity.Info, options => options.BackgroundBlurred = true); } }); await hubConnection.StartAsync(); }
public static string GetName(MudTheme theme) { return(theme == NightMode?nameof(NightMode) : nameof(Default)); }
protected override async Task OnInitializedAsync() { currentTheme = await _preferenceManager.GetCurrentThemeAsync(); }
protected override async Task OnInitializedAsync() { _currentTheme = BlazorHeroTheme.DefaultTheme; _currentTheme = await _clientPreferenceManager.GetCurrentThemeAsync(); _rightToLeft = await _clientPreferenceManager.IsRTL(); _interceptor.RegisterEvent(); hubConnection = hubConnection.TryInitialize(_navigationManager); await hubConnection.StartAsync(); hubConnection.On <string, string, string>(ApplicationConstants.SignalR.ReceiveChatNotification, (message, receiverUserId, senderUserId) => { if (CurrentUserId == receiverUserId) { _jsRuntime.InvokeAsync <string>("PlayAudio", "notification"); _snackBar.Add(message, Severity.Info, config => { config.VisibleStateDuration = 10000; config.HideTransitionDuration = 500; config.ShowTransitionDuration = 500; config.Action = localizer["Chat?"]; config.ActionColor = Color.Primary; config.Onclick = snackbar => { _navigationManager.NavigateTo($"chat/{senderUserId}"); return(Task.CompletedTask); }; }); } }); hubConnection.On(ApplicationConstants.SignalR.ReceiveRegenerateTokens, async() => { try { var token = await _authenticationManager.TryForceRefreshToken(); if (!string.IsNullOrEmpty(token)) { _snackBar.Add(localizer["Refreshed Token."], Severity.Success); _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); } } catch (Exception ex) { Console.WriteLine(ex.Message); _snackBar.Add(localizer["You are Logged Out."], Severity.Error); await _authenticationManager.Logout(); _navigationManager.NavigateTo("/"); } }); hubConnection.On <string, string>(ApplicationConstants.SignalR.LogoutUsersByRole, async(userId, roleId) => { if (CurrentUserId != userId) { var rolesResponse = await RoleManager.GetRolesAsync(); if (rolesResponse.Succeeded) { var role = rolesResponse.Data.FirstOrDefault(x => x.Id == roleId); if (role != null) { var currentUserRolesResponse = await _userManager.GetRolesAsync(CurrentUserId); if (currentUserRolesResponse.Succeeded && currentUserRolesResponse.Data.UserRoles.Any(x => x.RoleName == role.Name)) { _snackBar.Add(localizer["You are logged out because the Permissions of one of your Roles have been updated."], Severity.Error); await hubConnection.SendAsync(ApplicationConstants.SignalR.OnDisconnect, CurrentUserId); await _authenticationManager.Logout(); _navigationManager.NavigateTo("/login"); } } } } }); }
public void SetBaseTheme(MudTheme theme) { CurrentTheme = theme; OnMajorUpdateOccured(); }
protected override async Task OnInitializedAsync() { _interceptor.RegisterEvent(); currentTheme = await _preferenceManager.GetCurrentThemeAsync(); }