init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
69
Telegram/SourceFiles/info/profile/info_profile_text.cpp
Normal file
69
Telegram/SourceFiles/info/profile/info_profile_text.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "info/profile/info_profile_text.h"
|
||||
|
||||
#include <rpl/before_next.h>
|
||||
#include <rpl/filter.h>
|
||||
#include <rpl/after_next.h>
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
namespace Info {
|
||||
namespace Profile {
|
||||
|
||||
TextWithLabel CreateTextWithLabel(
|
||||
QWidget *parent,
|
||||
rpl::producer<TextWithEntities> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const style::FlatLabel &labelSt,
|
||||
const style::FlatLabel &textSt,
|
||||
const style::margins &padding) {
|
||||
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
parent,
|
||||
object_ptr<Ui::VerticalLayout>(parent),
|
||||
padding);
|
||||
result->setDuration(st::infoSlideDuration);
|
||||
auto layout = result->entity();
|
||||
auto nonEmptyText = rpl::duplicate(
|
||||
text
|
||||
) | rpl::before_next([slide = result.data()](
|
||||
const TextWithEntities &value) {
|
||||
if (value.text.isEmpty()) {
|
||||
slide->hide(anim::type::normal);
|
||||
}
|
||||
}) | rpl::filter([](const TextWithEntities &value) {
|
||||
return !value.text.isEmpty();
|
||||
}) | rpl::after_next([slide = result.data()](
|
||||
const TextWithEntities &value) {
|
||||
slide->show(anim::type::normal);
|
||||
});
|
||||
const auto labeled = layout->add(object_ptr<Ui::FlatLabel>(
|
||||
layout,
|
||||
std::move(nonEmptyText),
|
||||
textSt));
|
||||
std::move(text) | rpl::on_next([=] {
|
||||
labeled->resizeToWidth(layout->width());
|
||||
}, labeled->lifetime());
|
||||
labeled->setSelectable(true);
|
||||
layout->add(Ui::CreateSkipWidget(layout, st::infoLabelSkip));
|
||||
const auto subtext = layout->add(object_ptr<Ui::FlatLabel>(
|
||||
layout,
|
||||
std::move(
|
||||
label
|
||||
) | rpl::after_next([=] {
|
||||
layout->resizeToWidth(layout->widthNoMargins());
|
||||
}),
|
||||
labelSt));
|
||||
result->finishAnimating();
|
||||
return { std::move(result), labeled, subtext };
|
||||
}
|
||||
|
||||
} // namespace Profile
|
||||
} // namespace Info
|
||||
Reference in New Issue
Block a user