Bessere Trennung manueller / automatischer Login
Umstellung auf Sekunden wegen aktualisierter Hauptanwendung
Umstellung auf Toasts bei Informationsmeldungen
Abstände und Sichtbarkeiten vereinheitlicht
Upgrade auf .NET9
This commit is contained in:
2025-02-15 22:59:06 +01:00
parent 65d5dc94df
commit 4449b4ad0e
18 changed files with 268 additions and 121 deletions

View File

@@ -52,13 +52,9 @@
<VerticalStackLayout x:Name="LoginManual" Spacing="15">
<Label Text="Manueller Login" FontSize="32" HorizontalOptions="Start" />
<Entry x:Name="UsernameEntry" Placeholder="Benutzername" Keyboard="Email" />
<Entry x:Name="PasswordEntry" Placeholder="Passwort" IsPassword="True" />
<Entry x:Name="ServerEntry" Placeholder="Server" Keyboard="Url" />
<Button Text="Login" Clicked="OnLoginButtonClicked" />
</VerticalStackLayout>
</VerticalStackLayout>

View File

@@ -79,8 +79,13 @@ public partial class LoginPage : ContentPage {
await DisplayAlert("Login erfolgreich", user.Name + " " + user.Surname, "OK");
if (Navigation.NavigationStack.Count > 1)
if (Navigation.NavigationStack.Count > 1) {
//Beim ersten Start ohne Login, wird man automatisch auf die Loginseite geleitet. Danach in der History zur<75>ck
await Navigation.PopAsync();
} else {
//Beim manuellen Wechsel auf die Loginseite leiten wir nach erfolgreichem Login auf die Stunden<65>bersicht
await Shell.Current.GoToAsync($"//StundenPage");
}
} catch (Exception e) {
await DisplayAlert("Fehler", e.Message, "OK");
@@ -126,30 +131,50 @@ public partial class LoginPage : ContentPage {
var password = PasswordEntry.Text;
var server = ServerEntry.Text;
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(server)) {
await DisplayAlert("Fehler", "Bitte alle Felder ausf<73>llen", "OK");
return;
}
try {
Types.User response = await BaseFunc.AuthUserPass(username, password, server);
Uri uri = new Uri(InputUrlWithSchema(server));
Types.User response = await BaseFunc.AuthUserPass(username, password, uri.Scheme + "://" + uri.Authority + "/appapi");
GlobalVar.ApiKey = response.Token;
GlobalVar.Name = response.Name;
GlobalVar.Surname = response.Surname;
GlobalVar.EmployeeId = response.Id;
GlobalVar.ApiUrl = server;
GlobalVar.ApiUrl = uri.Scheme + "://" + uri.Authority + "/appapi";
Title = response.Name + " " + response.Surname;
ServerLabel.Text = "Server: " + server.Replace("/appapi", "").Replace("https://", "").Replace("http://", "");
//ServerLabel.Text = "Server: " + server.Replace("/appapi", "").Replace("https://", "").Replace("http://", "");
ServerLabel.Text = "Server: " + uri.Authority;
await DisplayAlert("Login erfolgreich", response.Name + " " + response.Surname, "OK");
if (Navigation.NavigationStack.Count > 1)
await Navigation.PopAsync();
else {
await Shell.Current.GoToAsync($"//StundenPage");
}
} catch (Exception ex) {
await DisplayAlert("Fehler", ex.Message, "OK");
}
}
/// <summary>
/// Aus einer URL ohne Schema eine URL mit Schema machen
/// </summary>
private static string InputUrlWithSchema(string url) {
if (!url.StartsWith("http://") && !url.StartsWith("https://")) {
url = "https://" + url;
}
if (url.StartsWith("http://")) {
url = url.Replace("http://", "https://");
}
return url;
}
//Zwischen manuellem und automatischem Login (mit QR-Code) umschalten und die Schalterstellung merken
private void Switch_Toggled(object sender, ToggledEventArgs e) {
var switcher = (Switch)sender;

View File

@@ -19,36 +19,53 @@
<VerticalStackLayout Spacing="10" Margin="10">
<Label Text="{Binding SubTitle}" FontSize="Medium" FontAttributes="Bold" Margin="4,0,0,0" />
<Label Text="{Binding SubTitle}" FontSize="Medium" Margin="4,0,0,0" />
<Border>
<Border.Padding>
<OnPlatform x:TypeArguments="Thickness" Default="0,15,10,0">
<On Platform="Android" Value="0,4,10,8"/>
<On Platform="WPF" Value="0,15,10,0"/>
</OnPlatform>
</Border.Padding>
<Frame Padding="5,2,5,10">
<FlexLayout Direction="Row" AlignItems="Start" Wrap="Wrap" JustifyContent="SpaceBetween">
<HorizontalStackLayout>
<Label Text="Beginn" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Padding="0,0,10,0" Margin="5,0,0,0" MinimumWidthRequest="60"></Label>
<TimePicker x:Name="TimeBegin" HorizontalOptions="Center" Format="HH:mm" MinimumWidthRequest="80" Time="{Binding DayTime.TimeSpanVon}" Margin="0,0,0,-5" />
<HorizontalStackLayout Spacing="10">
<Label Text="Beginn" VerticalTextAlignment="Center" HorizontalTextAlignment="End" MinimumWidthRequest="60"></Label>
<TimePicker x:Name="TimeBegin" HorizontalOptions="Center" Format="HH:mm" MinimumWidthRequest="80" Time="{Binding DayTime.TimeSpanVon}" />
</HorizontalStackLayout>
<HorizontalStackLayout>
<Label Text="Ende" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Padding="0,0,10,0" Margin="5,0,0,0" MinimumWidthRequest="60"></Label>
<TimePicker x:Name="TimeEnd" Format="HH:mm" MinimumWidthRequest="80" Time="{Binding DayTime.TimeSpanBis}" Margin="0,0,0,-5" />
<HorizontalStackLayout Spacing="10">
<Label Text="Ende" VerticalTextAlignment="Center" HorizontalTextAlignment="End" MinimumWidthRequest="60"></Label>
<TimePicker x:Name="TimeEnd" Format="HH:mm" MinimumWidthRequest="80" Time="{Binding DayTime.TimeSpanBis}" />
</HorizontalStackLayout>
</FlexLayout>
</Frame>
</Border>
<Frame Padding="5,4,5,8">
<Grid ColumnDefinitions="*,*,*">
<Border>
<Border.Padding>
<OnPlatform x:TypeArguments="Thickness" Default="5">
<On Platform="Android" Value="5,4,5,8"/>
<On Platform="WPF" Value="5"/>
</OnPlatform>
</Border.Padding>
<!--<Grid ColumnDefinitions="*,*,*">
<Picker x:Name="pick_gemeinde" Title="Gemeinde" ItemsSource="{Binding OptionsGemeinde}" SelectedItem="{Binding DayTime.GemeindeAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="0" IsVisible="{Binding GemeindeAktivSet}">
</Picker>
<Picker x:Name="pick_projekt" Title="Projekt" ItemsSource="{Binding OptionsProjekt}" SelectedItem="{Binding DayTime.ProjektAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="1" IsVisible="{Binding ProjektAktivSet}">
</Picker>
<Picker x:Name="pick_freistellung" Title="Freistellung" ItemsSource="{Binding OptionsFreistellung}" SelectedItem="{Binding DayTime.FreistellungAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" Grid.Column="2" IsEnabled="{Binding FreistellungEnabled}">
</Picker>
</Grid>
</Frame>
</Grid>-->
<HorizontalStackLayout>
<Picker x:Name="pick_gemeinde" Title="Gemeinde" ItemsSource="{Binding OptionsGemeinde}" SelectedItem="{Binding DayTime.GemeindeAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" IsVisible="{Binding GemeindeAktivSet}">
</Picker>
<Picker x:Name="pick_projekt" Title="Projekt" ItemsSource="{Binding OptionsProjekt}" SelectedItem="{Binding DayTime.ProjektAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" IsVisible="{Binding ProjektAktivSet}">
</Picker>
<Picker x:Name="pick_freistellung" Title="Freistellung" ItemsSource="{Binding OptionsFreistellung}" SelectedItem="{Binding DayTime.FreistellungAktiv, Mode=TwoWay}" ItemDisplayBinding="{Binding Name}" IsEnabled="{Binding FreistellungEnabled}">
</Picker>
</HorizontalStackLayout>
</Border>
<Editor Placeholder="Beschreibung" Text="{Binding DayTime.Description}" MinimumHeightRequest="40" AutoSize="TextChanges" FontSize="18" />
@@ -66,9 +83,8 @@
<Label>
<Label.FormattedText>
<FormattedString>
<Span Text="Am " />
<Span Text="Vorhandene Einträge: " />
<Span Text="{Binding SubTitle}" />
<Span Text=" vorhandene Einträge:"/>
</FormattedString>
</Label.FormattedText>
</Label>

View File

@@ -1,32 +1,54 @@
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
using Jugenddienst_Stunden.Models;
using Jugenddienst_Stunden.ViewModels;
using System.Windows.Input;
namespace Jugenddienst_Stunden.Views;
/// <summary>
/// Einzelner Stundeneintrag
/// </summary>
public partial class StundePage : ContentPage {
/// <summary>
/// CTOR
/// </summary>
public StundePage() {
InitializeComponent();
if (BindingContext is StundeViewModel vm) {
vm.AlertEvent += Vm_AlertEvent;
//vm.InfoEvent += Vm_InfoEvent;
vm.ConfirmEvent += ShowConfirm;
}
}
/// <summary>
/// CTOR
/// </summary>
public StundePage() {
InitializeComponent();
if (BindingContext is StundeViewModel vm) {
vm.AlertEvent += Vm_AlertEvent;
vm.InfoEvent += Vm_InfoEvent;
vm.ConfirmEvent += ShowConfirm;
}
}
private void Vm_AlertEvent(object? sender, string e) {
DisplayAlert("Fehler:", e, "OK");
}
DisplayAlert("Fehler:", e, "OK");
}
private async Task<bool> ShowConfirm(string title, string message) {
return await DisplayAlert(title, message, "Passt!", "Na, nor decht nit.");
}
private async Task<bool> ShowConfirm(string title, string message) {
return await DisplayAlert(title, message, "Passt!", "Na, nor decht nit.");
}
private void Vm_InfoEvent(object? sender, string e) {
MainThread.BeginInvokeOnMainThread(async () => {
CancellationTokenSource cts = new CancellationTokenSource();
ToastDuration duration = ToastDuration.Short;
double fontSize = 20;
var toast = Toast.Make(e, duration, fontSize);
await toast.Show(cts.Token);
});
}
//private async Task<bool> ShowConfirm(string title, string message, string ok, string not_ok) {
// return await DisplayAlert(title, message, ok, not_ok);
//}
//private async void ShowConfirm(object? sender, ConfirmEventArgs e) {
// bool result = await DisplayAlert(e.Title, e.Message, e.Ok, e.NotOk);
// e.Result = result;
//}
}

