Refactor StundePage and ViewModels: adjust grid padding, clean up commented code, add SelectEntryCommand, and improve navigation logic.
This commit is contained in:
@@ -74,6 +74,7 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
public ICommand SaveCommand { get; private set; }
|
||||
public ICommand DeleteCommand { get; private set; }
|
||||
public ICommand DeleteConfirmCommand { get; private set; }
|
||||
public ICommand SelectEntryCommand { get; }
|
||||
//public ICommand LoadDataCommand { get; private set; }
|
||||
|
||||
|
||||
@@ -83,6 +84,7 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
_alertService = alertService;
|
||||
SaveCommand = new AsyncRelayCommand(Save);
|
||||
DeleteConfirmCommand = new Command(async () => await DeleteConfirm());
|
||||
SelectEntryCommand = new AsyncRelayCommand<DayTime>(SelectEntryAsync);
|
||||
|
||||
_alertService.AlertRaised += (s, msg) => AlertEvent?.Invoke(this, msg);
|
||||
}
|
||||
@@ -136,7 +138,8 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
|
||||
if (!exceptionOccurred) {
|
||||
if (DayTime.Id != null) {
|
||||
await Shell.Current.GoToAsync($"..?saved={DayTime.Id}");
|
||||
//await Shell.Current.GoToAsync($"..?saved={DayTime.Id}");
|
||||
await Shell.Current.GoToAsync($"//StundenPage?saved={DayTime.Id}");
|
||||
} else {
|
||||
await Shell.Current.GoToAsync($"..?date={DayTime.Day.ToString("yyyy-MM-dd")}");
|
||||
}
|
||||
@@ -173,6 +176,19 @@ public partial class StundeViewModel : ObservableObject, IQueryAttributable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Öffnet eine bestehende Stundeneingabe
|
||||
/// </summary>
|
||||
private async Task SelectEntryAsync(DayTime entry) {
|
||||
if (entry != null && entry.Id != null) {
|
||||
//var navigationParameters = new Dictionary<string, object> { { "load", entry.id } };
|
||||
//await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}", navigationParameters);
|
||||
await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}?load={entry.Id}");
|
||||
} else AlertEvent?.Invoke(this, "Auswahl enthält keine Daten");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Anwenden der Query-Parameter
|
||||
/// </summary>
|
||||
|
||||
@@ -172,16 +172,6 @@ public partial class StundenViewModel : ObservableObject, IQueryAttributable, IN
|
||||
RefreshListCommand = new AsyncRelayCommand(RefreshList);
|
||||
RefreshCommand = new Command(async () => await RefreshItemsAsync());
|
||||
|
||||
// Task task = LoadDay(DateTime.Today);
|
||||
// Beim Startup NICHT direkt im CTOR laden (kann Startup/Navigation blockieren)
|
||||
// Stattdessen via Dispatcher "nach" dem Aufbau starten:
|
||||
// MainThread.BeginInvokeOnMainThread(async () => {
|
||||
// try {
|
||||
// await LoadDay(DateTime.Today);
|
||||
// } catch (Exception ex) {
|
||||
// AlertEvent?.Invoke(this, ex.Message);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
StatusBarStyle="LightContent" />
|
||||
</ContentPage.Behaviors>
|
||||
|
||||
<Grid>
|
||||
<Grid Padding="10,0,10,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
|
||||
Reference in New Issue
Block a user