mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved creation of link button in cloud password settings to common file.
This commit is contained in:
parent
3ef352b63c
commit
4d5cb6398e
5 changed files with 40 additions and 31 deletions
|
@ -166,6 +166,26 @@ not_null<Ui::CenterWrap<Ui::InputField>*> AddWrappedField(
|
||||||
text)));
|
text)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<Ui::LinkButton*> AddLinkButton(
|
||||||
|
not_null<Ui::CenterWrap<Ui::InputField>*> wrap,
|
||||||
|
rpl::producer<QString> &&text) {
|
||||||
|
const auto button = Ui::CreateChild<Ui::LinkButton>(
|
||||||
|
wrap->parentWidget(),
|
||||||
|
QString());
|
||||||
|
std::move(
|
||||||
|
text
|
||||||
|
) | rpl::start_with_next([=](const QString &text) {
|
||||||
|
button->setText(text);
|
||||||
|
}, button->lifetime());
|
||||||
|
|
||||||
|
wrap->geometryValue(
|
||||||
|
) | rpl::start_with_next([=](QRect r) {
|
||||||
|
r.translate(wrap->entity()->pos().x(), 0);
|
||||||
|
button->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
||||||
|
}, button->lifetime());
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
not_null<Ui::FlatLabel*> AddError(
|
not_null<Ui::FlatLabel*> AddError(
|
||||||
not_null<Ui::VerticalLayout*> content,
|
not_null<Ui::VerticalLayout*> content,
|
||||||
Ui::PasswordInput *input) {
|
Ui::PasswordInput *input) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ template <typename Widget>
|
||||||
class CenterWrap;
|
class CenterWrap;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
class InputField;
|
class InputField;
|
||||||
|
class LinkButton;
|
||||||
class PasswordInput;
|
class PasswordInput;
|
||||||
class RoundButton;
|
class RoundButton;
|
||||||
class VerticalLayout;
|
class VerticalLayout;
|
||||||
|
@ -60,6 +61,10 @@ void SetupHeader(
|
||||||
not_null<Ui::VerticalLayout*> content,
|
not_null<Ui::VerticalLayout*> content,
|
||||||
rpl::producer<QString> &&text);
|
rpl::producer<QString> &&text);
|
||||||
|
|
||||||
|
[[nodiscard]] not_null<Ui::LinkButton*> AddLinkButton(
|
||||||
|
not_null<Ui::CenterWrap<Ui::InputField>*> wrap,
|
||||||
|
rpl::producer<QString> &&text);
|
||||||
|
|
||||||
void AddSkipInsteadOfField(not_null<Ui::VerticalLayout*> content);
|
void AddSkipInsteadOfField(not_null<Ui::VerticalLayout*> content);
|
||||||
void AddSkipInsteadOfError(not_null<Ui::VerticalLayout*> content);
|
void AddSkipInsteadOfError(not_null<Ui::VerticalLayout*> content);
|
||||||
|
|
||||||
|
|
|
@ -132,14 +132,9 @@ void Email::setupContent() {
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto skip = Ui::CreateChild<Ui::LinkButton>(
|
const auto skip = AddLinkButton(
|
||||||
this,
|
wrap,
|
||||||
tr::lng_cloud_password_skip_email(tr::now));
|
tr::lng_cloud_password_skip_email());
|
||||||
wrap->geometryValue(
|
|
||||||
) | rpl::start_with_next([=](QRect r) {
|
|
||||||
r.translate(wrap->entity()->pos().x(), 0);
|
|
||||||
skip->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
|
||||||
}, skip->lifetime());
|
|
||||||
skip->setClickedCallback([=] {
|
skip->setClickedCallback([=] {
|
||||||
confirm(QString());
|
confirm(QString());
|
||||||
});
|
});
|
||||||
|
|
|
@ -96,14 +96,15 @@ void EmailConfirm::setupContent() {
|
||||||
|
|
||||||
AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
|
AddSkip(content, st::settingLocalPasscodeDescriptionBottomSkip);
|
||||||
|
|
||||||
|
auto objectInput = object_ptr<Ui::SentCodeField>(
|
||||||
|
content,
|
||||||
|
st::settingLocalPasscodeInputField,
|
||||||
|
tr::lng_change_phone_code_title());
|
||||||
|
const auto newInput = objectInput.data();
|
||||||
const auto wrap = content->add(
|
const auto wrap = content->add(
|
||||||
object_ptr<Ui::CenterWrap<Ui::SentCodeField>>(
|
object_ptr<Ui::CenterWrap<Ui::InputField>>(
|
||||||
content,
|
content,
|
||||||
object_ptr<Ui::SentCodeField>(
|
std::move(objectInput)));
|
||||||
content,
|
|
||||||
st::settingLocalPasscodeInputField,
|
|
||||||
tr::lng_change_phone_code_title())));
|
|
||||||
const auto newInput = wrap->entity();
|
|
||||||
|
|
||||||
const auto error = AddError(content, nullptr);
|
const auto error = AddError(content, nullptr);
|
||||||
QObject::connect(newInput, &Ui::InputField::changed, [=] {
|
QObject::connect(newInput, &Ui::InputField::changed, [=] {
|
||||||
|
@ -127,14 +128,7 @@ void EmailConfirm::setupContent() {
|
||||||
}
|
}
|
||||||
}, resendInfo->lifetime());
|
}, resendInfo->lifetime());
|
||||||
|
|
||||||
const auto resend = Ui::CreateChild<Ui::LinkButton>(
|
const auto resend = AddLinkButton(wrap, tr::lng_cloud_password_resend());
|
||||||
this,
|
|
||||||
tr::lng_cloud_password_resend(tr::now));
|
|
||||||
wrap->geometryValue(
|
|
||||||
) | rpl::start_with_next([=](QRect r) {
|
|
||||||
r.translate(wrap->entity()->pos().x(), 0);
|
|
||||||
resend->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
|
||||||
}, resend->lifetime());
|
|
||||||
resend->setClickedCallback([=] {
|
resend->setClickedCallback([=] {
|
||||||
if (_requestLifetime) {
|
if (_requestLifetime) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -67,15 +67,10 @@ void Hint::setupContent() {
|
||||||
showOther(CloudPasswordEmailId());
|
showOther(CloudPasswordEmailId());
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto skip = Ui::CreateChild<Ui::LinkButton>(
|
AddLinkButton(
|
||||||
this,
|
wrap,
|
||||||
tr::lng_settings_cloud_password_skip_hint(tr::now));
|
tr::lng_settings_cloud_password_skip_hint()
|
||||||
wrap->geometryValue(
|
)->setClickedCallback([=] {
|
||||||
) | rpl::start_with_next([=](QRect r) {
|
|
||||||
r.translate(wrap->entity()->pos().x(), 0);
|
|
||||||
skip->moveToLeft(r.x(), r.y() + r.height() + st::passcodeTextLine);
|
|
||||||
}, skip->lifetime());
|
|
||||||
skip->setClickedCallback([=] {
|
|
||||||
save(QString());
|
save(QString());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue