/* 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 #include #include #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 &&label, rpl::producer &&text, const style::FlatLabel &textSt, const style::margins &padding) { auto result = object_ptr>( parent, object_ptr(parent), padding); result->setDuration( st::infoSlideDuration ); auto layout = result->entity(); 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); }); auto labeled = layout->add(object_ptr( layout, std::move(nonEmptyText), textSt)); labeled->setSelectable(true); layout->add(Ui::CreateSkipWidget(layout, st::infoLabelSkip)); layout->add(object_ptr( layout, std::move( label ) | rpl::after_next([=] { layout->resizeToWidth(layout->widthNoMargins()); }), st::infoLabel)); result->finishAnimating(); return { std::move(result), labeled }; } } // namespace Profile } // namespace Info