Add InfoEvent with confirmation
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Jugenddienst_Stunden.Interfaces;
|
||||
using Jugenddienst_Stunden.Models;
|
||||
|
||||
namespace Jugenddienst_Stunden.ViewModels;
|
||||
|
||||
@@ -15,7 +16,8 @@ public partial class LoginViewModel : ObservableObject {
|
||||
private readonly TimeSpan _detectionInterval = TimeSpan.FromSeconds(5);
|
||||
|
||||
public event EventHandler<string>? AlertEvent;
|
||||
public event EventHandler<string>? InfoEvent;
|
||||
//public event EventHandler<string>? InfoEvent;
|
||||
public event EventHandler<ConfirmationEventArgs>? InfoEvent;
|
||||
|
||||
/// <summary>
|
||||
/// Name der Anwendung
|
||||
@@ -102,9 +104,13 @@ public partial class LoginViewModel : ObservableObject {
|
||||
(Server ?? string.Empty).Trim());
|
||||
|
||||
Title = $"{user.Name} {user.Surname}";
|
||||
InfoEvent?.Invoke(this, "Login erfolgreich");
|
||||
|
||||
await Shell.Current.GoToAsync("//StundenPage");
|
||||
// Info zeigen und auf Bestätigung warten
|
||||
var args = new ConfirmationEventArgs("Information:", "Login erfolgreich");
|
||||
InfoEvent?.Invoke(this, args);
|
||||
bool confirmed = await args.Task;
|
||||
if (confirmed) {
|
||||
await Shell.Current.GoToAsync("//StundenPage");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (_alerts is not null) {
|
||||
_alerts.Raise(ex.Message);
|
||||
@@ -128,7 +134,13 @@ public partial class LoginViewModel : ObservableObject {
|
||||
var user = await _auth.LoginWithToken(token);
|
||||
Title = $"{user.Name} {user.Surname}";
|
||||
|
||||
await Shell.Current.GoToAsync("//StundenPage");
|
||||
// Info zeigen und auf Bestätigung warten
|
||||
var infoArgs = new ConfirmationEventArgs("Information:", "Login erfolgreich");
|
||||
InfoEvent?.Invoke(this, infoArgs);
|
||||
bool confirmed = await infoArgs.Task;
|
||||
if (confirmed) {
|
||||
await Shell.Current.GoToAsync("//StundenPage");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
if (_alerts is not null) {
|
||||
_alerts.Raise(ex.Message);
|
||||
|
||||
Reference in New Issue
Block a user