Removed Adaptive namespace from Profile::BackButton.

This commit is contained in:
23rd 2021-05-27 00:39:30 +03:00
parent 0d814066d6
commit 295a863d69
3 changed files with 22 additions and 19 deletions

View File

@ -114,7 +114,8 @@ FixedBar::FixedBar(
, _backButton(
this,
&controller->session(),
tr::lng_admin_log_title_all(tr::now))
tr::lng_admin_log_title_all(tr::now),
controller->adaptive().oneColumnValue())
, _search(this, st::topBarSearch)
, _cancel(this, st::historyAdminLogCancelSearch)
, _filter(this, tr::lng_admin_log_filter(), st::topBarButton) {

View File

@ -14,21 +14,35 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_window.h"
#include "styles/style_profile.h"
#include "styles/style_info.h"
#include "facades.h"
namespace Profile {
BackButton::BackButton(
QWidget *parent,
not_null<Main::Session*> session,
const QString &text)
const QString &text,
rpl::producer<bool> oneColumnValue)
: Ui::AbstractButton(parent)
, _session(session)
, _text(text.toUpper()) {
setCursor(style::cur_pointer);
subscribe(Adaptive::Changed(), [=] { updateAdaptiveLayout(); });
updateAdaptiveLayout();
std::move(
oneColumnValue
) | rpl::start_with_next([=](bool oneColumn) {
if (!oneColumn) {
_unreadBadgeLifetime.destroy();
} else if (!_unreadBadgeLifetime) {
_session->data().unreadBadgeChanges(
) | rpl::start_with_next([=] {
rtlupdate(
0,
0,
st::titleUnreadCounterRight,
st::titleUnreadCounterTop);
}, _unreadBadgeLifetime);
}
}, lifetime());
}
void BackButton::setText(const QString &text) {
@ -57,15 +71,4 @@ void BackButton::onStateChanged(State was, StateChangeSource source) {
}
}
void BackButton::updateAdaptiveLayout() {
if (!Adaptive::OneColumn()) {
_unreadBadgeLifetime.destroy();
} else if (!_unreadBadgeLifetime) {
_session->data().unreadBadgeChanges(
) | rpl::start_with_next([=] {
rtlupdate(0, 0, st::titleUnreadCounterRight, st::titleUnreadCounterTop);
}, _unreadBadgeLifetime);
}
}
} // namespace Profile

View File

@ -20,7 +20,8 @@ public:
BackButton(
QWidget *parent,
not_null<Main::Session*> session,
const QString &text);
const QString &text,
rpl::producer<bool> oneColumnValue);
void setText(const QString &text);
@ -31,8 +32,6 @@ protected:
void onStateChanged(State was, StateChangeSource source) override;
private:
void updateAdaptiveLayout();
const not_null<Main::Session*> _session;
rpl::lifetime _unreadBadgeLifetime;