Files
decePubClient/Services/AppStatusService.cs
T

41 lines
1.6 KiB
C#
Raw Normal View History

2026-10-06 23:31:07 +02:00
using Microsoft.AspNetCore.Components;
using decePubClient.Models;
using Microsoft.JSInterop;
2022-02-14 01:51:52 +01:00
namespace decePubClient.Services;
2022-02-14 01:51:37 +01:00
public class AppStatusService(IJSRuntime jsRuntime)
2022-02-14 01:51:37 +01:00
{
readonly IJSInProcessRuntime JsSyncRuntime = (IJSInProcessRuntime)jsRuntime;
2022-02-14 01:51:52 +01:00
public async ValueTask<bool> IsOnline(CancellationToken cancellationToken = default) =>
await jsRuntime.InvokeAsync<bool>("isOnline", cancellationToken);
2022-02-14 01:51:52 +01:00
public string Language() => JsSyncRuntime.Invoke<string>("getLanguage");
public void SetAppBadge(int counter) => JsSyncRuntime.InvokeVoid("setAppBadge", counter);
public void ClearAppBadge() => JsSyncRuntime.InvokeVoid("clearAppBadge");
// wwwroot/js/theme.js
public void ApplyTheme(PageSettings pageSettings) => JsSyncRuntime.InvokeVoid("neoTheme.apply", pageSettings);
public bool IsDarkTheme() => JsSyncRuntime.Invoke<bool>("neoTheme.isDark");
2022-02-14 01:51:52 +01:00
public bool IsMobileMedia() => JsSyncRuntime.Invoke<bool>("isMobileMedia");
2026-10-06 23:49:49 +02:00
// whether the navigation being decided came from the Back (or Forward) button
public bool TookBack() => JsSyncRuntime.Invoke<bool>("tookBack");
2026-10-06 23:36:03 +02:00
// whether the pointer can hover (a mouse); a touch screen can't, so what shows on hover there opens on a tap
public bool CanHover() => JsSyncRuntime.Invoke<bool>("canHover");
// read once: a card asks it for each gifv it shows
bool? reducedMotion;
public bool PrefersReducedMotion() => reducedMotion ??= JsSyncRuntime.Invoke<bool>("prefersReducedMotion");
2026-10-06 23:31:07 +02:00
// a sideways-scrolling strip of tabs shows its selected tab
public void RevealActive(ElementReference strip) => JsSyncRuntime.InvokeVoid("revealActive", strip);
2022-02-14 01:51:37 +01:00
}