예제 #1
0
        private async void ToolbarItemClicked_ScannerCode(object sender, EventArgs e)
        {
            _scanPage = new ZXingScannerPage();
            _scanPage.OnScanResult += (result) =>
            {
                _scanPage.IsScanning = false;

                // Do something with result
                Device.BeginInvokeOnMainThread(async() =>
                {
                    await Navigation.PopModalAsync();
                    bool productExist = await _dataHelper.IsProductExist(result.Text);
                    if (productExist)
                    {
                        await Navigation.PushModalAsync(new ProductDetailView(result.Text));
                    }
                    else
                    {
                        bool answer = await DisplayAlert("Produit non reconnu", "Voulez vous ajouter ce produit à notre base ?", "Oui", "Non");
                        if (answer)
                        {
                            await Navigation.PushModalAsync(new ProductAddView());
                        }
                    }
                });
            };

            await Navigation.PushModalAsync(_scanPage);
        }