Swipe down to refresh
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Jugenddienst_Stunden.Types;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -20,11 +21,23 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
||||
public ICommand NewEntryCommand { get; }
|
||||
public ICommand SelectEntryCommand { get; }
|
||||
public ICommand LoadDataCommand { get; private set; }
|
||||
public ICommand LoadDayCommand { get; private set; }
|
||||
public ICommand RefreshListCommand { get; }
|
||||
public ICommand RefreshCommand { get; }
|
||||
|
||||
public event EventHandler<string> AlertEvent;
|
||||
public event EventHandler<string> InfoEvent;
|
||||
|
||||
private bool isRefreshing;
|
||||
public bool IsRefreshing {
|
||||
get => isRefreshing;
|
||||
set {
|
||||
if (isRefreshing != value) {
|
||||
isRefreshing = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string _title = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");
|
||||
public string Title {
|
||||
@@ -76,11 +89,12 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
||||
dateToday = value;
|
||||
//GetDay = value;
|
||||
//OnPropertyChanged();
|
||||
_ = LoadDay(value);
|
||||
Task.Run(() => LoadDay(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Monatsübersicht: Geleistete Stunden
|
||||
/// </summary>
|
||||
@@ -137,6 +151,8 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
||||
|
||||
Task task = LoadDay(DateTime.Today);
|
||||
|
||||
RefreshCommand = new Command(async () => await RefreshItemsAsync());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -219,6 +235,17 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task RefreshItemsAsync() {
|
||||
IsRefreshing = true;
|
||||
|
||||
// Fügen Sie hier die Logik zum Aktualisieren der Daten hinzu
|
||||
//await Task.Delay(2000); // Simuliert eine Datenaktualisierung
|
||||
await LoadDay(DateToday);
|
||||
|
||||
IsRefreshing = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes all properties
|
||||
/// </summary>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
|
||||
<RefreshView x:Name="MyRefreshView" Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}" Margin="10" Padding="10">
|
||||
<VerticalStackLayout Spacing="10" Margin="10">
|
||||
|
||||
<Grid RowDefinitions="Auto" ColumnDefinitions="Auto,*" HeightRequest="50">
|
||||
@@ -113,4 +113,5 @@
|
||||
|
||||
</VerticalStackLayout>
|
||||
|
||||
</RefreshView>
|
||||
</ContentPage>
|
||||
Reference in New Issue
Block a user