diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index 7813a8244..d97628285 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -534,12 +534,15 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { const auto bottom = _webviewBottom.get(); bottom->show(); - bottom->heightValue( - ) | rpl::start_with_next([=](int height) { - const auto inner = _widget->innerGeometry(); + rpl::combine( + container->geometryValue() | rpl::map([=] { + return _widget->innerGeometry(); + }), + bottom->heightValue() + ) | rpl::start_with_next([=](QRect inner, int height) { bottom->move(inner.x(), inner.y() + inner.height() - height); - container->resize(inner.width(), inner.height() - height); bottom->resizeToWidth(inner.width()); + _footerHeight = bottom->height(); }, bottom->lifetime()); container->show(); @@ -584,10 +587,12 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { }); }); - container->geometryValue( - ) | rpl::start_with_next([=](QRect geometry) { - if (raw->widget()) { - raw->widget()->setGeometry(geometry); + rpl::combine( + container->geometryValue(), + _footerHeight.value() + ) | rpl::start_with_next([=](QRect geometry, int footer) { + if (const auto view = raw->widget()) { + view->setGeometry(geometry.marginsRemoved({ 0, 0, 0, footer })); } }, _webview->lifetime); diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.h b/Telegram/SourceFiles/payments/ui/payments_panel.h index b65def015..6c64c661f 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel.h @@ -115,11 +115,13 @@ private: [[nodiscard]] bool progressWithBackground() const; [[nodiscard]] QRect progressRect() const; void setupProgressGeometry(); + void updateFooterHeight(); const not_null _delegate; std::unique_ptr _widget; std::unique_ptr _webview; std::unique_ptr _webviewBottom; + rpl::variable _footerHeight; std::unique_ptr _progress; QPointer _saveWebviewInformation; QPointer _weakFormSummary; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 747c812e4..d419d7775 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -570,17 +570,15 @@ void Panel::createWebviewBottom() { label->show(); _webviewBottom->resize(_webviewBottom->width(), height); - bottom->heightValue( - ) | rpl::start_with_next([=](int height) { - const auto inner = _widget->innerGeometry(); - if (_mainButton && !_mainButton->isHidden()) { - height = _mainButton->height(); - } + rpl::combine( + _webviewParent->geometryValue() | rpl::map([=] { + return _widget->innerGeometry(); + }), + bottom->heightValue() + ) | rpl::start_with_next([=](QRect inner, int height) { bottom->move(inner.x(), inner.y() + inner.height() - height); - if (const auto container = _webviewParent.data()) { - container->setFixedSize(inner.width(), inner.height() - height); - } bottom->resizeToWidth(inner.width()); + updateFooterHeight(); }, bottom->lifetime()); } @@ -636,10 +634,13 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { }); }); - container->geometryValue( - ) | rpl::start_with_next([=](QRect geometry) { - if (raw->widget()) { - raw->widget()->setGeometry(geometry); + updateFooterHeight(); + rpl::combine( + container->geometryValue(), + _footerHeight.value() + ) | rpl::start_with_next([=](QRect geometry, int footer) { + if (const auto view = raw->widget()) { + view->setGeometry(geometry.marginsRemoved({ 0, 0, 0, footer })); } }, _webview->lifetime); @@ -1185,22 +1186,25 @@ void Panel::createMainButton() { button->hide(); rpl::combine( + _webviewParent->geometryValue() | rpl::map([=] { + return _widget->innerGeometry(); + }), button->shownValue(), button->heightValue() - ) | rpl::start_with_next([=](bool shown, int height) { - const auto inner = _widget->innerGeometry(); - if (!shown) { - height = _webviewBottom->height(); - } + ) | rpl::start_with_next([=](QRect inner, bool shown, int height) { button->move(inner.x(), inner.y() + inner.height() - height); - if (const auto raw = _webviewParent.data()) { - raw->setFixedSize(inner.width(), inner.height() - height); - } button->resizeToWidth(inner.width()); _webviewBottom->setVisible(!shown); + updateFooterHeight(); }, button->lifetime()); } +void Panel::updateFooterHeight() { + _footerHeight = (_mainButton && !_mainButton->isHidden()) + ? _mainButton->height() + : _webviewBottom->height(); +} + void Panel::showBox(object_ptr box) { if (const auto widget = _webview ? _webview->window.widget() : nullptr) { const auto hideNow = !widget->isHidden(); diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index ee1dae837..fb0231a01 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -143,6 +143,7 @@ private: [[nodiscard]] bool progressWithBackground() const; [[nodiscard]] QRect progressRect() const; void setupProgressGeometry(); + void updateFooterHeight(); Webview::StorageId _storageId; const not_null _delegate; @@ -153,9 +154,10 @@ private: std::unique_ptr _webview; std::unique_ptr _webviewBottom; rpl::variable _bottomText; - QPointer _webviewParent; + QPointer _webviewParent; std::unique_ptr