2.3 KiB
2.3 KiB
name, description
| name | description |
|---|---|
| blazor-hybrid-bridge | Standards for cross-platform compatibility (Web & MAUI Hybrid) |
Cross-Platform Integration
-
Abstraction Layer:
- Define all platform-specific logic in
NexusReader.Application/Abstractions/Services. - Use
IPlatformServicefor device hardware (Haptics, Orientation). - Use
INativeStorageServicefor persistent key-value storage.
- Define all platform-specific logic in
-
Implementation Strategy:
- MAUI: Implement in
NexusReader.Infrastructure.MobileusingMicrosoft.Maui.*APIs. - Web: Implement in
NexusReader.Web.ClientusingIJSRuntimeto access Browser APIs (e.g.,navigator.vibrate,localStorage).
- MAUI: Implement in
-
UI Compatibility:
- Notch Support: Use
env(safe-area-inset-top)and other safe-area variables in CSS to prevent content from being hidden by hardware notches or home indicators. - Touch Optimization:
- Use
user-select: nonefor non-text interactive elements. - Ensure touch targets are at least
44x44px. - Handle
activestates for immediate feedback on mobile.
- Use
- Notch Support: Use
-
Platform Detection:
- Use
IPlatformService.GetDeviceContext()to determineDeviceType(Phone, Tablet, Desktop). - Adapt UI layout dynamically based on the context (e.g., sidebars on Tablet/Desktop, bottom navigation on Phone).
- Use
-
Real-time & Events (SignalR / UI):
- Debouncing: Implement trailing-edge debouncing using
CancellationTokenSourceandTask.Delayfor high-frequency UI events (like scrolling). Do not just drop events inside a time window, as the final state might be lost. - Dependency Isolation: Blazor WebAssembly (
Web.Client) cannot reference projects that requireMicrosoft.AspNetCore.App(like SignalR Hubs). Keep SignalR abstractions inUI.Sharedand the Hub implementation strictly on the server (InfrastructureorWeb.New).
- Debouncing: Implement trailing-edge debouncing using
-
Dependency Injection:
- Register implementations in
MauiProgram.csfor mobile andProgram.csfor web. - Components in
NexusReader.UI.Sharedmust only depend on the interfaces.
- Register implementations in
-
JS Interop Standards:
- Keep JS Interop calls isolated within service implementations.
- Use
IJSObjectReferencefor module-based scripts to avoid global namespace pollution. - Always provide a fallback or graceful failure for browsers that don't support specific APIs.