Snackbar meg ilyesmik
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
using CommunityToolkit.Maui.Alerts;
|
||||
using CommunityToolkit.Maui.Core;
|
||||
using System.Drawing;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.Security;
|
||||
|
||||
public partial class LoginPage : ContentPage
|
||||
{
|
||||
private IUserService _userService;
|
||||
private IUserService _userService;
|
||||
private ISyncService _syncService;
|
||||
public LoginPage()
|
||||
{
|
||||
@@ -26,17 +29,35 @@ public partial class LoginPage : ContentPage
|
||||
if (response != null && response.IsSuccess)
|
||||
{
|
||||
_userService.SetCurrentUser(response.Data);
|
||||
await _syncService.SyncDatas();
|
||||
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 SecureStorage.Default.SetAsync("AuthToken", response.Data.JwtToken);
|
||||
|
||||
await Shell.Current.GoToAsync("//MainPage");
|
||||
}
|
||||
else
|
||||
{
|
||||
await DisplayAlert("Error", "Invalid login credentials.", "OK");
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user