2026-10-06 23:31:07 +02:00
|
|
|
using Microsoft.AspNetCore.Components;
|
2026-10-17 02:56:57 +02:00
|
|
|
using decePubClient.Models;
|
2026-10-03 11:29:31 +02:00
|
|
|
|
|
|
|
|
using Microsoft.JSInterop;
|
2022-02-14 01:51:52 +01:00
|
|
|
|
|
|
|
|
namespace decePubClient.Services;
|
2022-02-14 01:51:37 +01:00
|
|
|
|
2026-10-03 15:26:21 +02:00
|
|
|
public class AppStatusService(IJSRuntime jsRuntime)
|
2022-02-14 01:51:37 +01:00
|
|
|
{
|
2026-10-03 15:26:21 +02:00
|
|
|
readonly IJSInProcessRuntime JsSyncRuntime = (IJSInProcessRuntime)jsRuntime;
|
2022-02-14 01:51:52 +01:00
|
|
|
|
2026-10-03 15:26:21 +02: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");
|
|
|
|
|
|
2026-10-03 11:29:31 +02:00
|
|
|
// wwwroot/js/theme.js
|
|
|
|
|
public void ApplyTheme(PageSettings pageSettings) => JsSyncRuntime.InvokeVoid("neoTheme.apply", pageSettings);
|
|
|
|
|
|
2026-10-03 12:43:07 +02:00
|
|
|
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");
|
|
|
|
|
|
2026-10-07 11:56:59 +02:00
|
|
|
// 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
|
|
|
}
|