Пример #1
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);
                    }
                });
            };
        }
Пример #2
0
        private void LoadBarcode()
        {
            var data = new BarcodePackageData
            {
                EscrowAddress = ViewModel.PaketId
            };

            BarcodeImage.BarcodeOptions.Width  = 300;
            BarcodeImage.BarcodeOptions.Height = 300;
            BarcodeImage.BarcodeOptions.Margin = 1;
            BarcodeImage.BarcodeValue          = JsonConvert.SerializeObject(data);
        }
Пример #3
0
        public NewPackageDetailPage(Package package, bool canAcceptPackage = false, BarcodePackageData barcodePackageData = null)
        {
            InitializeComponent();

            LocationArrow.Source = "right_arrow.png";
            InfoArrow.Source     = "right_arrow.png";
            UsersArrow.Source    = "right_arrow.png";
            EventsArrow.Source   = "right_arrow.png";


            BarcodeData = barcodePackageData;

            CanAcceptPackage = canAcceptPackage;

            if (package.CourierPubkey == null && package.MyRole == PaketRole.Courier && CanAcceptPackage == false)
            {
                CanAssignPackage = true;
            }

#if __IOS__
            if (App.Locator.DeviceService.IsIphoneX() == true)
            {
                TitleLabel.TranslationY = 35;
                BackButton.TranslationY = 10;
            }
            else
            {
                TitleLabel.TranslationY = 24;
            }
#elif __ANDROID__
            TitleLabel.TranslationY = 5;
            BackButton.TranslationY = -18;
            BackButton.TranslationX = -30;
#endif

            InfoPacketView.WidthRequest = App.Locator.DeviceService.ScreenWidth();

            BindingContext = package;

            AddCommands();
            LoadPhoto();
            LoadBarcode();
            CheckVisiblePayments();
            //  AddEvents();

            MessagingCenter.Subscribe <PackagesModel, Package>(this, Constants.DISPLAY_PACKAGE_CHANGED, (sender, arg) =>
            {
                var _package    = BindingContext as Package;
                _package.Status = arg.Status;

                RefreshDetails();
            });

            if (CanAssignPackage)
            {
                AssignLabel.IsVisible  = true;
                AssignButton.IsVisible = true;
                EmptyBox.IsVisible     = true;
            }
            else if (CanAcceptPackage)
            {
                EmptyBox.IsVisible     = true;
                AcceptButton.IsVisible = true;
            }
        }