initial commit

This commit is contained in:
robotics_x1
2026-10-12 15:24:08 +07:00
commit 55228b3772
367 changed files with 162893 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using System.Net.Http.Json;
namespace Lab505.Client.Services;
public class LangService
{
public string Current { get; private set; } = "vi";
public event Action? LangChanged;
public string T(string vi, string en) => Current == "en" ? en : vi;
public void Set(string lang)
{
if (Current == lang) return;
Current = lang;
LangChanged?.Invoke();
}
public async Task LoadAsync(HttpClient http)
{
try
{
var prefs = await http.GetFromJsonAsync<PrefsDto>("/api/prefs");
if (prefs?.Lang is { } l) Set(l);
}
catch { }
}
public async Task ToggleAsync(HttpClient http)
{
Set(Current == "vi" ? "en" : "vi");
try { await http.PutAsJsonAsync("/api/prefs", new { Lang = (string?)Current, NotifMuted = (bool?)null }); }
catch { }
}
private record PrefsDto(string? Lang);
}