Exemple #1
0
        private async void OpenPackageFromDeepLink(string packageid)
        {
            App.ShowLoading(true);

            var package = await PackageHelper.GetPackageDetails(packageid);

            if (package != null)
            {
                var packagePage = new NewPackageDetailPage(package);
                packagePage.ShouldDismiss = true;

                var mainPage = App.Current.MainPage;

                if (mainPage.Navigation.ModalStack.Count == 0)
                {
                    await mainPage.Navigation.PushModalAsync(packagePage, true);
                }
            }
            else
            {
                App.Locator.NotificationService.ShowMessage(AppResources.ErrorGetPackage, false);
            }

            App.ShowLoading(false);
        }
Exemple #2
0
        private void ConfigureScanner()
        {
            overlayBarcode.BindingContext = overlayBarcode;

            barcodeScaner.Options.UseFrontCameraIfAvailable = false;

            barcodeScaner?.AutoFocus();

            barcodeScaner.OnScanResult += (result) => {
                Device.BeginInvokeOnMainThread(async() => {
                    try {
                        data = JsonConvert.DeserializeObject <BarcodePackageData>(result.Text);
                    } catch (Exception ex) {
                        System.Diagnostics.Debug.WriteLine(ex);
                    }

                    if (data != null && data.EscrowAddress != null)
                    {
                        App.ShowLoading(true);

                        StopScanning();

                        var package = await App.Locator.RouteServiceClient.Package(data.EscrowAddress);
                        if (package != null && package.Package != null && package.Package.PaymentTransaction != null)
                        {
                            var myPubkey = App.Locator.Profile.Pubkey;
                            if (myPubkey == package.Package.RecipientPubkey)
                            {
                                //you are a recepient //Title = "Accept as a Recipient";
                                package.Package.MyRole = PaketRole.Recipient;
                            }
                            else
                            {
                                //you are a courier //Title = "Accept as a Courier";
                                package.Package.MyRole = PaketRole.Courier;
                            }

                            BindingContext = package.Package;

                            var packagePage = new NewPackageDetailPage(package.Package, true, data);
                            await Navigation.PushAsync(packagePage);
                        }
                        else
                        {
                            ShowMessage(AppResources.InvalidPackageId);
                            StartScanning();
                        }

                        App.ShowLoading(false);
                    }
                    else
                    {
                        ShowMessage(AppResources.InvalidBarcode);
                    }
                });
            };
        }
Exemple #3
0
        private async void PackageItemSelected(object sender, Xamarin.Forms.SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }

            PakagesView.SelectedItem = null;

            var pkgData = (Package)PakagesView.SelectedItem;

            if (pkgData.PaketId == null)
            {
                return;
            }

            App.ShowLoading(true);

            var package = await PackageHelper.GetPackageDetails(pkgData.PaketId);

            if (package != null)
            {
                ViewModel.CurrentDisplayPackageId = pkgData.PaketId;

                var packagePage = new NewPackageDetailPage(package);

                var mainPage = App.Current.MainPage;

                await mainPage.Navigation.PushAsync(packagePage);
            }
            else
            {
                ShowErrorMessage(AppResources.ErrorGetPackage);
            }

            App.ShowLoading(false);
        }