diff --git a/Telegram/SourceFiles/iv/iv_controller.cpp b/Telegram/SourceFiles/iv/iv_controller.cpp index 2b436d842c..c73b063294 100644 --- a/Telegram/SourceFiles/iv/iv_controller.cpp +++ b/Telegram/SourceFiles/iv/iv_controller.cpp @@ -903,10 +903,12 @@ void Controller::showWebviewError() { } void Controller::showWebviewError(TextWithEntities text) { - auto error = Ui::CreateChild>( - _container, + const auto wrap = Ui::CreateChild(_container); + + const auto error = Ui::CreateChild>( + wrap, object_ptr( - _container, + wrap, rpl::single(text), st::paymentsCriticalError), st::paymentsCriticalErrorPadding); @@ -920,10 +922,16 @@ void Controller::showWebviewError(TextWithEntities text) { File::OpenUrl(entity.data); return false; }); - error->show(); + wrap->show(); + + wrap->widthValue() | rpl::start_with_next([=](int width) { + error->resizeToWidth(width); + wrap->resize(width, error->height()); + }, wrap->lifetime()); + _container->sizeValue() | rpl::start_with_next([=](QSize size) { - error->setGeometry(0, 0, size.width(), size.height() * 2 / 3); - }, error->lifetime()); + wrap->setGeometry(0, 0, size.width(), size.height() * 2 / 3); + }, wrap->lifetime()); } void Controller::showInWindow( diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index b0e1bcc0cb..6e7f049bc1 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -881,10 +881,13 @@ void Panel::showCriticalError(const TextWithEntities &text) { _progress = nullptr; _webviewProgress = false; if (!_weakFormSummary || !_weakFormSummary->showCriticalError(text)) { - auto error = base::make_unique_q>( - _widget.get(), + auto wrap = base::make_unique_q(_widget.get()); + const auto raw = wrap.get(); + + const auto error = CreateChild>( + raw, object_ptr( - _widget.get(), + raw, rpl::single(text), st::paymentsCriticalError), st::paymentsCriticalErrorPadding); @@ -898,7 +901,13 @@ void Panel::showCriticalError(const TextWithEntities &text) { _delegate->panelOpenUrl(entity.data); return false; }); - _widget->showInner(std::move(error)); + + raw->widthValue() | rpl::start_with_next([=](int width) { + error->resizeToWidth(width); + raw->resize(width, error->height()); + }, raw->lifetime()); + + _widget->showInner(std::move(wrap)); } } diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 525bc4eb05..5bc6481e86 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -2014,10 +2014,13 @@ void Panel::hideLayer(anim::type animated) { void Panel::showCriticalError(const TextWithEntities &text) { _progress = nullptr; _webviewProgress = false; - auto error = base::make_unique_q>( - _widget.get(), + auto wrap = base::make_unique_q(_widget.get()); + const auto raw = wrap.get(); + + const auto error = CreateChild>( + raw, object_ptr( - _widget.get(), + raw, rpl::single(text), st::paymentsCriticalError), st::paymentsCriticalErrorPadding); @@ -2031,7 +2034,13 @@ void Panel::showCriticalError(const TextWithEntities &text) { File::OpenUrl(entity.data); return false; }); - _widget->showInner(std::move(error)); + + raw->widthValue() | rpl::start_with_next([=](int width) { + error->resizeToWidth(width); + raw->resize(width, error->height()); + }, raw->lifetime()); + + _widget->showInner(std::move(wrap)); } void Panel::updateThemeParams(const Webview::ThemeParams ¶ms) {