View File

@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
xmlns:mmodels="clr-namespace:Jugenddienst_Stunden.Models"
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
xmlns:conv="clr-namespace:Jugenddienst_Stunden.Converter"
x:Class="Jugenddienst_Stunden.Views.StundenPage"
Title="{Binding Title}">
@@ -11,12 +12,16 @@
</ContentPage.BindingContext>
<ContentPage.Resources>
<FontImageSource x:Key="ToolbarIcon"
<ResourceDictionary>
<conv:SecondsTimeConverter x:Key="secToTime" />
<FontImageSource x:Key="ToolbarIcon"
Glyph="+"
Size="22"
Color="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.ToolbarItems>
<!--<ToolbarItem Text="Lade Liste" Command="{Binding RefreshListCommand}"/>-->
<ToolbarItem Text="Neuer Eintrag" IconImageSource="{StaticResource ToolbarIcon}" Command="{Binding NewEntryCommand}" />
@@ -93,9 +98,9 @@
<Setter Property="Padding" Value="4"/>
</DataTrigger>
</HorizontalStackLayout.Triggers>
<Label Text="{Binding GemeindeAktiv.Name}" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.GemeindeAktivSet}" />
<Label Text="{Binding ProjektAktiv.Name}" Margin="10,0,0,0" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ProjektAktivSet}" />
<Label Text="{Binding FreistellungAktiv.Name}" Margin="10,0,0,0" />
<Label Text="{Binding GemeindeAktiv.Name}" Margin="0,0,10,0" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.GemeindeAktivSet}" />
<Label Text="{Binding ProjektAktiv.Name}" Margin="0,0,10,0" IsVisible="{Binding Source={RelativeSource AncestorType={x:Type ContentPage}}, Path=BindingContext.ProjektAktivSet}" />
<Label Text="{Binding FreistellungAktiv.Name}" IsVisible="{Binding Approved}" />
</HorizontalStackLayout>
<Label Text="{Binding Description}" Padding="0,0,0,15"/>
@@ -108,7 +113,7 @@
<BoxView HeightRequest="1" />
<Button Text="{Binding LoadOverview}" Command="{Binding LoadDataCommand}" />
<Frame Padding="2" HeightRequest="125">
<Border Padding="2" HeightRequest="125">
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto,*" ColumnDefinitions="Auto,*" Margin="10,2">
<Label Grid.Row="0" Text="Soll:" />
<Label Grid.Row="1" Text="Summe:" />
@@ -117,13 +122,13 @@
<Label Grid.Row="4" Text="Restüberstunden:" />
<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="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="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="0" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Nominal, Converter={StaticResource secToTime}}" ToolTipProperties.Text="Sollstunden" />
<Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitCalculated, Converter={StaticResource secToTime}}" ToolTipProperties.Text="Geleistete Stunden" />
<Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding OvertimeMonth, Converter={StaticResource secToTime}}" />
<Label Grid.Row="4" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Overtime, Converter={StaticResource secToTime}}" />
<Label Grid.Row="5" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Holiday, Converter={StaticResource secToTime}}" />
</Grid>
</Frame>
</Border>
</VerticalStackLayout>

View File

@@ -1,5 +1,7 @@
using Jugenddienst_Stunden.ViewModels;
using Jugenddienst_Stunden.Models;
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Alerts;
namespace Jugenddienst_Stunden.Views;
@@ -41,9 +43,21 @@ public partial class StundenPage : ContentPage {
await DisplayAlert("Fehler:", e, "OK");
});
}
//private void Vm_InfoEvent(object? sender, string e) {
// DisplayAlert("Information:", e, "OK");
//}
//private void Vm_InfoEvent(object? sender, string e) {
// MainThread.BeginInvokeOnMainThread(async () => {
// await DisplayAlert("Information:", e, "OK");
// });
//}
private void Vm_InfoEvent(object? sender, string e) {
MainThread.BeginInvokeOnMainThread(async () => {
await DisplayAlert("Information:", e, "OK");
CancellationTokenSource cts = new CancellationTokenSource();
ToastDuration duration = ToastDuration.Short;
double fontSize = 20;
var toast = Toast.Make(e, duration, fontSize);
await toast.Show(cts.Token);
});
}