51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using CommunityToolkit.Maui.Alerts;
|
|
using CommunityToolkit.Maui.Core;
|
|
using Jugenddienst_Stunden.Models;
|
|
using Jugenddienst_Stunden.ViewModels;
|
|
using System.Windows.Input;
|
|
|
|
namespace Jugenddienst_Stunden.Views;
|
|
|
|
/// <summary>
|
|
/// Einzelner Stundeneintrag
|
|
/// </summary>
|
|
public partial class StundePage : ContentPage {
|
|
/// <summary>
|
|
/// CTOR
|
|
/// </summary>
|
|
public StundePage(StundeViewModel vm) {
|
|
InitializeComponent();
|
|
|
|
BindingContext = vm;
|
|
vm.AlertEvent += Vm_AlertEvent;
|
|
vm.InfoEvent += Vm_InfoEvent;
|
|
vm.ConfirmEvent += ShowConfirm;
|
|
}
|
|
|
|
private void Vm_AlertEvent(object? sender, string e) {
|
|
DisplayAlert("Fehler:", e, "OK");
|
|
}
|
|
|
|
private async Task<bool> ShowConfirm(string title, string message) {
|
|
return await DisplayAlert(title, message, "Passt!", "Na, nor decht nit.");
|
|
}
|
|
|
|
private void Vm_InfoEvent(object? sender, string e) {
|
|
MainThread.BeginInvokeOnMainThread(async () => {
|
|
CancellationTokenSource cts = new CancellationTokenSource();
|
|
ToastDuration duration = ToastDuration.Short;
|
|
double fontSize = 20;
|
|
var toast = Toast.Make(e, duration, fontSize);
|
|
await toast.Show(cts.Token);
|
|
});
|
|
}
|
|
|
|
//private async Task<bool> ShowConfirm(string title, string message, string ok, string not_ok) {
|
|
// return await DisplayAlert(title, message, ok, not_ok);
|
|
//}
|
|
|
|
//private async void ShowConfirm(object? sender, ConfirmEventArgs e) {
|
|
// bool result = await DisplayAlert(e.Title, e.Message, e.Ok, e.NotOk);
|
|
// e.Result = result;
|
|
//}
|
|
} |