mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added support of suggestion to validate phone number to settings.
This commit is contained in:
parent
b64db54793
commit
a00d262773
2 changed files with 105 additions and 0 deletions
|
@ -836,6 +836,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_disconnect" = "Disconnect";
|
"lng_settings_disconnect" = "Disconnect";
|
||||||
"lng_settings_connected_title" = "Connected websites";
|
"lng_settings_connected_title" = "Connected websites";
|
||||||
|
|
||||||
|
"lng_settings_suggestion_phone_number_title" = "Is {phone} still your number?";
|
||||||
|
"lng_settings_suggestion_phone_number_about" = "Keep your number up to date to ensure you can always log into Telegram. {link}";
|
||||||
|
"lng_settings_suggestion_phone_number_about_link" = "https://telegram.org/faq#q-i-have-a-new-phone-number-what-do-i-do";
|
||||||
|
"lng_settings_suggestion_phone_number_change" = "Please change your phone number in the official Telegram app on your phone as soon as possible.";
|
||||||
|
|
||||||
"lng_settings_power_menu" = "Battery and Animations";
|
"lng_settings_power_menu" = "Battery and Animations";
|
||||||
"lng_settings_power_title" = "Power Usage";
|
"lng_settings_power_title" = "Power Usage";
|
||||||
"lng_settings_power_subtitle" = "Power saving options";
|
"lng_settings_power_subtitle" = "Power saving options";
|
||||||
|
|
|
@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/menu/menu_add_action_callback.h"
|
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||||
#include "ui/widgets/continuous_sliders.h"
|
#include "ui/widgets/continuous_sliders.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/new_badges.h"
|
#include "ui/new_badges.h"
|
||||||
|
@ -44,12 +45,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/profile/info_profile_badge.h"
|
#include "info/profile/info_profile_badge.h"
|
||||||
#include "info/profile/info_profile_emoji_status_panel.h"
|
#include "info/profile/info_profile_emoji_status_panel.h"
|
||||||
#include "data/components/credits.h"
|
#include "data/components/credits.h"
|
||||||
|
#include "data/components/promo_suggestions.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_cloud_themes.h"
|
#include "data/data_cloud_themes.h"
|
||||||
#include "data/data_chat_filters.h"
|
#include "data/data_chat_filters.h"
|
||||||
#include "lang/lang_cloud_manager.h"
|
#include "lang/lang_cloud_manager.h"
|
||||||
#include "lang/lang_instance.h"
|
#include "lang/lang_instance.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
|
@ -69,6 +72,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
#include "styles/style_layers.h" // boxLabel
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
|
@ -78,6 +82,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Settings {
|
namespace Settings {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kSugValidatePhone = "VALIDATE_PHONE_NUMBER"_cs;
|
||||||
|
|
||||||
class Cover final : public Ui::FixedHeightWidget {
|
class Cover final : public Ui::FixedHeightWidget {
|
||||||
public:
|
public:
|
||||||
Cover(
|
Cover(
|
||||||
|
@ -397,6 +403,95 @@ void SetupLanguageButton(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupValidatePhoneNumberSuggestion(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
Fn<void(Type)> showOther) {
|
||||||
|
if (!controller->session().promoSuggestions().current(
|
||||||
|
kSugValidatePhone.utf8())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto mainWrap = container->add(
|
||||||
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
container,
|
||||||
|
object_ptr<Ui::VerticalLayout>(container)));
|
||||||
|
const auto content = mainWrap->entity();
|
||||||
|
Ui::AddSubsectionTitle(
|
||||||
|
content,
|
||||||
|
tr::lng_settings_suggestion_phone_number_title(
|
||||||
|
lt_phone,
|
||||||
|
rpl::single(
|
||||||
|
Ui::FormatPhone(controller->session().user()->phone()))),
|
||||||
|
QMargins(
|
||||||
|
st::boxRowPadding.left()
|
||||||
|
- st::defaultSubsectionTitlePadding.left(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0));
|
||||||
|
const auto label = content->add(
|
||||||
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
content,
|
||||||
|
tr::lng_settings_suggestion_phone_number_about(
|
||||||
|
lt_link,
|
||||||
|
tr::lng_collectible_learn_more(
|
||||||
|
) | Ui::Text::ToLink(
|
||||||
|
tr::lng_settings_suggestion_phone_number_about_link(
|
||||||
|
tr::now)),
|
||||||
|
Ui::Text::WithEntities),
|
||||||
|
st::boxLabel),
|
||||||
|
st::boxRowPadding);
|
||||||
|
label->setClickHandlerFilter([=, weak = base::make_weak(controller)](
|
||||||
|
const auto &...) {
|
||||||
|
UrlClickHandler::Open(
|
||||||
|
tr::lng_settings_suggestion_phone_number_about_link(tr::now),
|
||||||
|
QVariant::fromValue(ClickHandlerContext{
|
||||||
|
.sessionWindow = weak,
|
||||||
|
}));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
|
||||||
|
const auto wrap = content->add(
|
||||||
|
object_ptr<Ui::FixedHeightWidget>(
|
||||||
|
content,
|
||||||
|
st::inviteLinkButton.height),
|
||||||
|
st::inviteLinkButtonsPadding);
|
||||||
|
const auto yes = Ui::CreateChild<Ui::RoundButton>(
|
||||||
|
wrap,
|
||||||
|
tr::lng_box_yes(),
|
||||||
|
st::inviteLinkButton);
|
||||||
|
yes->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
||||||
|
yes->setClickedCallback([=] {
|
||||||
|
controller->session().promoSuggestions().dismiss(
|
||||||
|
kSugValidatePhone.utf8());
|
||||||
|
mainWrap->toggle(false, anim::type::normal);
|
||||||
|
});
|
||||||
|
const auto no = Ui::CreateChild<Ui::RoundButton>(
|
||||||
|
wrap,
|
||||||
|
tr::lng_box_no(),
|
||||||
|
st::inviteLinkButton);
|
||||||
|
no->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
||||||
|
no->setClickedCallback([=] {
|
||||||
|
controller->uiShow()->show(
|
||||||
|
Ui::MakeInformBox(
|
||||||
|
tr::lng_settings_suggestion_phone_number_change()));
|
||||||
|
});
|
||||||
|
|
||||||
|
wrap->widthValue() | rpl::start_with_next([=](int width) {
|
||||||
|
const auto buttonWidth = (width - st::inviteLinkButtonsSkip) / 2;
|
||||||
|
yes->setFullWidth(buttonWidth);
|
||||||
|
no->setFullWidth(buttonWidth);
|
||||||
|
yes->moveToLeft(0, 0, width);
|
||||||
|
no->moveToRight(0, 0, width);
|
||||||
|
}, wrap->lifetime());
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
Ui::AddDivider(content);
|
||||||
|
Ui::AddSkip(content);
|
||||||
|
}
|
||||||
|
|
||||||
void SetupSections(
|
void SetupSections(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
@ -404,6 +499,11 @@ void SetupSections(
|
||||||
Ui::AddDivider(container);
|
Ui::AddDivider(container);
|
||||||
Ui::AddSkip(container);
|
Ui::AddSkip(container);
|
||||||
|
|
||||||
|
SetupValidatePhoneNumberSuggestion(
|
||||||
|
controller,
|
||||||
|
container,
|
||||||
|
showOther);
|
||||||
|
|
||||||
const auto addSection = [&](
|
const auto addSection = [&](
|
||||||
rpl::producer<QString> label,
|
rpl::producer<QString> label,
|
||||||
Type type,
|
Type type,
|
||||||
|
|
Loading…
Add table
Reference in a new issue