Gui Changes

This commit is contained in:
2024-09-19 19:36:36 +02:00
parent b5c20b8177
commit 7803c3dc27
6 changed files with 46 additions and 46 deletions

View File

@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using Jugenddienst_Stunden.Models;
using Jugenddienst_Stunden.Types; using Jugenddienst_Stunden.Types;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -26,6 +27,8 @@ namespace Jugenddienst_Stunden.ViewModels {
} }
} }
public string SubTitle { get; set; } = DateTime.Today.ToString("dddd, d. MMM. yyyy");
public int Identifier => (int)_stunde.id; public int Identifier => (int)_stunde.id;
public ICommand SaveCommand { get; private set; } public ICommand SaveCommand { get; private set; }
@@ -40,6 +43,7 @@ namespace Jugenddienst_Stunden.ViewModels {
public StundeViewModel(Types.DayTime stunde) { public StundeViewModel(Types.DayTime stunde) {
_stunde = stunde; _stunde = stunde;
//SaveCommand = new AsyncRelayCommand(Save); //SaveCommand = new AsyncRelayCommand(Save);
//DeleteCommand = new AsyncRelayCommand(Delete); //DeleteCommand = new AsyncRelayCommand(Delete);
} }
@@ -59,8 +63,9 @@ namespace Jugenddienst_Stunden.ViewModels {
if (query.ContainsKey("load")) { if (query.ContainsKey("load")) {
//DateTime heute = DateTime.Now; //DateTime heute = DateTime.Now;
_stunde = await Models.Stunde.LoadEntry(Convert.ToInt32(query["load"])); _stunde = await Models.Stunde.LoadEntry(Convert.ToInt32(query["load"]));
SubTitle = _stunde.day.ToString("dddd, d. MMM. yyyy");
OnPropertyChanged(nameof(Stunde)); OnPropertyChanged(nameof(Stunde));
OnPropertyChanged(nameof(SubTitle));
} }
} }
} }

View File

@@ -20,6 +20,7 @@ namespace Jugenddienst_Stunden.ViewModels {
public string ShowDay => "Zeit an Tag " + GetDay.ToString("ddd d. MMM") + ": "; public string ShowDay => "Zeit an Tag " + GetDay.ToString("ddd d. MMM") + ": ";
public int id { get; set; } public int id { get; set; }
public ICommand NewEntryCommand { get; }
public ICommand SelectEntryCommand { get; } public ICommand SelectEntryCommand { get; }
public ICommand LoadDataCommand { get; private set; } public ICommand LoadDataCommand { get; private set; }
@@ -133,12 +134,18 @@ namespace Jugenddienst_Stunden.ViewModels {
_hour = new Types.Hours(); _hour = new Types.Hours();
LoadDataCommand = new AsyncRelayCommand(LoadData); LoadDataCommand = new AsyncRelayCommand(LoadData);
NewEntryCommand = new AsyncRelayCommand(NewEntryAsync);
SelectEntryCommand = new AsyncRelayCommand<DayTime>(SelectEntryAsync); SelectEntryCommand = new AsyncRelayCommand<DayTime>(SelectEntryAsync);
_ = LoadDay(DateTime.Today);
OnPropertyChanged(nameof(DayTimes));
}
private async Task NewEntryAsync() {
await Shell.Current.GoToAsync(nameof(Views.StundePage));
} }
private async Task SelectEntryAsync(DayTime entry) { private async Task SelectEntryAsync(DayTime entry) {
if (entry != null && entry.id != null) if (entry != null && entry.id != null)
await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}?load={entry.id}"); await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}?load={entry.id}");
else AlertEvent?.Invoke(this, "Auswahl enthält keine Daten"); else AlertEvent?.Invoke(this, "Auswahl enthält keine Daten");

View File

@@ -5,6 +5,7 @@
x:Class="Jugenddienst_Stunden.Views.AllNotesPage" x:Class="Jugenddienst_Stunden.Views.AllNotesPage"
Title="Deine Notizen" Title="Deine Notizen"
NavigatedTo="ContentPage_NavigatedTo"> NavigatedTo="ContentPage_NavigatedTo">
<ContentPage.BindingContext> <ContentPage.BindingContext>
<viewModels:NotesViewModel /> <viewModels:NotesViewModel />
</ContentPage.BindingContext> </ContentPage.BindingContext>
@@ -14,28 +15,32 @@
<ToolbarItem Text="Add" Command="{Binding NewCommand}" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" /> <ToolbarItem Text="Add" Command="{Binding NewCommand}" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" />
</ContentPage.ToolbarItems> </ContentPage.ToolbarItems>
<Label Text="Werden nur lokal gespeichert"/> <VerticalStackLayout>
<!-- Display notes in a list --> <Label Text="Werden nur lokal gespeichert"/>
<CollectionView x:Name="notesCollection"
<!-- Display notes in a list -->
<CollectionView x:Name="notesCollection"
ItemsSource="{Binding AllNotes}" ItemsSource="{Binding AllNotes}"
Margin="20" Margin="20"
SelectionMode="Single" SelectionMode="Single"
SelectionChangedCommand="{Binding SelectNoteCommand}" SelectionChangedCommand="{Binding SelectNoteCommand}"
SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}"> SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}">
<!-- Designate how the collection of items are laid out --> <!-- Designate how the collection of items are laid out -->
<CollectionView.ItemsLayout> <CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="10" /> <LinearItemsLayout Orientation="Vertical" ItemSpacing="10" />
</CollectionView.ItemsLayout> </CollectionView.ItemsLayout>
<!-- Define the appearance of each item in the list --> <!-- Define the appearance of each item in the list -->
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<StackLayout> <StackLayout>
<Label Text="{Binding Text}" FontSize="22"/> <Label Text="{Binding Text}" FontSize="22"/>
<Label Text="{Binding Date}" FontSize="14" TextColor="Silver"/> <Label Text="{Binding Date}" FontSize="14" TextColor="Silver"/>
</StackLayout> </StackLayout>
</DataTemplate> </DataTemplate>
</CollectionView.ItemTemplate> </CollectionView.ItemTemplate>
</CollectionView> </CollectionView>
</VerticalStackLayout>
</ContentPage> </ContentPage>

