From 38abfacd8820d78199fa07636ba31071c8790fe9 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 21 Mar 2022 15:33:31 +0300 Subject: [PATCH] Added ability to open calendar from search messages in dialogs. --- Telegram/SourceFiles/dialogs/dialogs.style | 9 +++++++++ .../controls/history_view_compose_search.cpp | 20 ++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index 7a1f2f1224..e3f4bbc579 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -179,6 +179,15 @@ dialogsCancelSearch: CrossButton { ripple: emptyRippleAnimation; } +dialogCalendar: IconButton(dialogsMenuToggle) { + icon: icon {{ "dialogs/dialogs_calendar", lightButtonFg }}; + iconOver: icon {{ "dialogs/dialogs_calendar", lightButtonFgOver }}; + iconPosition: point(8px, 9px); + + rippleAreaPosition: point(3px, 3px); + rippleAreaSize: 34px; +} + dialogsChatTypeSkip: 20px; dialogsChatIcon: icon {{ "dialogs/dialogs_chat", dialogsChatIconFg, point(1px, 4px) }}; dialogsChatIconOver: icon {{ "dialogs/dialogs_chat", dialogsChatIconFgOver, point(1px, 4px) }}; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp index 2dcedd422f..610c25fb1f 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_search.cpp @@ -97,12 +97,15 @@ public: void setTotal(int total); [[nodiscard]] rpl::producer showItemRequests() const; + [[nodiscard]] rpl::producer<> showCalendarRequests() const; private: void updateText(int current); base::unique_qptr _previous; base::unique_qptr _next; + + base::unique_qptr _jumpToDate; base::unique_qptr _counter; int _total = -1; @@ -114,6 +117,7 @@ BottomBar::BottomBar(not_null parent) // Icons are swaped. , _previous(base::make_unique_q(this, st::calendarNext)) , _next(base::make_unique_q(this, st::calendarPrevious)) +, _jumpToDate(base::make_unique_q(this, st::dialogCalendar)) , _counter(base::make_unique_q( this, st::defaultSettingsRightLabel)) { @@ -135,7 +139,12 @@ BottomBar::BottomBar(not_null parent) (s.height() - _next->height()) / 2); const auto left = st::topBarActionSkip; - _counter->moveToLeft(left, (s.height() - _counter->height()) / 2); + _jumpToDate->moveToLeft( + left, + (s.height() - _jumpToDate->height()) / 2); + _counter->moveToLeft( + _jumpToDate->x() + _jumpToDate->width(), + (s.height() - _counter->height()) / 2); }, lifetime()); paintRequest( @@ -195,6 +204,10 @@ rpl::producer BottomBar::showItemRequests() const { return _current.changes() | rpl::map(rpl::mappers::_1 - 1); } +rpl::producer<> BottomBar::showCalendarRequests() const { + return _jumpToDate->clicks() | rpl::to_empty; +} + } // namespace class ComposeSearch::Inner final { @@ -285,6 +298,11 @@ ComposeSearch::Inner::Inner( }); } }, _bottomBar->lifetime()); + + _bottomBar->showCalendarRequests( + ) | rpl::start_with_next([=] { + _window->showCalendar({ _history }, QDate()); + }, _bottomBar->lifetime()); } void ComposeSearch::Inner::showAnimated() {