forked from ElixorTeam/Palleto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScanPage.xaml.cs
43 lines (35 loc) · 1.02 KB
/
ScanPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using BarcodeScanning;
namespace Pl.Mobile.Client;
public partial class ScanPage : ContentPage
{
public event EventHandler<string>? ScanCompleted;
public ScanPage()
{
InitializeComponent();
}
protected override async void OnAppearing()
{
await Methods.AskForRequiredPermissionAsync();
base.OnAppearing();
Barcode.CameraEnabled = true;
}
protected override void OnDisappearing()
{
base.OnDisappearing();
Barcode.CameraEnabled = false;
}
private void ContentPage_Unloaded(object sender, EventArgs e)
{
Barcode.Handler?.DisconnectHandler();
}
private async void OnBackButtonClicked(object sender, EventArgs e)
{
await Navigation.PopModalAsync();
}
private void CameraView_OnDetectionFinished(object sender, OnDetectionFinishedEventArg e)
{
if (e.BarcodeResults.Count == 0) return;
ScanCompleted?.Invoke(this, e.BarcodeResults.First().DisplayValue);
Navigation.PopModalAsync();
}
}