Added bottom fade shadow to info sections with pinned bottom content.

This commit is contained in:
23rd 2022-05-19 03:16:05 +03:00
parent 62c759a0ff
commit f3ca4f45ea
4 changed files with 37 additions and 1 deletions

View File

@ -275,6 +275,20 @@ void ContentWidget::refreshSearchField(bool shown) {
}
}
int ContentWidget::scrollBottomSkip() const {
return _scrollBottomSkip.current();
}
rpl::producer<bool> 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);

View File

@ -79,6 +79,9 @@ public:
virtual void saveChanges(FnMut<void()> done);
[[nodiscard]] int scrollBottomSkip() const;
[[nodiscard]] rpl::producer<bool> desiredBottomShadowVisibility() const;
protected:
template <typename Widget>
Widget *setInnerWidget(object_ptr<Widget> inner) {

View File

@ -70,12 +70,18 @@ WrapWidget::WrapWidget(
: SectionWidget(parent, window, rpl::producer<PeerData*>())
, _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());
}
}

View File

@ -218,6 +218,7 @@ private:
bool _topBarOverrideShown = false;
object_ptr<Ui::FadeShadow> _topShadow;
object_ptr<Ui::FadeShadow> _bottomShadow;
base::unique_qptr<Ui::IconButton> _topBarMenuToggle;
base::unique_qptr<Ui::PopupMenu> _topBarMenu;
@ -227,6 +228,7 @@ private:
rpl::event_stream<rpl::producer<int>> _desiredHeights;
rpl::event_stream<rpl::producer<bool>> _desiredShadowVisibilities;
rpl::event_stream<rpl::producer<bool>> _desiredBottomShadowVisibilities;
rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists;
rpl::event_stream<rpl::producer<int>> _scrollTillBottomChanges;
rpl::event_stream<> _contentChanges;