ADD : Avancement ScanView (ToFinish)

scan-20-10
Lou BRODA 2 years ago
parent 37cd46dee8
commit 68371c878f

@ -40,10 +40,25 @@
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
<Label Text="Annuler"
TextColor="{StaticResource Blue100Accent}"
Grid.Column="0"/>
<Grid Grid.Column="0">
<Label Text="Annuler"
TextColor="{StaticResource Blue100Accent}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ScanVM.Navigator.PopupBackButtonNavigationCommand}"/>
</Grid.GestureRecognizers>
</Grid>
<Grid IsVisible="{Binding ScanVM.AddIsVisible}"
Grid.Column="2">
<Label Text="Ajouter le livre !"
TextColor="{StaticResource Blue100Accent}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer Command="{Binding ScanVM.AddBookISBNDetectedCommand}"
CommandParameter="{Binding ScanVM.BarcodeText}"/>
</Grid.GestureRecognizers>
</Grid>
<Label Text="{Binding ScanVM.BarcodeText}"
TextColor="{StaticResource Blue100Accent}"
Grid.Column="4"/>

@ -16,7 +16,7 @@ public partial class ScanView : ContentPage
{
ScanVM = scanVM;
InitializeComponent();
ScanVM.CameraView = cameraView;
ScanVM.CameraView = cameraView; //ToRemove
BindingContext = this;
}

@ -155,7 +155,11 @@
<ImageButton Source="chevron_right.png"
Rotation="180"
Command="{Binding TousVM.Manager.PreviousCommand}"
Grid.Column="1"/>
Grid.Column="1">
<ImageButton.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"/>
</ImageButton.Behaviors>
</ImageButton>
<Label Style="{StaticResource MasterTitleBookText}"
VerticalOptions="FillAndExpand"
Grid.Column="3">
@ -169,7 +173,11 @@
</Label>
<ImageButton Source="chevron_right.png"
Command="{Binding TousVM.Manager.NextCommand}"
Grid.Column="5"/>
Grid.Column="5">
<ImageButton.Behaviors>
<toolkit:IconTintColorBehavior TintColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}"/>
</ImageButton.Behaviors>
</ImageButton>
</Grid>
</Grid>
</ScrollView>

@ -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<CameraInfo> 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<string>((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
}
}

Loading…
Cancel
Save