Swipe down to refresh
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Jugenddienst_Stunden.Types;
|
using Jugenddienst_Stunden.Types;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@@ -20,13 +21,25 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
|||||||
public ICommand NewEntryCommand { get; }
|
public ICommand NewEntryCommand { get; }
|
||||||
public ICommand SelectEntryCommand { get; }
|
public ICommand SelectEntryCommand { get; }
|
||||||
public ICommand LoadDataCommand { get; private set; }
|
public ICommand LoadDataCommand { get; private set; }
|
||||||
|
public ICommand LoadDayCommand { get; private set; }
|
||||||
public ICommand RefreshListCommand { get; }
|
public ICommand RefreshListCommand { get; }
|
||||||
|
public ICommand RefreshCommand { get; }
|
||||||
|
|
||||||
public event EventHandler<string> AlertEvent;
|
public event EventHandler<string> AlertEvent;
|
||||||
public event EventHandler<string> InfoEvent;
|
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", "");
|
private string _title = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");
|
||||||
public string Title {
|
public string Title {
|
||||||
get => _title;
|
get => _title;
|
||||||
set => SetProperty(ref _title, value);
|
set => SetProperty(ref _title, value);
|
||||||
@@ -76,11 +89,12 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
|||||||
dateToday = value;
|
dateToday = value;
|
||||||
//GetDay = value;
|
//GetDay = value;
|
||||||
//OnPropertyChanged();
|
//OnPropertyChanged();
|
||||||
_ = LoadDay(value);
|
Task.Run(() => LoadDay(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Monatsübersicht: Geleistete Stunden
|
/// Monatsübersicht: Geleistete Stunden
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -137,7 +151,9 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
|||||||
|
|
||||||
Task task = LoadDay(DateTime.Today);
|
Task task = LoadDay(DateTime.Today);
|
||||||
|
|
||||||
}
|
RefreshCommand = new Command(async () => await RefreshItemsAsync());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -219,10 +235,21 @@ internal class StundenViewModel : ObservableObject, IQueryAttributable, INotifyP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Refreshes all properties
|
private async Task RefreshItemsAsync() {
|
||||||
/// </summary>
|
IsRefreshing = true;
|
||||||
private void RefreshProperties() {
|
|
||||||
|
// 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>
|
||||||
|
private void RefreshProperties() {
|
||||||
OnPropertyChanged(nameof(Nominal));
|
OnPropertyChanged(nameof(Nominal));
|
||||||
OnPropertyChanged(nameof(Overtime));
|
OnPropertyChanged(nameof(Overtime));
|
||||||
OnPropertyChanged(nameof(OvertimeMonth));
|
OnPropertyChanged(nameof(OvertimeMonth));
|
||||||
|
|||||||
@@ -22,19 +22,19 @@
|
|||||||
|
|
||||||
</ContentPage.ToolbarItems>
|
</ContentPage.ToolbarItems>
|
||||||
|
|
||||||
|
<RefreshView x:Name="MyRefreshView" Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}" Margin="10" Padding="10">
|
||||||
|
<VerticalStackLayout Spacing="10" Margin="10">
|
||||||
|
|
||||||
<VerticalStackLayout Spacing="10" Margin="10">
|
<Grid RowDefinitions="Auto" ColumnDefinitions="Auto,*" HeightRequest="50">
|
||||||
|
<DatePicker Grid.Column="0" MinimumDate="{Binding MinimumDate}"
|
||||||
<Grid RowDefinitions="Auto" ColumnDefinitions="Auto,*" HeightRequest="50">
|
|
||||||
<DatePicker Grid.Column="0" MinimumDate="{Binding MinimumDate}"
|
|
||||||
MaximumDate="{Binding MaximumDate}"
|
MaximumDate="{Binding MaximumDate}"
|
||||||
Date="{Binding DateToday}" Format="dddd, d. MMMM yyyy" />
|
Date="{Binding DateToday}" Format="dddd, d. MMMM yyyy" />
|
||||||
<Border Grid.Column="1" Margin="15,0,0,0" Padding="15,0,0,0" ToolTipProperties.Text="Tagessumme">
|
<Border Grid.Column="1" Margin="15,0,0,0" Padding="15,0,0,0" ToolTipProperties.Text="Tagessumme">
|
||||||
<Label Text="{Binding DayTotal,StringFormat='{}{0:HH:mm}'}" VerticalOptions="Center"></Label>
|
<Label Text="{Binding DayTotal,StringFormat='{}{0:HH:mm}'}" VerticalOptions="Center"></Label>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<CollectionView
|
<CollectionView
|
||||||
ItemsSource="{Binding DayTimes}"
|
ItemsSource="{Binding DayTimes}"
|
||||||
x:Name="stundeItems" Margin="0"
|
x:Name="stundeItems" Margin="0"
|
||||||
HeightRequest="300"
|
HeightRequest="300"
|
||||||
@@ -42,75 +42,76 @@
|
|||||||
SelectionChangedCommand="{Binding SelectEntryCommand}"
|
SelectionChangedCommand="{Binding SelectEntryCommand}"
|
||||||
SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}">
|
SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}">
|
||||||
|
|
||||||
<CollectionView.ItemsLayout>
|
<CollectionView.ItemsLayout>
|
||||||
<LinearItemsLayout Orientation="Vertical" ItemSpacing="0" />
|
<LinearItemsLayout Orientation="Vertical" ItemSpacing="0" />
|
||||||
</CollectionView.ItemsLayout>
|
</CollectionView.ItemsLayout>
|
||||||
|
|
||||||
<CollectionView.ItemTemplate>
|
<CollectionView.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid Padding="5,10,5,0">
|
<Grid Padding="5,10,5,0">
|
||||||
<VisualStateManager.VisualStateGroups>
|
<VisualStateManager.VisualStateGroups>
|
||||||
<VisualStateGroup Name="CommonStates">
|
<VisualStateGroup Name="CommonStates">
|
||||||
<VisualState Name="Normal">
|
<VisualState Name="Normal">
|
||||||
<VisualState.Setters>
|
<VisualState.Setters>
|
||||||
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource TransparentColor}}" />
|
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource TransparentColor}}" />
|
||||||
</VisualState.Setters>
|
</VisualState.Setters>
|
||||||
</VisualState>
|
</VisualState>
|
||||||
<VisualState Name="Selected">
|
<VisualState Name="Selected">
|
||||||
<VisualState.Setters>
|
<VisualState.Setters>
|
||||||
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource PrimaryDark}}" />
|
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource PrimaryDark}}" />
|
||||||
</VisualState.Setters>
|
</VisualState.Setters>
|
||||||
</VisualState>
|
</VisualState>
|
||||||
</VisualStateGroup>
|
</VisualStateGroup>
|
||||||
</VisualStateManager.VisualStateGroups>
|
</VisualStateManager.VisualStateGroups>
|
||||||
|
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<HorizontalStackLayout Grid.Row="0" HorizontalOptions="FillAndExpand">
|
<HorizontalStackLayout Grid.Row="0" HorizontalOptions="FillAndExpand">
|
||||||
<Label Grid.Column="0" Text="{Binding begin}" />
|
<Label Grid.Column="0" Text="{Binding begin}" />
|
||||||
<Label Text="bis" Padding="5,0,5,0" />
|
<Label Text="bis" Padding="5,0,5,0" />
|
||||||
<Label Text="{Binding end}" />
|
<Label Text="{Binding end}" />
|
||||||
<Label Text="{Binding GemeindeAktiv.Name}" Margin="10,0,0,0" />
|
<Label Text="{Binding GemeindeAktiv.Name}" Margin="10,0,0,0" />
|
||||||
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0" />
|
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0" />
|
||||||
<Label Text="{Binding FreistellungAktiv.Id}" Margin="10,0,0,0" />
|
<Label Text="{Binding FreistellungAktiv.Id}" Margin="10,0,0,0" />
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
|
|
||||||
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding description}" Padding="0,0,0,15"/>
|
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding description}" Padding="0,0,0,15"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</CollectionView.ItemTemplate>
|
</CollectionView.ItemTemplate>
|
||||||
|
|
||||||
</CollectionView>
|
</CollectionView>
|
||||||
|
|
||||||
<BoxView HeightRequest="1" />
|
<BoxView HeightRequest="1" />
|
||||||
|
|
||||||
<Button Text="{Binding LoadOverview}" Command="{Binding LoadDataCommand}" />
|
<Button Text="{Binding LoadOverview}" Command="{Binding LoadDataCommand}" />
|
||||||
<Frame Padding="2" HeightRequest="125">
|
<Frame Padding="2" HeightRequest="125">
|
||||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,*" ColumnDefinitions="Auto,*" Margin="10,2">
|
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,*" ColumnDefinitions="Auto,*" Margin="10,2">
|
||||||
<Label Grid.Row="0" Text="Soll:" />
|
<Label Grid.Row="0" Text="Soll:" />
|
||||||
<Label Grid.Row="1" Text="Summe:" />
|
<Label Grid.Row="1" Text="Summe:" />
|
||||||
<Label Grid.Row="2" Text="Differenz:" Margin="0,0,15,0" />
|
<Label Grid.Row="2" Text="Differenz:" Margin="0,0,15,0" />
|
||||||
<BoxView Grid.Row="3" Grid.ColumnSpan="2" HeightRequest="1" Color="LightGrey" Margin="0,5"/>
|
<BoxView Grid.Row="3" Grid.ColumnSpan="2" HeightRequest="1" Color="LightGrey" Margin="0,5"/>
|
||||||
<Label Grid.Row="4" Text="Restüberstunden:" />
|
<Label Grid.Row="4" Text="Restüberstunden:" />
|
||||||
<Label Grid.Row="5" Text="Resturlaub:" />
|
<Label Grid.Row="5" Text="Resturlaub:" />
|
||||||
|
|
||||||
|
|
||||||
<Label Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Nominal}" ToolTipProperties.Text="Sollstunden" />
|
<Label Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Nominal}" ToolTipProperties.Text="Sollstunden" />
|
||||||
<Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitCalculated}" ToolTipProperties.Text="Geleistete Stunden" />
|
<Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitCalculated}" ToolTipProperties.Text="Geleistete Stunden" />
|
||||||
<Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding OvertimeMonth}" />
|
<Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding OvertimeMonth}" />
|
||||||
<Label Grid.Row="4" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Overtime}" />
|
<Label Grid.Row="4" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Overtime}" />
|
||||||
<Label Grid.Row="5" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Holiday}" />
|
<Label Grid.Row="5" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Holiday}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Frame>
|
</Frame>
|
||||||
|
|
||||||
|
|
||||||
</VerticalStackLayout>
|
</VerticalStackLayout>
|
||||||
|
|
||||||
|
</RefreshView>
|
||||||
</ContentPage>
|
</ContentPage>
|
||||||
Reference in New Issue
Block a user