diff options
author | John Preston <johnprestonmail@gmail.com> | 2021-03-23 16:34:34 +0400 |
---|---|---|
committer | John Preston <johnprestonmail@gmail.com> | 2021-03-23 16:34:34 +0400 |
commit | 28137dfb609fb5da649d46ee125ad789a0580fc8 (patch) | |
tree | 9c640689e479adbf6f74376abf58003bb74e294e /Telegram/SourceFiles/payments/ui/payments_form_summary.cpp | |
parent | e7784620d36b146942cda025228f1aa03cff1dd9 (diff) |
Start proper payments processing.
Diffstat (limited to 'Telegram/SourceFiles/payments/ui/payments_form_summary.cpp')
-rw-r--r-- | Telegram/SourceFiles/payments/ui/payments_form_summary.cpp | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp new file mode 100644 index 0000000000..935aa7cdd7 --- /dev/null +++ b/Telegram/SourceFiles/payments/ui/payments_form_summary.cpp @@ -0,0 +1,87 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +#include "payments/ui/payments_form_summary.h" + +#include "payments/ui/payments_panel_delegate.h" +#include "ui/widgets/scroll_area.h" +#include "ui/widgets/buttons.h" +#include "ui/wrap/vertical_layout.h" +#include "ui/wrap/fade_wrap.h" +#include "lang/lang_keys.h" +#include "styles/style_payments.h" +#include "styles/style_passport.h" + +namespace Payments::Ui { + +using namespace ::Ui; + +class PanelDelegate; + +FormSummary::FormSummary( + QWidget *parent, + const Invoice &invoice, + not_null<PanelDelegate*> delegate) +: _delegate(delegate) +, _scroll(this, st::passportPanelScroll) +, _topShadow(this) +, _bottomShadow(this) +, _submit( + this, + tr::lng_payments_pay_amount(lt_amount, rpl::single(QString("much"))), + st::passportPanelAuthorize) { + setupControls(); +} + +void FormSummary::setupControls() { + const auto inner = setupContent(); + + _submit->addClickHandler([=] { + _delegate->panelSubmit(); + }); + + using namespace rpl::mappers; + + _topShadow->toggleOn( + _scroll->scrollTopValue() | rpl::map(_1 > 0)); + _bottomShadow->toggleOn(rpl::combine( + _scroll->scrollTopValue(), + _scroll->heightValue(), + inner->heightValue(), + _1 + _2 < _3)); +} + +not_null<Ui::RpWidget*> FormSummary::setupContent() { + const auto inner = _scroll->setOwnedWidget( + object_ptr<Ui::VerticalLayout>(this)); + + _scroll->widthValue( + ) | rpl::start_with_next([=](int width) { + inner->resizeToWidth(width); + }, inner->lifetime()); + + return inner; +} + +void FormSummary::resizeEvent(QResizeEvent *e) { + updateControlsGeometry(); +} + +void FormSummary::updateControlsGeometry() { + const auto submitTop = height() - _submit->height(); + _scroll->setGeometry(0, 0, width(), submitTop); + _topShadow->resizeToWidth(width()); + _topShadow->moveToLeft(0, 0); + _bottomShadow->resizeToWidth(width()); + _bottomShadow->moveToLeft(0, submitTop - st::lineWidth); + _submit->setFullWidth(width()); + _submit->moveToLeft(0, submitTop); + + _scroll->updateBars(); +} + +} // namespace Payments::Ui |