NFC azonosítás is beállítva

This commit is contained in:
2025-04-06 14:41:36 +02:00
parent 71a5850d65
commit dc3e6e2f7b
8 changed files with 157 additions and 17 deletions
@@ -48,15 +48,27 @@
BackgroundColor="#f9f9f9"
HeightRequest="50"
Margin="0" />
<HorizontalStackLayout Spacing="20" HorizontalOptions="Center">
<RadioButton x:Name="ProdOption" Content="PROD" GroupName="Environment" />
<RadioButton x:Name="UatOption" Content="UAT" GroupName="Environment" />
</HorizontalStackLayout>
<Button x:Name="LoginBtn"
Text="Bejelentkezés"
FontSize="18"
HeightRequest="50"
CornerRadius="10"
BackgroundColor="#007aff"
TextColor="White"
Clicked="OnLoginClicked" />
<Button x:Name="LoginNFCBtn"
Text="NFC azonosítás"
FontSize="18"
HeightRequest="50"
CornerRadius="10"
TextColor="White"
Clicked="OnLoginNFCClicked" />
<ActivityIndicator x:Name="LoadingIndicator"
IsRunning="False"
@@ -1,6 +1,7 @@
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
using System.Drawing;
using WorkFlowCheck.MAUI.Pages.NFC;
using WorkFlowCheck.MAUI.Services.Interfaces;
namespace WorkFlowCheck.MAUI.Pages.Security;
@@ -29,7 +30,7 @@ public partial class LoginPage : ContentPage
if (response != null && response.IsSuccess)
{
_userService.SetCurrentUser(response.Data);
//await _syncService.SyncDatas();
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
@@ -40,14 +41,14 @@ public partial class LoginPage : ContentPage
}
else
{
var visualOptions = new SnackbarOptions
{
ActionButtonTextColor = Colors.Yellow,
CornerRadius = new CornerRadius(10),
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
TextColor=Colors.Yellow
TextColor = Colors.Yellow
};
var snackbar = Snackbar.Make(
@@ -77,4 +78,71 @@ public partial class LoginPage : ContentPage
}
}
private async void OnLoginNFCClicked(object sender, EventArgs e)
{
LoadingIndicator.IsRunning = true;
LoadingIndicator.IsVisible = true;
LoginBtn.IsEnabled = false;
LoginNFCBtn.IsEnabled = false;
UsernameEntry.IsEnabled = false;
PasswordEntry.IsEnabled = false;
try
{
var nFCCode = await NFCWaiter.ShowModalAsync();
if (!string.IsNullOrEmpty(nFCCode))
{
var response = await _userService.AuthenticateNFC(nFCCode);
if (response != null && response.IsSuccess)
{
_userService.SetCurrentUser(response.Data);
//await _syncService.SyncDatas();
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
await SecureStorage.Default.SetAsync("AuthToken", response.Data.JwtToken);
await Shell.Current.GoToAsync("//SyncPage");
}
else
{
var visualOptions = new SnackbarOptions
{
ActionButtonTextColor = Colors.Yellow,
CornerRadius = new CornerRadius(10),
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
TextColor = Colors.Yellow
};
var snackbar = Snackbar.Make(
"Invalid login credentials.",
duration: TimeSpan.FromSeconds(10),
action: () => Console.WriteLine("Snackbar dismissed"),
actionButtonText: "OK",
visualOptions: visualOptions
);
await snackbar.Show();
}
}
}
catch (Exception)
{
throw;
}
finally
{
LoginBtn.IsEnabled = true;
LoadingIndicator.IsRunning = false;
LoadingIndicator.IsVisible = false;
UsernameEntry.IsEnabled = true;
PasswordEntry.IsEnabled = true;
LoginNFCBtn.IsEnabled = true;
}
}
}
@@ -35,7 +35,7 @@ public partial class UsersPage : ContentPage
{
IsRefreshing = true;
//await _syncService.SyncDatas();
UsersList.ItemsSource = await _userService.GetAllUsers();
//UsersList.ItemsSource = await _userService.GetAllUserAsync().Result.Data;
IsRefreshing = false;
OnPropertyChanged(nameof(IsRefreshing));
}
@@ -51,8 +51,8 @@ public partial class UsersPage : ContentPage
}
if (UserDTO != null)
{
UserDTO.Code = UserCode;
await _baseStockService.UpdateUser(UserDTO);
//UserDTO.Code = UserCode;
//await _baseStockService.UpdateUser(UserDTO);
await LoadUsers();
}
}