2017-09-25 09:02:55 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-25 09:02:55 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-25 09:02:55 +00:00
|
|
|
*/
|
|
|
|
#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 {
|
|
|
|
|
2017-11-10 17:51:59 +00:00
|
|
|
TextWithLabel CreateTextWithLabel(
|
2017-09-25 09:02:55 +00:00
|
|
|
QWidget *parent,
|
|
|
|
rpl::producer<TextWithEntities> &&label,
|
|
|
|
rpl::producer<TextWithEntities> &&text,
|
2023-06-16 11:56:44 +00:00
|
|
|
const style::FlatLabel &labelSt,
|
2017-09-25 09:02:55 +00:00
|
|
|
const style::FlatLabel &textSt,
|
2017-11-10 17:51:59 +00:00
|
|
|
const style::margins &padding) {
|
2017-09-25 09:02:55 +00:00
|
|
|
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
|
|
|
parent,
|
|
|
|
object_ptr<Ui::VerticalLayout>(parent),
|
|
|
|
padding);
|
2017-11-19 11:37:15 +00:00
|
|
|
result->setDuration(
|
|
|
|
st::infoSlideDuration
|
|
|
|
);
|
2017-09-25 09:02:55 +00:00
|
|
|
auto layout = result->entity();
|
2017-12-22 07:05:20 +00:00
|
|
|
auto nonEmptyText = std::move(
|
|
|
|
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);
|
|
|
|
});
|
2017-09-25 09:02:55 +00:00
|
|
|
auto labeled = layout->add(object_ptr<Ui::FlatLabel>(
|
|
|
|
layout,
|
|
|
|
std::move(nonEmptyText),
|
|
|
|
textSt));
|
|
|
|
labeled->setSelectable(true);
|
|
|
|
layout->add(Ui::CreateSkipWidget(layout, st::infoLabelSkip));
|
2022-10-12 22:24:03 +00:00
|
|
|
const auto subtext = layout->add(object_ptr<Ui::FlatLabel>(
|
2017-09-25 09:02:55 +00:00
|
|
|
layout,
|
2018-11-20 15:36:36 +00:00
|
|
|
std::move(
|
|
|
|
label
|
|
|
|
) | rpl::after_next([=] {
|
|
|
|
layout->resizeToWidth(layout->widthNoMargins());
|
|
|
|
}),
|
2023-06-16 11:56:44 +00:00
|
|
|
labelSt));
|
2017-09-30 19:20:40 +00:00
|
|
|
result->finishAnimating();
|
2022-10-12 22:24:03 +00:00
|
|
|
return { std::move(result), labeled, subtext };
|
2017-09-25 09:02:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Profile
|
|
|
|
} // namespace Info
|