diff --git a/Telegram/SourceFiles/info/info_content_widget.cpp b/Telegram/SourceFiles/info/info_content_widget.cpp index eadc09e7c..88f74e598 100644 --- a/Telegram/SourceFiles/info/info_content_widget.cpp +++ b/Telegram/SourceFiles/info/info_content_widget.cpp @@ -275,6 +275,20 @@ void ContentWidget::refreshSearchField(bool shown) { } } +int ContentWidget::scrollBottomSkip() const { + return _scrollBottomSkip.current(); +} + +rpl::producer ContentWidget::desiredBottomShadowVisibility() const { + using namespace rpl::mappers; + return rpl::combine( + _scroll->scrollTopValue(), + _scrollBottomSkip.value() + ) | rpl::map([=](int scroll, int skip) { + return ((skip > 0) && (scroll < _scroll->scrollTopMax())); + }); +} + Key ContentMemento::key() const { if (const auto peer = this->peer()) { return Key(peer); diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index be548fbf1..c79c703d5 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -79,6 +79,9 @@ public: virtual void saveChanges(FnMut done); + [[nodiscard]] int scrollBottomSkip() const; + [[nodiscard]] rpl::producer desiredBottomShadowVisibility() const; + protected: template Widget *setInnerWidget(object_ptr inner) { diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index f3150f277..bd992ee35 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -70,12 +70,18 @@ WrapWidget::WrapWidget( : SectionWidget(parent, window, rpl::producer()) , _wrap(wrap) , _controller(createController(window, memento->content())) -, _topShadow(this) { +, _topShadow(this) +, _bottomShadow(this) { _topShadow->toggleOn( topShadowToggledValue( ) | rpl::filter([](bool shown) { return true; })); + + _bottomShadow->toggleOn( + _desiredBottomShadowVisibilities.events( + ) | rpl::flatten_latest() | rpl::distinct_until_changed()); + _wrap.changes( ) | rpl::start_with_next([this] { setupTop(); @@ -651,10 +657,14 @@ void WrapWidget::finishShowContent() { _topBar->setTitle(_content->title()); _desiredHeights.fire(desiredHeightForContent()); _desiredShadowVisibilities.fire(_content->desiredShadowVisibility()); + _desiredBottomShadowVisibilities.fire( + _content->desiredBottomShadowVisibility()); _selectedLists.fire(_content->selectedListValue()); _scrollTillBottomChanges.fire(_content->scrollTillBottomChanges()); _topShadow->raise(); _topShadow->finishAnimating(); + _bottomShadow->raise(); + _bottomShadow->finishAnimating(); _contentChanges.fire({}); // This was done for tabs support. @@ -810,6 +820,7 @@ void WrapWidget::doSetInnerFocus() { void WrapWidget::showFinishedHook() { // Restore shadow visibility after showChildren() call. _topShadow->toggle(_topShadow->toggled(), anim::type::instant); + _bottomShadow->toggle(_bottomShadow->toggled(), anim::type::instant); _topBarSurrogate.destroy(); _content->showFinished(); } @@ -1023,6 +1034,12 @@ void WrapWidget::updateContentGeometry() { _topShadow->resizeToWidth(width()); _topShadow->moveToLeft(0, topWidget()->height()); _content->setGeometry(contentGeometry()); + _bottomShadow->resizeToWidth(width()); + _bottomShadow->moveToLeft( + 0, + _content->y() + + _content->height() + - _content->scrollBottomSkip()); } } diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index d2cf6c2ca..a1100f6fd 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -218,6 +218,7 @@ private: bool _topBarOverrideShown = false; object_ptr _topShadow; + object_ptr _bottomShadow; base::unique_qptr _topBarMenuToggle; base::unique_qptr _topBarMenu; @@ -227,6 +228,7 @@ private: rpl::event_stream> _desiredHeights; rpl::event_stream> _desiredShadowVisibilities; + rpl::event_stream> _desiredBottomShadowVisibilities; rpl::event_stream> _selectedLists; rpl::event_stream> _scrollTillBottomChanges; rpl::event_stream<> _contentChanges;