diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 984d5b647e..a1f570fac4 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -212,7 +212,9 @@ Widget::Widget( _searchControls, object_ptr(this, st::dialogsCalendar)) , _cancelSearch(_searchControls, st::dialogsCancelSearch) -, _lockUnlock(_searchControls, st::dialogsLock) +, _lockUnlock( + _searchControls, + object_ptr(this, st::dialogsLock)) , _scroll(this) , _scrollToTop(_scroll, st::dialogsToUp) , _stories((_layout != Layout::Child) @@ -370,10 +372,13 @@ Widget::Widget( ) | rpl::start_with_next([=] { updateLockUnlockVisibility(); }, lifetime()); - _lockUnlock->setClickedCallback([this] { - _lockUnlock->setIconOverride(&st::dialogsUnlockIcon, &st::dialogsUnlockIconOver); + const auto lockUnlock = _lockUnlock->entity(); + lockUnlock->setClickedCallback([=] { + lockUnlock->setIconOverride( + &st::dialogsUnlockIcon, + &st::dialogsUnlockIconOver); Core::App().maybeLockByPasscode(); - _lockUnlock->setIconOverride(nullptr); + lockUnlock->setIconOverride(nullptr); }); setupMainMenuToggle(); @@ -2273,6 +2278,7 @@ void Widget::applyFilterUpdate(bool force) { return; } + updateLockUnlockVisibility(anim::type::normal); updateStoriesVisibility(); const auto filterText = currentSearchQuery(); _inner->applyFilterUpdate(filterText, force); @@ -2607,7 +2613,7 @@ void Widget::resizeEvent(QResizeEvent *e) { updateControlsGeometry(); } -void Widget::updateLockUnlockVisibility() { +void Widget::updateLockUnlockVisibility(anim::type animated) { if (_showAnimation) { return; } @@ -2618,8 +2624,11 @@ void Widget::updateLockUnlockVisibility() { || _childList || !_filter->getLastText().isEmpty() || _searchInChat; - if (_lockUnlock->isHidden() != hidden) { - _lockUnlock->setVisible(!hidden); + if (_lockUnlock->toggled() == hidden) { + const auto stories = _stories && !_stories->empty(); + _lockUnlock->toggle( + !hidden, + stories ? anim::type::instant : animated); if (!hidden) { updateLockUnlockPosition(); } diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index 48760b6306..83a8d70e64 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -179,7 +179,8 @@ private: void clearSearchCache(); void setSearchQuery(const QString &query); void updateControlsVisibility(bool fast = false); - void updateLockUnlockVisibility(); + void updateLockUnlockVisibility( + anim::type animated = anim::type::instant); void updateLoadMoreChatsVisibility(); void updateStoriesVisibility(); void updateJumpToDateVisibility(bool fast = false); @@ -245,7 +246,7 @@ private: object_ptr> _chooseFromUser; object_ptr> _jumpToDate; object_ptr _cancelSearch; - object_ptr _lockUnlock; + object_ptr< Ui::FadeWrapScaled> _lockUnlock; std::unique_ptr _moreChatsBar;