Figyelmeztető üzenet javítása + hangjelzés

This commit is contained in:
2025-04-16 08:41:30 +02:00
parent ab86c845ab
commit 8815df06b3
6 changed files with 66 additions and 10 deletions
+41 -9
View File
@@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using System.Threading;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.DataLayer;
using WorkFlowCheck.MAUI.Helper;
using WorkFlowCheck.MAUI.Services;
using WorkFlowCheck.MAUI.Services.Interfaces;
@@ -70,7 +71,7 @@ namespace WorkFlowCheck.MAUI
{
var userDTO = _userService.GetCurrentUser();
if (userDTO != null && userDTO.Id > 0)
if (userDTO != null && userDTO.Id > 0 && SystemHelper.Syncronised)
{
if (userDTO.RoleDTO?.Count > 0)
{
@@ -81,7 +82,13 @@ namespace WorkFlowCheck.MAUI
var deviceMessageDTOList = await _syncService.DeviceMessageReadUnreaded(_userService.DeviceId.ToUpper());
if (deviceMessageDTOList != null && deviceMessageDTOList.Count > 0)
{
await ShowSnackbar(deviceMessageDTOList[0].Message);
await ShowSnackbar(deviceMessageDTOList[0].Message, async () => await GoToCheckListPage());
break;
}
deviceMessageDTOList = await _syncService.DeviceMessageReadUnreadedRole(roleDTO.Id);
if (deviceMessageDTOList != null && deviceMessageDTOList.Count > 0)
{
await ShowSnackbar(deviceMessageDTOList[0].Message, async () => await GoToCheckListPage());
break;
}
}
@@ -96,8 +103,32 @@ namespace WorkFlowCheck.MAUI
await Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
}
}
private async Task ShowSnackbar(string message)
private async Task GoToCheckListPage()
{
await Shell.Current.GoToAsync("//CheckListPage");
}
private async Task ShowSnackbar(string message, Func<Task> action)
{
#if ANDROID
try
{
var context = Android.App.Application.Context;
var player = Android.Media.MediaPlayer.Create(context, Resource.Raw.siren_alert);
player.Start();
// Ha lejátszás után el akarod engedni az erőforrást:
player.Completion += (s, e) =>
{
player.Release();
player.Dispose();
};
}
catch (Exception ex)
{
Console.WriteLine("Hanglejátszás hiba: " + ex.Message);
}
#endif
var visualOptions = new SnackbarOptions
{
ActionButtonTextColor = Colors.Yellow,
@@ -105,17 +136,18 @@ namespace WorkFlowCheck.MAUI
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
TextColor = Colors.Yellow
};
var snackbar = Snackbar.Make(message,
duration: TimeSpan.FromSeconds(10),
action: () => Console.WriteLine("Snackbar dismissed"),
actionButtonText: "OK",
visualOptions: visualOptions
);
duration: TimeSpan.FromSeconds(10),
action: async () => await action(),
actionButtonText: "OK",
visualOptions: visualOptions
);
await snackbar.Show();
}
private async Task<ApiResponseDTO<UserDTO>> CheckSecurity()
{
var isLogged = await SecureStorage.Default.GetAsync("WFCUser");