Exemplo n.º 1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            _viewModel.CopyToClipboardAsync(_viewModel.Payment.Address)
            .ContinueWith(_ => _msgDisplayer.ShowMessageAsync("Copiado endereço"),
                          TaskContinuationOptions.OnlyOnRanToCompletion);

            _viewModel.StartBackgroundJob();
        }
Exemplo n.º 2
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            await _viewModel.SaveSettingsAsync();

            // go back in the navigation stack
            await _navigationService.PopStackAsync();

            await _messageDisplayer.ShowMessageAsync("Configurações salvas!");
        }
Exemplo n.º 3
0
        public PaymentFinalizationPage(
            PaymentFinalizationPageViewModel viewModel
            , INavigationService navigationService
            , IMessageDisplayer msgDisplayer
            )
        {
            InitializeComponent();

            _navigationService = navigationService;
            _msgDisplayer      = msgDisplayer;

            BindingContext = _viewModel = viewModel;

            MessagingCenter.Subscribe <PaymentFinalizationPageViewModel, decimal>(
                _viewModel
                , MessengerKeys.PaymentFullyReceived
                , (_, value) =>
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    _viewModel.HandleCompletePayment(value);

                    await _msgDisplayer.ShowMessageAsync($"Pagamento efetuado!\nPago: {value:N8}");
                    await ExitPageAsync();
                });
            }
                );
            MessagingCenter.Subscribe <PaymentFinalizationPageViewModel, (decimal totalValue, decimal txValue)>(
                _viewModel
                , MessengerKeys.PaymentPartiallyReceived
                , (_, partialPayment) =>
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    _viewModel.HandlePartialValuePayment(partialPayment);

                    await _msgDisplayer.ShowMessageAsync(
                        $"Valor recebido: {partialPayment.totalValue:N8}\n" +
                        $"Aguardando o restante ({_viewModel.MissingAmount:N8})..."
                        );
                });
            }
                );
        }
Exemplo n.º 4
0
        private async void Receive_Clicked(object sender, EventArgs e)
        {
            Debug.WriteLine($"Receive Clicked: {_viewModel.TransactionValue}", "UI");

            Payment payment = null;

            try
            {
                payment = await _viewModel.GenerateNewPayment();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                await _msgDisplayer.ShowMessageAsync("Aconteceu um erro.");
            }

            if (payment != null)
            {
                await _navigationService.NavigateToModalAsync <PaymentFinalizationPageViewModel>(payment);
            }
        }