Beautifiing Login Process

This commit is contained in:
2024-08-21 20:18:04 +02:00
parent 13db083891
commit 23ea92baf6
3 changed files with 15 additions and 17 deletions

View File

@@ -5,11 +5,13 @@ using Microsoft.Maui.Dispatching;
namespace Jugenddienst_Stunden.ViewModels {
internal class AboutViewModel {
public string Title => AppInfo.Name;
public string AppTitle => AppInfo.Name;
public string Version => AppInfo.VersionString;
public string Message => "Scanne den QR-Code von deinem Benutzerprofil auf der Stundenseite.";
public string Title { get; set; } = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");

View File

@@ -3,31 +3,27 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"
x:Class="Jugenddienst_Stunden.Views.AboutPage">
x:Class="Jugenddienst_Stunden.Views.AboutPage"
Title="{Binding Title}">
<ContentPage.BindingContext>
<models:AboutViewModel />
</ContentPage.BindingContext>
<VerticalStackLayout Spacing="10" Margin="10">
<VerticalStackLayout Spacing="10" Margin="15">
<HorizontalStackLayout Spacing="10">
<Image Source="dotnet_bot.png"
SemanticProperties.Description="The dot net bot waving hello!"
HeightRequest="64" />
<Label FontSize="22" FontAttributes="Bold" Text="{Binding Title}" VerticalOptions="End" />
<Label FontSize="22" FontAttributes="Bold" Text="{Binding AppTitle}" VerticalOptions="End" />
<Label FontSize="22" Text="{Binding Version}" VerticalOptions="End" />
</HorizontalStackLayout>
<Label Text="{Binding Message}" />
<Label Text="{Binding Message}" HeightRequest="110" />
<zxing:CameraBarcodeReaderView x:Name="barcodeScannerView"
BarcodesDetected="BarcodesDetected"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
Margin="0,60,0,0"/>
VerticalOptions="FillAndExpand"/>
</VerticalStackLayout>

View File

@@ -27,7 +27,7 @@ public partial class AboutPage : ContentPage {
_lastDetectionTime = currentTime;
foreach (var barcode in e.Results) {
if (Preferences.Default.Get("apiKey", "") != barcode.Value) {
MainThread.InvokeOnMainThreadAsync(async() => {
MainThread.InvokeOnMainThreadAsync(async () => {
//DisplayAlert("Barcode erkannt", $"Barcode: {barcode.Format} - {barcode.Value}", "OK");
Preferences.Default.Set("apiKey", barcode.Value);
@@ -36,13 +36,13 @@ public partial class AboutPage : ContentPage {
var op = await Models.Operator.LoadData(barcode.Value);
Preferences.Default.Set("name", op.name);
Preferences.Default.Set("surname", op.surname);
DisplayAlert("Neuer Barcode erkannt", op.name + " " + op.surname, "OK");
DisplayAlert("Login erfolgreich", op.name + " " + op.surname, "OK");
Title = op.name + " " + op.surname;
});
} else {
MainThread.InvokeOnMainThreadAsync(() => {
DisplayAlert("Barcode bereits vorhanden",
DisplayAlert("Bereits eingeloggt",
Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", ""),
"OK");
});