diff --git a/LivreLand/View/ScanView.xaml b/LivreLand/View/ScanView.xaml
index e5519f1..74b9328 100644
--- a/LivreLand/View/ScanView.xaml
+++ b/LivreLand/View/ScanView.xaml
@@ -40,10 +40,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LivreLand/View/ScanView.xaml.cs b/LivreLand/View/ScanView.xaml.cs
index fd22222..ab2b96f 100644
--- a/LivreLand/View/ScanView.xaml.cs
+++ b/LivreLand/View/ScanView.xaml.cs
@@ -16,7 +16,7 @@ public partial class ScanView : ContentPage
{
ScanVM = scanVM;
InitializeComponent();
- ScanVM.CameraView = cameraView;
+ ScanVM.CameraView = cameraView; //ToRemove
BindingContext = this;
}
diff --git a/LivreLand/View/TousView.xaml b/LivreLand/View/TousView.xaml
index 2675a3e..f5e59e5 100644
--- a/LivreLand/View/TousView.xaml
+++ b/LivreLand/View/TousView.xaml
@@ -155,7 +155,11 @@
+ Grid.Column="1">
+
+
+
+
+ Grid.Column="5">
+
+
+
+
diff --git a/LivreLand/ViewModel/ScanVM.cs b/LivreLand/ViewModel/ScanVM.cs
index e2b0ebe..4724afd 100644
--- a/LivreLand/ViewModel/ScanVM.cs
+++ b/LivreLand/ViewModel/ScanVM.cs
@@ -1,4 +1,5 @@
using Camera.MAUI;
+using CommunityToolkit.Maui.Alerts;
using PersonalMVVMToolkit;
using System;
using System.Collections.Generic;
@@ -19,9 +20,9 @@ namespace LivreLand.ViewModel
private CameraView cameraView;
private CameraInfo camera = null;
private ObservableCollection cameras = new();
- private int camerasCount;
private Result[] result;
private string barcodeText = "ISBN";
+ private bool addIsVisible = false;
#endregion
@@ -68,7 +69,7 @@ namespace LivreLand.ViewModel
public int CamerasCount
{
- get => camerasCount = Cameras.Count();
+ get => Cameras.Count();
set
{
if (value > 0)
@@ -104,9 +105,18 @@ namespace LivreLand.ViewModel
}
}
- public bool AutoStartPreview { get; set; } = false;
-
- public bool AutoStartRecording { get; set; } = false;
+ public bool AddIsVisible
+ {
+ get => addIsVisible;
+ set
+ {
+ if (addIsVisible != value)
+ {
+ addIsVisible = value;
+ OnPropertyChanged(nameof(AddIsVisible));
+ }
+ }
+ }
public NavigatorVM Navigator { get; private set; }
@@ -116,6 +126,8 @@ namespace LivreLand.ViewModel
public ICommand BarcodeDetectCommand { get; private set; }
+ public ICommand AddBookISBNDetectedCommand { get; private set; }
+
#endregion
#region Constructor
@@ -126,6 +138,7 @@ namespace LivreLand.ViewModel
Manager = managerVM;
CamerasLoadCommand = new RelayCommand(() => CamerasLoad());
BarcodeDetectCommand = new RelayCommand(() => BarcodeDetect());
+ AddBookISBNDetectedCommand = new RelayCommand((isbn) => AddBookISBNDetected(isbn));
}
#endregion
@@ -146,13 +159,25 @@ namespace LivreLand.ViewModel
}
private async Task BarcodeDetect()
- {
+ {
MainThread.BeginInvokeOnMainThread(() =>
{
BarcodeText = BarCodeResult[0].Text;
+ AddIsVisible = true;
});
}
+ private async Task AddBookISBNDetected(string isbn)
+ {
+ Manager.AddBookCommand.Execute(isbn);
+
+ var toast = Toast.Make("Livre ajouté !", CommunityToolkit.Maui.Core.ToastDuration.Short);
+ await toast.Show();
+
+ Manager.GetBooksFromCollectionCommand.Execute(null);
+ Navigator.NavigationCommand.Execute("/tous");
+ }
+
#endregion
}
}