diff --git a/Telegram/SourceFiles/payments/payments_checkout_process.cpp b/Telegram/SourceFiles/payments/payments_checkout_process.cpp index 6eb4ab7a4..ff8692009 100644 --- a/Telegram/SourceFiles/payments/payments_checkout_process.cpp +++ b/Telegram/SourceFiles/payments/payments_checkout_process.cpp @@ -106,7 +106,7 @@ CheckoutProcess::CheckoutProcess( }, _lifetime); _panel->backRequests( ) | rpl::start_with_next([=] { - showForm(); + panelCancelEdit(); }, _panel->lifetime()); showForm(); } @@ -385,6 +385,13 @@ bool CheckoutProcess::panelWebviewNavigationAttempt(const QString &uri) { return false; } +void CheckoutProcess::panelCancelEdit() { + if (_submitState != SubmitState::None) { + return; + } + showForm(); +} + void CheckoutProcess::panelEditPaymentMethod() { if (_submitState != SubmitState::None && _submitState != SubmitState::Validated) { diff --git a/Telegram/SourceFiles/payments/payments_checkout_process.h b/Telegram/SourceFiles/payments/payments_checkout_process.h index ea5ca02e1..06ca7ca7e 100644 --- a/Telegram/SourceFiles/payments/payments_checkout_process.h +++ b/Telegram/SourceFiles/payments/payments_checkout_process.h @@ -85,6 +85,7 @@ private: void panelWebviewMessage(const QJsonDocument &message) override; bool panelWebviewNavigationAttempt(const QString &uri) override; + void panelCancelEdit() override; void panelEditPaymentMethod() override; void panelEditShippingInformation() override; void panelEditName() override; diff --git a/Telegram/SourceFiles/payments/ui/payments.style b/Telegram/SourceFiles/payments/ui/payments.style index d6931c82f..3dbc9eeaa 100644 --- a/Telegram/SourceFiles/payments/ui/payments.style +++ b/Telegram/SourceFiles/payments/ui/payments.style @@ -9,12 +9,13 @@ using "ui/basic.style"; using "info/info.style"; +paymentsPanelButton: defaultBoxButton; paymentsPanelSubmit: RoundButton(defaultActiveButton) { - width: 0px; - height: 49px; - padding: margins(0px, -3px, 0px, 0px); - textTop: 16px; + width: -36px; + height: 36px; + font: boxButtonFont; } +paymentsPanelPadding: margins(8px, 12px, 15px, 12px); paymentsCoverPadding: margins(26px, 0px, 26px, 13px); paymentsDescription: FlatLabel(defaultFlatLabel) { diff --git a/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp b/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp index 583e73d10..4abdf760d 100644 --- a/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_edit_card.cpp @@ -208,10 +208,14 @@ EditCard::EditCard( , _scroll(this, st::passportPanelScroll) , _topShadow(this) , _bottomShadow(this) -, _done( +, _submit( + this, + tr::lng_about_done(), + st::paymentsPanelButton) +, _cancel( this, - tr::lng_about_done(), - st::passportPanelSaveValue) { + tr::lng_cancel(), + st::paymentsPanelButton) { setupControls(); } @@ -241,9 +245,12 @@ void EditCard::showError(CardField field) { void EditCard::setupControls() { const auto inner = setupContent(); - _done->addClickHandler([=] { + _submit->addClickHandler([=] { _delegate->panelValidateCard(collect()); }); + _cancel->addClickHandler([=] { + _delegate->panelCancelEdit(); + }); using namespace rpl::mappers; @@ -364,14 +371,20 @@ void EditCard::focusInEvent(QFocusEvent *e) { } void EditCard::updateControlsGeometry() { - const auto submitTop = height() - _done->height(); - _scroll->setGeometry(0, 0, width(), submitTop); + const auto &padding = st::paymentsPanelPadding; + const auto buttonsHeight = padding.top() + + _cancel->height() + + padding.bottom(); + const auto buttonsTop = height() - buttonsHeight; + _scroll->setGeometry(0, 0, width(), buttonsTop); _topShadow->resizeToWidth(width()); _topShadow->moveToLeft(0, 0); _bottomShadow->resizeToWidth(width()); - _bottomShadow->moveToLeft(0, submitTop - st::lineWidth); - _done->setFullWidth(width()); - _done->moveToLeft(0, submitTop); + _bottomShadow->moveToLeft(0, buttonsTop - st::lineWidth); + auto right = padding.right(); + _submit->moveToRight(right, buttonsTop + padding.top()); + right += _submit->width() + padding.left(); + _cancel->moveToRight(right, buttonsTop + padding.top()); _scroll->updateBars(); } diff --git a/Telegram/SourceFiles/payments/ui/payments_edit_card.h b/Telegram/SourceFiles/payments/ui/payments_edit_card.h index 742bdbf34..da6a23c4c 100644 --- a/Telegram/SourceFiles/payments/ui/payments_edit_card.h +++ b/Telegram/SourceFiles/payments/ui/payments_edit_card.h @@ -53,7 +53,8 @@ private: object_ptr _scroll; object_ptr _topShadow; object_ptr _bottomShadow; - object_ptr _done; + object_ptr _submit; + object_ptr _cancel; std::unique_ptr _number; std::unique_ptr _cvc; diff --git a/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp b/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp index b216d1d30..04940544e 100644 --- a/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_edit_information.cpp @@ -44,10 +44,14 @@ EditInformation::EditInformation( , _scroll(this, st::passportPanelScroll) , _topShadow(this) , _bottomShadow(this) -, _done( +, _submit( + this, + tr::lng_settings_save(), + st::paymentsPanelButton) +, _cancel( this, - tr::lng_about_done(), - st::passportPanelSaveValue) { + tr::lng_cancel(), + st::paymentsPanelButton) { setupControls(); } @@ -79,9 +83,12 @@ void EditInformation::showError(InformationField field) { void EditInformation::setupControls() { const auto inner = setupContent(); - _done->addClickHandler([=] { + _submit->addClickHandler([=] { _delegate->panelValidateInformation(collect()); }); + _cancel->addClickHandler([=] { + _delegate->panelCancelEdit(); + }); using namespace rpl::mappers; @@ -189,14 +196,20 @@ void EditInformation::focusInEvent(QFocusEvent *e) { } void EditInformation::updateControlsGeometry() { - const auto submitTop = height() - _done->height(); - _scroll->setGeometry(0, 0, width(), submitTop); + const auto &padding = st::paymentsPanelPadding; + const auto buttonsHeight = padding.top() + + _cancel->height() + + padding.bottom(); + const auto buttonsTop = height() - buttonsHeight; + _scroll->setGeometry(0, 0, width(), buttonsTop); _topShadow->resizeToWidth(width()); _topShadow->moveToLeft(0, 0); _bottomShadow->resizeToWidth(width()); - _bottomShadow->moveToLeft(0, submitTop - st::lineWidth); - _done->setFullWidth(width()); - _done->moveToLeft(0, submitTop); + _bottomShadow->moveToLeft(0, buttonsTop - st::lineWidth); + auto right = padding.right(); + _submit->moveToRight(right, buttonsTop + padding.top()); + right += _submit->width() + padding.left(); + _cancel->moveToRight(right, buttonsTop + padding.top()); _scroll->updateBars(); } diff --git a/Telegram/SourceFiles/payments/ui/payments_edit_information.h b/Telegram/SourceFiles/payments/ui/payments_edit_information.h index 5864f8328..6755939a0 100644 --- a/Telegram/SourceFiles/payments/ui/payments_edit_information.h +++ b/Telegram/SourceFiles/payments/ui/payments_edit_information.h @@ -59,7 +59,8 @@ private: object_ptr _scroll; object_ptr _topShadow; object_ptr _bottomShadow; - object_ptr _done; + object_ptr _submit; + object_ptr _cancel; std::unique_ptr _street1; std::unique_ptr _street2; diff --git a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp index 8f441f6a7..b1aa3a2b6 100644 --- a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp @@ -47,16 +47,20 @@ FormSummary::FormSummary( , _scroll(this, st::passportPanelScroll) , _topShadow(this) , _bottomShadow(this) -, _submit( - this, - (_invoice.receipt.paid - ? tr::lng_about_done() - : tr::lng_payments_pay_amount( +, _submit(_invoice.receipt.paid + ? object_ptr(nullptr) + : object_ptr( + this, + tr::lng_payments_pay_amount( lt_amount, - rpl::single(formatAmount(computeTotalAmount())))), - (_invoice.receipt.paid - ? st::passportPanelSaveValue - : st::paymentsPanelSubmit)) { + rpl::single(formatAmount(computeTotalAmount()))), + st::paymentsPanelSubmit)) +, _cancel( + this, + (_invoice.receipt.paid + ? tr::lng_about_done() + : tr::lng_cancel()), + st::paymentsPanelButton) { setupControls(); } @@ -92,11 +96,19 @@ int64 FormSummary::computeTotalAmount() const { void FormSummary::setupControls() { const auto inner = setupContent(); - _submit->addClickHandler([=] { - _delegate->panelSubmit(); + if (_submit) { + _submit->addClickHandler([=] { + _delegate->panelSubmit(); + }); + } + _cancel->addClickHandler([=] { + _delegate->panelRequestClose(); }); if (!_invoice) { - _submit->hide(); + if (_submit) { + _submit->hide(); + } + _cancel->hide(); } using namespace rpl::mappers; @@ -387,14 +399,22 @@ void FormSummary::resizeEvent(QResizeEvent *e) { } void FormSummary::updateControlsGeometry() { - const auto submitTop = height() - _submit->height(); - _scroll->setGeometry(0, 0, width(), submitTop); + const auto &padding = st::paymentsPanelPadding; + const auto buttonsHeight = padding.top() + + _cancel->height() + + padding.bottom(); + const auto buttonsTop = height() - buttonsHeight; + _scroll->setGeometry(0, 0, width(), buttonsTop); _topShadow->resizeToWidth(width()); _topShadow->moveToLeft(0, 0); _bottomShadow->resizeToWidth(width()); - _bottomShadow->moveToLeft(0, submitTop - st::lineWidth); - _submit->setFullWidth(width()); - _submit->moveToLeft(0, submitTop); + _bottomShadow->moveToLeft(0, buttonsTop - st::lineWidth); + auto right = padding.right(); + if (_submit) { + _submit->moveToRight(right, buttonsTop + padding.top()); + right += _submit->width() + padding.left(); + } + _cancel->moveToRight(right, buttonsTop + padding.top()); _scroll->updateBars(); } diff --git a/Telegram/SourceFiles/payments/ui/payments_form_summary.h b/Telegram/SourceFiles/payments/ui/payments_form_summary.h index 8ce6bcd4c..7db3e4b16 100644 --- a/Telegram/SourceFiles/payments/ui/payments_form_summary.h +++ b/Telegram/SourceFiles/payments/ui/payments_form_summary.h @@ -58,6 +58,7 @@ private: object_ptr _topShadow; object_ptr _bottomShadow; object_ptr _submit; + object_ptr _cancel; rpl::event_stream _thumbnails; }; diff --git a/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h b/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h index e3bf155e7..cce968fe1 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel_delegate.h @@ -31,6 +31,7 @@ public: virtual void panelWebviewMessage(const QJsonDocument &message) = 0; virtual bool panelWebviewNavigationAttempt(const QString &uri) = 0; + virtual void panelCancelEdit() = 0; virtual void panelEditPaymentMethod() = 0; virtual void panelEditShippingInformation() = 0; virtual void panelEditName() = 0; diff --git a/Telegram/SourceFiles/ui/text/format_values.cpp b/Telegram/SourceFiles/ui/text/format_values.cpp index edcca777c..9294cc0bc 100644 --- a/Telegram/SourceFiles/ui/text/format_values.cpp +++ b/Telegram/SourceFiles/ui/text/format_values.cpp @@ -372,7 +372,7 @@ QString FillAmountAndCurrency(int64 amount, const QString ¤cy) { const auto name = (*rule.international) ? QString::fromUtf8(rule.international) : currency; - auto result = QString(); + auto result = prefix; if (rule.left) { result.append(name); if (rule.space) result.append(' '); @@ -381,7 +381,7 @@ QString FillAmountAndCurrency(int64 amount, const QString ¤cy) { || std::floor(value) != value) ? exponent : 0; - result.append(prefix).append(FormatWithSeparators( + result.append(FormatWithSeparators( value, precision, rule.decimal,