Barcodes speichern
This commit is contained in:
@@ -19,17 +19,15 @@
|
||||
</HorizontalStackLayout>
|
||||
|
||||
<Label Text="{Binding Message}" />
|
||||
<Button Text="Learn more..." Command="{Binding ShowMoreInfoCommand}" />
|
||||
|
||||
|
||||
<!--<scanner:CameraView x:Name="barcodeScannerView"
|
||||
OnDetectionFinished="BarcodesDetected"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand" />-->
|
||||
|
||||
|
||||
<zxing:CameraBarcodeReaderView x:Name="barcodeScannerView"
|
||||
BarcodesDetected="BarcodesDetected"
|
||||
HorizontalOptions="FillAndExpand"
|
||||
VerticalOptions="FillAndExpand" />
|
||||
VerticalOptions="FillAndExpand"
|
||||
Margin="0,60,0,0"/>
|
||||
</VerticalStackLayout>
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Jugenddienst_Stunden.Models;
|
||||
using Microsoft.Maui.Controls;
|
||||
using System.Collections.Generic;
|
||||
using ZXing.Net.Maui;
|
||||
@@ -21,15 +22,31 @@ public partial class AboutPage : ContentPage {
|
||||
|
||||
private void BarcodesDetected(object sender, ZXing.Net.Maui.BarcodeDetectionEventArgs e) {
|
||||
//var first = e.Results?.FirstOrDefault();
|
||||
|
||||
var currentTime = DateTime.Now;
|
||||
if ((currentTime - _lastDetectionTime) > _detectionInterval) {
|
||||
_lastDetectionTime = currentTime;
|
||||
foreach (var barcode in e.Results) {
|
||||
MainThread.InvokeOnMainThreadAsync(() => {
|
||||
DisplayAlert("Barcode erkannt", $"Barcode: {barcode.Format} - {barcode.Value}", "OK");
|
||||
Models.Stunde.apiKey = barcode.Value;
|
||||
});
|
||||
if (Preferences.Default.Get("apiKey", "") != barcode.Value) {
|
||||
MainThread.InvokeOnMainThreadAsync(async() => {
|
||||
//DisplayAlert("Barcode erkannt", $"Barcode: {barcode.Format} - {barcode.Value}", "OK");
|
||||
Preferences.Default.Set("apiKey", barcode.Value);
|
||||
|
||||
Models.Stunde.apiKey = barcode.Value;
|
||||
|
||||
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");
|
||||
|
||||
|
||||
});
|
||||
} else {
|
||||
MainThread.InvokeOnMainThreadAsync(() => {
|
||||
DisplayAlert("Barcode bereits vorhanden",
|
||||
Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", ""),
|
||||
"OK");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,12 +67,12 @@ public partial class AboutPage : ContentPage {
|
||||
base.OnDisappearing();
|
||||
barcodeScannerView.CameraLocation = CameraLocation.Front;
|
||||
barcodeScannerView.IsDetecting = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override void OnAppearing() {
|
||||
base.OnAppearing();
|
||||
|
||||
|
||||
barcodeScannerView.IsDetecting = true;
|
||||
barcodeScannerView.CameraLocation = CameraLocation.Rear;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:models="clr-namespace:Jugenddienst_Stunden.ViewModels"
|
||||
x:Class="Jugenddienst_Stunden.Views.StundenPage"
|
||||
Title="StundenPage">
|
||||
Title="{Binding Title}">
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<models:StundenViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<VerticalStackLayout Spacing="10" Margin="15">
|
||||
<Label Text="{Binding Message}" />
|
||||
|
||||
@@ -18,13 +20,13 @@
|
||||
<Label Text="Berechnet:" Grid.Row="2" />
|
||||
<Label Text="Überstunden Monat:" Grid.Row="3" Margin="0,0,15,0" />
|
||||
<Label Text="Überstunden Jahr:" Grid.Row="4" />
|
||||
|
||||
|
||||
<Label BackgroundColor="AliceBlue" Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Nominal}" />
|
||||
<Label BackgroundColor="AliceBlue" Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitDone}" />
|
||||
<Label BackgroundColor="AliceBlue" Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitCalculated}" />
|
||||
<Label BackgroundColor="AliceBlue" Grid.Row="3" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding OvertimeMonth}" />
|
||||
<Label BackgroundColor="AliceBlue" Grid.Row="4" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Overtime}" />
|
||||
|
||||
|
||||
<Label Grid.Row="0" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding Nominal}" />
|
||||
<Label Grid.Row="1" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitDone}" />
|
||||
<Label Grid.Row="2" Grid.Column="1" HorizontalTextAlignment="End" Padding="0,0,5,0" Text="{Binding ZeitCalculated}" />
|
||||
<Label Grid.Row="3" 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}" />
|
||||
</Grid>
|
||||
</VerticalStackLayout>
|
||||
</ContentPage>
|
||||
@@ -1,9 +1,12 @@
|
||||
namespace Jugenddienst_Stunden.Views;
|
||||
|
||||
public partial class StundenPage : ContentPage
|
||||
{
|
||||
public StundenPage()
|
||||
{
|
||||
public partial class StundenPage : ContentPage {
|
||||
public StundenPage() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnAppearing() {
|
||||
base.OnAppearing();
|
||||
Title = Preferences.Default.Get("name", "") + " " + Preferences.Default.Get("surname", "");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user