Initial commit: NexusArchitect Professional Workstation Overhaul
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
namespace NexusReader.Infrastructure.Mobile;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net10.0-android</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
|
||||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net10.0-windows10.0.19041.0</TargetFrameworks>
|
||||
<UseMaui>true</UseMaui>
|
||||
<SkipValidateMauiImplicitPackageReferences>true</SkipValidateMauiImplicitPackageReferences>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NexusReader.Application\NexusReader.Application.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,84 @@
|
||||
using FluentResults;
|
||||
using Microsoft.Maui.Devices;
|
||||
using NexusReader.Application.Abstractions.Services;
|
||||
|
||||
namespace NexusReader.Infrastructure.Mobile.Services;
|
||||
|
||||
public sealed class MauiPlatformService : IPlatformService
|
||||
{
|
||||
public async Task<Result> VibrateSuccessAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
HapticFeedback.Default.Perform(HapticFeedbackType.Click);
|
||||
await Task.Delay(100);
|
||||
HapticFeedback.Default.Perform(HapticFeedbackType.Click);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Result> VibrateErrorAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
HapticFeedback.Default.Perform(HapticFeedbackType.LongPress);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Result> VibrateAsync(int milliseconds)
|
||||
{
|
||||
try
|
||||
{
|
||||
HapticFeedback.Default.Perform(HapticFeedbackType.Click);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public Result<DeviceContext> GetDeviceContext()
|
||||
{
|
||||
try
|
||||
{
|
||||
var device = DeviceInfo.Current;
|
||||
var display = DeviceDisplay.Current.MainDisplayInfo;
|
||||
|
||||
return Result.Ok(new DeviceContext(
|
||||
device.Model,
|
||||
device.Manufacturer,
|
||||
MapDeviceType(device.Idiom),
|
||||
MapOrientation(display.Orientation)
|
||||
));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private static NexusReader.Application.Abstractions.Services.DeviceType MapDeviceType(DeviceIdiom idiom)
|
||||
{
|
||||
if (idiom == DeviceIdiom.Phone) return NexusReader.Application.Abstractions.Services.DeviceType.Phone;
|
||||
if (idiom == DeviceIdiom.Tablet) return NexusReader.Application.Abstractions.Services.DeviceType.Tablet;
|
||||
if (idiom == DeviceIdiom.Desktop) return NexusReader.Application.Abstractions.Services.DeviceType.Desktop;
|
||||
return NexusReader.Application.Abstractions.Services.DeviceType.Unknown;
|
||||
}
|
||||
|
||||
private static NexusReader.Application.Abstractions.Services.DisplayOrientation MapOrientation(Microsoft.Maui.Devices.DisplayOrientation orientation) => orientation switch
|
||||
{
|
||||
Microsoft.Maui.Devices.DisplayOrientation.Portrait => NexusReader.Application.Abstractions.Services.DisplayOrientation.Portrait,
|
||||
Microsoft.Maui.Devices.DisplayOrientation.Landscape => NexusReader.Application.Abstractions.Services.DisplayOrientation.Landscape,
|
||||
_ => NexusReader.Application.Abstractions.Services.DisplayOrientation.Unknown
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using FluentResults;
|
||||
using Microsoft.Maui.Storage;
|
||||
using NexusReader.Application.Abstractions.Services;
|
||||
|
||||
namespace NexusReader.Infrastructure.Mobile.Services;
|
||||
|
||||
public sealed class MauiStorageService : INativeStorageService
|
||||
{
|
||||
public Result SaveString(string key, string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Preferences.Default.Set(key, value);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public Result<string?> GetString(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Result.Ok(Preferences.Default.Get(key, (string?)null));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public Result SaveBool(string key, bool value)
|
||||
{
|
||||
try
|
||||
{
|
||||
Preferences.Default.Set(key, value);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public Result<bool> GetBool(string key, bool defaultValue = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Result.Ok(Preferences.Default.Get(key, defaultValue));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public Result Remove(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
Preferences.Default.Remove(key);
|
||||
return Result.Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Result.Fail(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user