UI BUGFIX

This commit is contained in:
2025-04-09 15:37:30 +02:00
parent d383ccccbd
commit e3ee93c74c
5 changed files with 74 additions and 15 deletions
@@ -1,3 +1,5 @@
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
using System.Diagnostics;
using System.Globalization;
using System.Threading.Tasks;
@@ -13,6 +15,7 @@ public partial class CheckListPage : ContentPage
{
private readonly ICheckListService _checkListService;
private readonly IUserService _userService;
private readonly ISyncService _syncService;
private bool _isLoading;
private UserDTO _currentUser;
@@ -36,6 +39,7 @@ public partial class CheckListPage : ContentPage
InitializeComponent();
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
NewCommand = new Command<CheckListTemplateHeaderDTO>(OnNewItem);
ContinueCommand = new Command<CheckListHeaderDTO>(OnContinueItem);
UnblockCommand = new Command<CheckListHeaderDTO>(OnUnblockItem);
@@ -64,13 +68,48 @@ public partial class CheckListPage : ContentPage
private async void OnNewItem(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
{
IsLoading = true;
await _checkListService.StartNew(
var response = await _checkListService.StartNew(
new CheckListHeaderNewDTO()
{
UserId = _userService.GetCurrentUser().Id,
CheckListTemplateHeaderId = checkListTemplateHeaderDTO.Id
});
IsLoading = false;
if (response != null && response.IsSuccess)
{
await Task.Run(async () =>
{
await _syncService.SyncCheckListHeader_Down((percentage, infostring) =>
{
// Direkt UI frissítés
MainThread.BeginInvokeOnMainThread(() =>
{
//progressBar.Progress = percentage / 100;
//progressLabel.Text = $"{infostring}: {percentage:0.00}%";
});
});
});
await LoadCheckList();
var visualOptions = new SnackbarOptions
{
ActionButtonTextColor = Colors.White,
CornerRadius = new CornerRadius(10),
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Green"),
TextColor = Colors.White
};
var snackbar = Snackbar.Make(
$"Új ellenõrzés indult! {response.Data.DocumentNumber}",
duration: TimeSpan.FromSeconds(10),
action: () => Console.WriteLine("Snackbar dismissed"),
actionButtonText: "OK",
visualOptions: visualOptions
);
await snackbar.Show();
}
}
private async void OnContinueItem(CheckListHeaderDTO checkListHeaderDTO)
{
@@ -96,15 +135,34 @@ public partial class CheckListPage : ContentPage
private async Task LoadCheckListTemplate()
{
IsLoading = true;
CheckListTemplate.ItemsSource = await _checkListService.GetCheckListTemplates(_currentUser.Id);
IsLoading = false;
}
private async Task LoadCheckList()
{
IsLoading = true;
CheckList.ItemsSource = await _checkListService.GetCheckLists(_currentUser.Id);
var checkListHeaderDTOs = await _checkListService.GetCheckLists(_currentUser.Id);
var isAdmin = false;
var userDTO = _userService.GetCurrentUser();
foreach (var roleDTO in userDTO.RoleDTO)
{
if (roleDTO.IsAdmin)
{
isAdmin = true;
CheckList.ItemsSource = checkListHeaderDTOs;
break;
}
}
if (!isAdmin)
{
var result = checkListHeaderDTOs
.Where(w => w.UserId == userDTO.Id && w.CheckStatus != CheckStatus.Blocked).ToList();
CheckList.ItemsSource = result;
}
IsLoading = false;
}