View File

@@ -3,16 +3,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels" xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
x:Class="Jugenddienst_Stunden.Views.StundePage" x:Class="Jugenddienst_Stunden.Views.StundePage"
Title="StundePage"> Title="Eintrag bearbeiten">
<ContentPage.BindingContext> <ContentPage.BindingContext>
<models:StundeViewModel /> <models:StundeViewModel />
</ContentPage.BindingContext> </ContentPage.BindingContext>
<VerticalStackLayout Spacing="10" Margin="10"> <VerticalStackLayout Spacing="10" Margin="10">
<Label Text="{Binding SubTitle}" />
<Grid Padding="5,10,5,10">
<Grid Padding="15,10,0,10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@@ -29,11 +29,11 @@
<!--<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Stunde.description}" Padding="0,0,0,5"/>--> <!--<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Text="{Binding Stunde.description}" Padding="0,0,0,5"/>-->
<Editor Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Placeholder="Beschreibung" Text="{Binding Stunde.description}" HeightRequest="40" /> <Editor Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Placeholder="Beschreibung" Text="{Binding Stunde.description}" MinimumHeightRequest="40" AutoSize="TextChanges" />
</Grid> </Grid>
<Grid ColumnDefinitions="*,*" ColumnSpacing="4"> <Grid ColumnDefinitions="*,*" ColumnSpacing="4">
<Button Text="Save" Clicked="GetDayTime" /> <Button Text="Save" />
<Button Grid.Column="1" <Button Grid.Column="1"
Text="Delete" /> Text="Delete" />

View File

@@ -6,23 +6,8 @@ namespace Jugenddienst_Stunden.Views;
public partial class StundePage : ContentPage public partial class StundePage : ContentPage
{ {
private DayTime _stunde;
public StundePage() public StundePage()
{ {
//GetDayTime();
InitializeComponent(); InitializeComponent();
}
private async void GetDayTime() {
_stunde = await Models.Stunde.LoadEntry(4096);
//_stunde = new DayTime();
//_stunde.description = "asd";
//StundeDescription.Text = _stunde.description;
}
private void GetDayTime(object sender, EventArgs e) {
GetDayTime();
} }
} }

View File

@@ -10,14 +10,12 @@
</ContentPage.BindingContext> </ContentPage.BindingContext>
<ContentPage.ToolbarItems> <ContentPage.ToolbarItems>
<ToolbarItem Text="Add" Command="{Binding NewCommand}" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" /> <ToolbarItem Text="Add" Command="{Binding NewEntryCommand}" IconImageSource="{FontImage Glyph='+', Color=Black, Size=22}" />
</ContentPage.ToolbarItems> </ContentPage.ToolbarItems>
<ScrollView Margin="5">
<VerticalStackLayout Spacing="10" Margin="10"> <VerticalStackLayout Spacing="10" Margin="10">
<Grid RowDefinitions="Auto" ColumnDefinitions="Auto,*"> <Grid RowDefinitions="Auto" ColumnDefinitions="Auto,*">
<DatePicker Grid.Column="0" MinimumDate="{Binding MinimumDate}" <DatePicker Grid.Column="0" MinimumDate="{Binding MinimumDate}"
MaximumDate="{Binding MaximumDate}" MaximumDate="{Binding MaximumDate}"
@@ -27,10 +25,10 @@
</Border> </Border>
</Grid> </Grid>
<CollectionView <CollectionView
ItemsSource="{Binding DayTimes}" ItemsSource="{Binding DayTimes}"
x:Name="stundeItems" Margin="0" x:Name="stundeItems" Margin="0"
HeightRequest="350"
SelectionMode="Single" SelectionMode="Single"
SelectionChangedCommand="{Binding SelectEntryCommand}" SelectionChangedCommand="{Binding SelectEntryCommand}"
SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}"> SelectionChangedCommandParameter="{Binding Source={RelativeSource Self}, Path=SelectedItem}">
@@ -41,7 +39,7 @@
<CollectionView.ItemTemplate> <CollectionView.ItemTemplate>
<DataTemplate> <DataTemplate>
<Grid Padding="15,10,0,0"> <Grid Padding="5,10,5,0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@@ -115,5 +113,5 @@
</VerticalStackLayout> </VerticalStackLayout>
</ScrollView>
</ContentPage> </ContentPage>