Initial commit: NexusArchitect Professional Workstation Overhaul
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using FluentResults;
|
||||
using Microsoft.JSInterop;
|
||||
using NexusReader.Application.Abstractions.Services;
|
||||
|
||||
namespace NexusReader.Web.Client.Services;
|
||||
|
||||
public sealed class WebPlatformService : IPlatformService
|
||||
{
|
||||
private readonly IJSRuntime _jsRuntime;
|
||||
|
||||
public WebPlatformService(IJSRuntime jsRuntime)
|
||||
{
|
||||
_jsRuntime = jsRuntime;
|
||||
}
|
||||
|
||||
public async Task<Result> VibrateSuccessAsync() => await VibrateAsync(100);
|
||||
public async Task<Result> VibrateErrorAsync() => await VibrateAsync(300);
|
||||
|
||||
public async Task<Result> VibrateAsync(int milliseconds)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _jsRuntime.InvokeVoidAsync("navigator.vibrate", milliseconds);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public Result<DeviceContext> GetDeviceContext()
|
||||
{
|
||||
return Result.Ok(new DeviceContext(
|
||||
"Browser",
|
||||
"Web",
|
||||
DeviceType.Desktop, // Default for web, or could detect via JS
|
||||
DisplayOrientation.Unknown
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user