Moved creation of divider with text and lottie to single place.

This commit is contained in:
23rd 2023-01-07 08:15:27 +03:00 committed by John Preston
parent 991fafb30e
commit c99ac0a264
3 changed files with 52 additions and 44 deletions

View File

@ -43,49 +43,6 @@ From RecreateResetHint:
namespace Settings {
namespace CloudPassword {
namespace {
void SetupTopContent(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<> showFinished) {
const auto divider = Ui::CreateChild<Ui::BoxContentDivider>(parent.get());
const auto verticalLayout = parent->add(
object_ptr<Ui::VerticalLayout>(parent.get()));
auto icon = CreateLottieIcon(
verticalLayout,
{
.name = u"cloud_password/intro"_q,
.sizeOverride = {
st::settingsFilterIconSize,
st::settingsFilterIconSize,
},
},
st::settingsFilterIconPadding);
std::move(
showFinished
) | rpl::start_with_next([animate = std::move(icon.animate)] {
animate(anim::repeat::once);
}, verticalLayout->lifetime());
verticalLayout->add(std::move(icon.widget));
verticalLayout->add(
object_ptr<Ui::CenterWrap<>>(
verticalLayout,
object_ptr<Ui::FlatLabel>(
verticalLayout,
tr::lng_settings_cloud_password_manage_about1(),
st::settingsFilterDividerLabel)),
st::settingsFilterDividerLabelPadding);
verticalLayout->geometryValue(
) | rpl::start_with_next([=](const QRect &r) {
divider->setGeometry(r);
}, divider->lifetime());
}
} // namespace
class Manage : public TypedAbstractStep<Manage> {
public:
@ -164,7 +121,12 @@ void Manage::setupContent() {
showOther(type);
};
SetupTopContent(content, showFinishes());
AddDividerTextWithLottie(
content,
showFinishes(),
tr::lng_settings_cloud_password_manage_about1(
TextWithEntities::Simple),
u"cloud_password/intro"_q);
AddSkip(content);
AddButton(

View File

@ -265,6 +265,47 @@ not_null<Ui::FlatLabel*> AddSubsectionTitle(
st::settingsSubsectionTitlePadding + addPadding);
}
void AddDividerTextWithLottie(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<> showFinished,
rpl::producer<TextWithEntities> text,
const QString &lottie) {
const auto divider = Ui::CreateChild<Ui::BoxContentDivider>(parent.get());
const auto verticalLayout = parent->add(
object_ptr<Ui::VerticalLayout>(parent.get()));
auto icon = CreateLottieIcon(
verticalLayout,
{
.name = lottie,
.sizeOverride = {
st::settingsFilterIconSize,
st::settingsFilterIconSize,
},
},
st::settingsFilterIconPadding);
std::move(
showFinished
) | rpl::start_with_next([animate = std::move(icon.animate)] {
animate(anim::repeat::once);
}, verticalLayout->lifetime());
verticalLayout->add(std::move(icon.widget));
verticalLayout->add(
object_ptr<Ui::CenterWrap<>>(
verticalLayout,
object_ptr<Ui::FlatLabel>(
verticalLayout,
std::move(text),
st::settingsFilterDividerLabel)),
st::settingsFilterDividerLabelPadding);
verticalLayout->geometryValue(
) | rpl::start_with_next([=](const QRect &r) {
divider->setGeometry(r);
}, divider->lifetime());
}
LottieIcon CreateLottieIcon(
not_null<QWidget*> parent,
Lottie::IconDescriptor &&descriptor,

View File

@ -207,6 +207,11 @@ not_null<Ui::FlatLabel*> AddSubsectionTitle(
rpl::producer<QString> text,
style::margins addPadding = {},
const style::FlatLabel *st = nullptr);
void AddDividerTextWithLottie(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<> showFinished,
rpl::producer<TextWithEntities> text,
const QString &lottie);
struct LottieIcon {
object_ptr<Ui::RpWidget> widget;