@using EnvelopeGenerator.Server.Client.Services @using EnvelopeGenerator.Application.Resources @using Microsoft.AspNetCore.Components.Routing @using Microsoft.Extensions.Localization @using System.Globalization @inherits LayoutComponentBase @implements IDisposable @inject ThemeService ThemeService @inject IStringLocalizer UiLocalizer @inject NavigationManager Navigation
@Body
@code { [Inject] IHttpClientFactory HttpClientFactory { get; set; } = default!; private Action? _themeChangeHandler; protected override async Task OnInitializedAsync() { Navigation.LocationChanged += OnLocationChanged; await FontLoader.LoadFonts(HttpClientFactory, ["opensans.ttf"]); _themeChangeHandler = () => InvokeAsync(StateHasChanged); ThemeService.OnChange += _themeChangeHandler; await base.OnInitializedAsync(); } public void Dispose() { ThemeService.OnChange -= _themeChangeHandler; Navigation.LocationChanged -= OnLocationChanged; } private void OnLocationChanged(object? sender, LocationChangedEventArgs e) => _ = InvokeAsync(StateHasChanged); private string GetPrivacyPolicyPath() { var current = CultureInfo.CurrentUICulture.Name; var code = current switch { "de-DE" => "de-DE", "en-US" => "en-US", "fr-FR" => "fr-FR", _ => "de-DE" }; return $"docs/privacy-policy.{code}.html"; } string L(string key, string fallback) { var value = UiLocalizer[key]; return value.ResourceNotFound ? fallback : value.Value; } }