Add OtpDialogService for mobile-friendly OTP authentication dialog
This commit is contained in:
37
src/FrontOffice.Main/Utilities/َOtpDialogService.cs
Normal file
37
src/FrontOffice.Main/Utilities/َOtpDialogService.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using FrontOffice.Main.Shared;
|
||||
using MudBlazor;
|
||||
|
||||
namespace FrontOffice.Main.Utilities;
|
||||
|
||||
public class OtpDialogService
|
||||
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IDeviceDetector _deviceDetector;
|
||||
private readonly DialogOptions _normalWidth = new() { MaxWidth = MaxWidth.ExtraSmall, FullWidth = true };
|
||||
|
||||
public OtpDialogService(IDialogService dialogService, IDeviceDetector deviceDetector)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(dialogService);
|
||||
ArgumentNullException.ThrowIfNull(deviceDetector);
|
||||
_dialogService = dialogService!;
|
||||
_deviceDetector = deviceDetector!;
|
||||
}
|
||||
|
||||
public async Task ShowAuthDialogAsync()
|
||||
{
|
||||
// Pick dialog size based on device type
|
||||
var options = _deviceDetector.IsMobile()
|
||||
? new DialogOptions() { FullScreen = true}
|
||||
: _normalWidth;
|
||||
|
||||
var dialog = await _dialogService.ShowAsync<SimpleOtpDialog>("تأیید قرارداد", options);
|
||||
var result = await dialog.Result;
|
||||
|
||||
if (!result.Canceled)
|
||||
{
|
||||
// User logged in successfully
|
||||
// You can add additional logic here if needed
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user