using CommunityToolkit.Maui.Alerts; using CommunityToolkit.Maui.Core; using Jugenddienst_Stunden.Models; using Jugenddienst_Stunden.ViewModels; using System.Windows.Input; namespace Jugenddienst_Stunden.Views; /// /// Einzelner Stundeneintrag /// public partial class StundePage : ContentPage { /// /// CTOR /// public StundePage() { InitializeComponent(); if (BindingContext is StundeViewModel 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 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 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; //} }