Last active
September 5, 2017 23:12
-
-
Save brunoportess/37195a85594b19a6d0332cfa5852d5de to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" | |
xmlns:forms="clr-namespace:ZXing.Net.Mobile.Forms;assembly=ZXing.Net.Mobile.Forms" | |
x:Class="QrCodeSample.Views.VerificaQrCode"> | |
<Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> | |
<forms:ZXingScannerView IsScanning="{Binding IsScanning}" IsAnalyzing="{Binding IsAnalyzing}" Result="{Binding Result, Mode=TwoWay}" ScanResultCommand="{Binding QRScanResultCommand}"></forms:ZXingScannerView> | |
<forms:ZXingDefaultOverlay TopText="QCLUB - Leitor QrCode" BottomText="Passe o leitor sobre o QrCode" ShowFlashButton="False" Opacity="0.9"></forms:ZXingDefaultOverlay> | |
</Grid> | |
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VerificaQrCodeViewModel : BaseViewModel | |
{ | |
public ZXing.Result Result { get; set; } | |
private INavigationService _navigationService; | |
private IPageDialogService _dialogService; | |
public DelegateCommand QRScanResultCommand { get; set; } | |
public VerificaQrCodeViewModel(INavigationService navigationService, IPageDialogService dialogService) | |
{ | |
_navigationService = navigationService; | |
_dialogService = dialogService; | |
QRScanResultCommand = new DelegateCommand(ExecuteQRScanResultCommand); | |
} | |
private bool isAnalyzing = true; | |
public bool IsAnalyzing | |
{ | |
get => isAnalyzing; | |
set => SetProperty(ref isAnalyzing, value); | |
} | |
private bool isScanning = true; | |
public bool IsScanning | |
{ | |
get => isScanning; | |
set => SetProperty(ref isScanning, value); | |
} | |
public async void ExecuteQRScanResultCommand() | |
{ | |
//tem que chamar pela mainThread pra trocar de tela fechando o leitor | |
Device.BeginInvokeOnMainThread(async () => | |
{ | |
//do your job here - Result.Text contains QR CODE | |
//await _dialogService.DisplayAlertAsync("Scanned Barcode", Result.Text, "OK"); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usando o plugin ZXing com XAML e MVVM