コード例 #1
0
ファイル: WalletPage.xaml.cs プロジェクト: paket-core/mobile
        protected async override void OnAppearing()
        {
            App.Locator.DeviceService.setStausBarLight();

            var fl = firstLoad;

            base.OnAppearing();

            App.Locator.DeviceService.IsNeedAlertDialogToClose = true;

            if (ShowPurchaseBuls)
            {
                TitleView.Padding      = new Thickness(50, 0, 0, 0);
                CancelButton.IsVisible = true;
            }

            if (fl)
            {
                await LoadWallet();

                if (ShowPurchaseBuls)
                {
                    ShowEntry(PurchaseBULEntryViews);

                    CancelButton.IsVisible  = true;
                    RefreshButton.IsVisible = false;

                    PickerBULCurrency.Focus();
                }
            }
        }
コード例 #2
0
ファイル: WalletPage.xaml.cs プロジェクト: paket-core/mobile
 private void FieldCompleted(object sender, EventArgs e)
 {
     if (sender == EntryRecepient)
     {
         if (!ValidationHelper.ValidateNumber(EntryAmount.Text))
         {
             EntryAmount.Focus();
         }
     }
     else if (sender == EntryAmount)
     {
         if (!ValidationHelper.ValidateTextField(EntryRecepient.Text))
         {
             EntryRecepient.FocusField();
         }
     }
     else if (sender == EntryAmountForBUL)
     {
         if (PickerBULCurrency.SelectedItem == null)
         {
             PickerBULCurrency.Focus();
         }
     }
     else if (sender == EntryAmountForXLM)
     {
         if (PickerXLMCurrency.SelectedItem == null)
         {
             PickerXLMCurrency.Focus();
         }
     }
 }
コード例 #3
0
ファイル: WalletPage.xaml.cs プロジェクト: paket-core/mobile
        private bool IsValid(SpendCurrency spendCurrency)
        {
            if (spendCurrency == SpendCurrency.BUL)
            {
                if (PickerBULCurrency.SelectedItem == null)
                {
                    EventHandler handleCurrencyHandler = (s, e) =>
                    { 
 PickerBULCurrency.Focus(); }; 

                    ShowErrorMessage(AppResources.PleaseSelectPaymentCurrency, false, handleCurrencyHandler);

                    return(false);
                }
                if (!ValidationHelper.ValidateNumber(EntryAmountForBUL.Text))
                {
                    EntryAmountForBUL.Focus();
                    return(false);
                }
            }
            else
            {
                if (PickerXLMCurrency.SelectedItem == null)
                {
                    EventHandler handleCurrencyHandler = (s, e) =>
                    {
                        PickerXLMCurrency.Focus();
                    };

                    ShowErrorMessage(AppResources.PleaseSelectPaymentCurrency, false, handleCurrencyHandler);

                    return(false);
                }
                if (!ValidationHelper.ValidateNumber(EntryAmountForXLM.Text))
                {
                    EntryAmountForXLM.Focus();
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
ファイル: WalletPage.xaml.cs プロジェクト: paket-core/mobile
        private async void SendClicked(object sender, EventArgs e)
        {
            if (EntryRecepient.IsBusy)
            {
                return;
            }
            else if (recipient.Length == 0)
            {
                EntryRecepient.FocusField();
            }
            else if (IsValid())
            {
                Unfocus();

                App.ShowLoading(true);

                try
                {
                    double amount = double.Parse(EntryAmount.Text);

                    var trans = await App.Locator.BridgeServiceClient.PrepareSendBuls(App.Locator.Profile.Pubkey, recipient, amount);

                    if (trans != null)
                    {
                        var signed = await StellarHelper.SignTransaction(App.Locator.Profile.KeyPair, trans.Transaction);

                        var result = await App.Locator.BridgeServiceClient.SubmitTransaction(signed);

                        if (result != null)
                        {
                            await ViewModel.Load();

                            SundBULSMainStackView.IsVisible = false;
                            SendBULSSuccessView.IsVisible   = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    EventHandler handler = (se, ee) =>
                    {
                        if (ee != null)
                        {
                            ShowEntry(PurchaseBULEntryViews);

                            if (PickerBULCurrency.SelectedItem == null)
                            {
                                PickerBULCurrency.Focus();
                            }
                        }
                        else
                        {
                            EntryAmount.Focus();
                        }
                    };

                    if (ex.Message == AppResources.InsufficientBULs)
                    {
                        ShowErrorMessage(AppResources.PurchaseBULs, false, handler, AppResources.Purchase);
                    }
                    else
                    {
                        ShowErrorMessage(ex.Message, false, handler);
                    }
                }

                App.ShowLoading(false);

                EnableDisableButton();
            }
        }