Datepicker überwachen
und Arbeitszeit des gewählten Tages ausgeben.
This commit is contained in:
@@ -18,6 +18,9 @@ namespace Jugenddienst_Stunden.ViewModels {
|
||||
public ICommand LoadDataCommand { get; private set; }
|
||||
public object Stunden { get; }
|
||||
|
||||
public static int GetDay = DateTime.Today.Day;
|
||||
public string ShowDay => "Zeit an Tag " + GetDay + ": ";
|
||||
|
||||
|
||||
/* Nicht gemergte Änderung aus Projekt "Jugenddienst Stunden (net8.0-ios)"
|
||||
Vor:
|
||||
@@ -53,14 +56,26 @@ namespace Jugenddienst_Stunden.ViewModels {
|
||||
//get => _hour.MinDate;
|
||||
get => DateTime.Today.AddDays(-21);
|
||||
}
|
||||
|
||||
public DateTime MaximumDate {
|
||||
//get => _hour.MaxDate;
|
||||
get => DateTime.Today.AddDays(5);
|
||||
}
|
||||
|
||||
private DateTime dateToday = DateTime.Today;
|
||||
public DateTime DateToday {
|
||||
//get => _hour.Today;
|
||||
get => DateTime.Today;
|
||||
get => dateToday;
|
||||
set {
|
||||
if (dateToday != value) {
|
||||
dateToday = value;
|
||||
GetDay = dateToday.Day;
|
||||
OnPropertyChanged();
|
||||
_ = LoadData(); // Use discard operator to explicitly ignore the returned Task
|
||||
RefreshProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime Date {
|
||||
get => _hour.Date;
|
||||
}
|
||||
@@ -86,6 +101,7 @@ namespace Jugenddienst_Stunden.ViewModels {
|
||||
set {
|
||||
if (selectedOption != value) {
|
||||
selectedOption = value;
|
||||
//new AsyncRelayCommand(LoadData);
|
||||
OnPropertyChanged(nameof(SelectedOption));
|
||||
}
|
||||
}
|
||||
@@ -134,7 +150,7 @@ namespace Jugenddienst_Stunden.ViewModels {
|
||||
//Models.Hours Hours = new Models.Hours();
|
||||
//Title = _hour.operator_api.name + " " + _hour.operator_api.surname;
|
||||
if (_hour != null) {
|
||||
TimeDay = _hour.zeit_total_daily_api.Where(p => p.Day == 1).ToList();
|
||||
TimeDay = _hour.zeit_total_daily_api.Where(p => p.Day == GetDay).ToList();
|
||||
RefreshProperties();
|
||||
}
|
||||
}
|
||||
@@ -151,7 +167,8 @@ namespace Jugenddienst_Stunden.ViewModels {
|
||||
OnPropertyChanged(nameof(TimeDay));
|
||||
OnPropertyChanged(nameof(MinimumDate));
|
||||
OnPropertyChanged(nameof(MaximumDate));
|
||||
OnPropertyChanged(nameof(DateToday));
|
||||
OnPropertyChanged(nameof(ShowDay));
|
||||
//OnPropertyChanged(nameof(DateToday));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,9 +33,13 @@
|
||||
|
||||
<BoxView HeightRequest="1" Color="Red"/>
|
||||
|
||||
<DatePicker MinimumDate="{Binding MinimumDate}"
|
||||
<Grid RowDefinitions="Auto" ColumnDefinitions="Auto,*">
|
||||
<DatePicker Grid.Column="0" MinimumDate="{Binding MinimumDate}"
|
||||
MaximumDate="{Binding MaximumDate}"
|
||||
Date="{Binding DateToday}" Format="dddd, d. MMM. yyyy" />
|
||||
<Label Grid.Column="1" Text="{Binding TimeDay[0].Hours}" VerticalOptions="Center"></Label>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid ColumnDefinitions="Auto,Auto,Auto">
|
||||
<Picker x:Name="pick_gemeinde" Title="Gemeinde" ItemsSource="{Binding Options}" SelectedItem="{Binding SelectedOption, Mode=TwoWay}" Grid.Column="0" >
|
||||
@@ -54,8 +58,8 @@
|
||||
<TimePicker HorizontalOptions="Center" Grid.Column="3" Background="OrangeRed" TextColor="White" />
|
||||
</Grid>
|
||||
|
||||
<Label Text="Zeit an Tag 1:"></Label>
|
||||
<Label Text="{Binding TimeDay[0].Hours}"></Label>
|
||||
<Label Text="{Binding ShowDay}"></Label>
|
||||
|
||||
|
||||
|
||||
</VerticalStackLayout>
|
||||
|
||||
@@ -18,4 +18,8 @@ public partial class StundenPage : ContentPage {
|
||||
base.OnAppearing();
|
||||
Title = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");
|
||||
}
|
||||
|
||||
protected void OnDateSelected(object sender, DateChangedEventArgs e) {
|
||||
DateTime selectedDate = e.NewDate;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user