Added ability to sing up and sing in with anonymous numbers.

This commit is contained in:
23rd 2022-12-28 21:41:38 +03:00
parent 8748265b00
commit aa1117a714
12 changed files with 109 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -323,6 +323,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_intro_qr_step3" = "Scan this image to Log In"; "lng_intro_qr_step3" = "Scan this image to Log In";
"lng_intro_qr_skip" = "Or log in using your phone number"; "lng_intro_qr_skip" = "Or log in using your phone number";
"lng_intro_fragment_title" = "Enter code";
"lng_intro_fragment_about" = "Get the code for {phone_number} in the Anonymous Numbers section on Fragment.";
"lng_intro_fragment_button" = "Open Fragment";
"lng_phone_title" = "Your Phone Number"; "lng_phone_title" = "Your Phone Number";
"lng_phone_desc" = "Please confirm your country code and\nenter your mobile phone number."; "lng_phone_desc" = "Please confirm your country code and\nenter your mobile phone number.";
"lng_phone_to_qr" = "Quick log in using QR code"; "lng_phone_to_qr" = "Quick log in using QR code";

View file

@ -293,6 +293,13 @@ membersAbout: FlatLabel(defaultFlatLabel) {
style: boxLabelStyle; style: boxLabelStyle;
} }
fragmentBoxButton: RoundButton(introNextButton) {
width: 256px;
icon: icon {{ "fragment", activeButtonFg }};
iconOver: icon {{ "fragment", activeButtonFgOver }};
iconPosition: point(-10px, 9px);
}
passcodeHeaderFont: font(19px); passcodeHeaderFont: font(19px);
passcodeHeaderHeight: 80px; passcodeHeaderHeight: 80px;
passcodeInput: InputField(introPhone) { passcodeInput: InputField(introPhone) {

View file

@ -85,6 +85,7 @@ introCoverDuration: 200;
introNextButton: RoundButton(defaultActiveButton) { introNextButton: RoundButton(defaultActiveButton) {
width: 300px; width: 300px;
height: 42px; height: 42px;
radius: 6px;
textTop: 11px; textTop: 11px;
font: font(boxFontSize semibold); font: font(boxFontSize semibold);
} }

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "intro/intro_signup.h" #include "intro/intro_signup.h"
#include "intro/intro_password_check.h" #include "intro/intro_password_check.h"
#include "core/file_utilities.h"
#include "core/update_checker.h" #include "core/update_checker.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
@ -19,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_account.h" #include "main/main_account.h"
#include "mtproto/mtp_instance.h" #include "mtproto/mtp_instance.h"
#include "styles/style_intro.h" #include "styles/style_intro.h"
#include "styles/style_boxes.h"
namespace Intro { namespace Intro {
namespace details { namespace details {
@ -99,7 +101,9 @@ CodeWidget::CodeWidget(
_code->setDigitsCountMax(getData()->codeLength); _code->setDigitsCountMax(getData()->codeLength);
setTitleText(rpl::single(Ui::FormatPhone(getData()->phone))); setTitleText(getData()->codeByFragmentUrl.isEmpty()
? rpl::single(Ui::FormatPhone(getData()->phone))
: tr::lng_intro_fragment_title());
updateDescText(); updateDescText();
} }
@ -117,10 +121,19 @@ int CodeWidget::errorTop() const {
void CodeWidget::updateDescText() { void CodeWidget::updateDescText() {
const auto byTelegram = getData()->codeByTelegram; const auto byTelegram = getData()->codeByTelegram;
const auto isFragment = !getData()->codeByFragmentUrl.isEmpty();
setDescriptionText( setDescriptionText(
(byTelegram ? tr::lng_code_from_telegram : tr::lng_code_desc)( isFragment
Ui::Text::RichLangValue)); ? tr::lng_intro_fragment_about(
if (getData()->codeByTelegram) { lt_phone_number,
rpl::single(TextWithEntities{
.text = Ui::FormatPhone(getData()->phone)
}),
Ui::Text::RichLangValue)
: (byTelegram ? tr::lng_code_from_telegram : tr::lng_code_desc)(
Ui::Text::RichLangValue));
if (isFragment) {
} else if (getData()->codeByTelegram) {
_noTelegramCode->show(); _noTelegramCode->show();
_callTimer.cancel(); _callTimer.cancel();
} else { } else {
@ -300,7 +313,7 @@ void CodeWidget::codeSubmitFail(const MTP::Error &error) {
void CodeWidget::codeChanged() { void CodeWidget::codeChanged() {
hideError(); hideError();
submit(); submitCode();
} }
void CodeWidget::sendCall() { void CodeWidget::sendCall() {
@ -362,6 +375,14 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) {
} }
void CodeWidget::submit() { void CodeWidget::submit() {
if (getData()->codeByFragmentUrl.isEmpty()) {
submitCode();
} else {
File::OpenUrl(getData()->codeByFragmentUrl);
}
}
void CodeWidget::submitCode() {
const auto text = QString( const auto text = QString(
_code->getLastText() _code->getLastText()
).remove( ).remove(
@ -393,6 +414,18 @@ void CodeWidget::submit() {
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
rpl::producer<QString> CodeWidget::nextButtonText() const {
return getData()->codeByFragmentUrl.isEmpty()
? Step::nextButtonText()
: tr::lng_intro_fragment_button();
}
const style::RoundButton *CodeWidget::nextButtonStyle() const {
return !getData()->codeByFragmentUrl.isEmpty()
? &st::fragmentBoxButton
: nullptr;
}
void CodeWidget::noTelegramCode() { void CodeWidget::noTelegramCode() {
if (_noTelegramCodeRequestId) { if (_noTelegramCodeRequestId) {
return; return;

View file

@ -55,6 +55,8 @@ public:
void finished() override; void finished() override;
void cancelled() override; void cancelled() override;
void submit() override; void submit() override;
rpl::producer<QString> nextButtonText() const override;
const style::RoundButton *nextButtonStyle() const override;
void updateDescText(); void updateDescText();
@ -83,6 +85,8 @@ private:
void noTelegramCodeDone(const MTPauth_SentCode &result); void noTelegramCodeDone(const MTPauth_SentCode &result);
void noTelegramCodeFail(const MTP::Error &result); void noTelegramCodeFail(const MTP::Error &result);
void submitCode();
void stopCheck(); void stopCheck();
object_ptr<Ui::LinkButton> _noTelegramCode; object_ptr<Ui::LinkButton> _noTelegramCode;

View file

@ -119,6 +119,10 @@ rpl::producer<QString> Step::nextButtonText() const {
return tr::lng_intro_next(); return tr::lng_intro_next();
} }
const style::RoundButton *Step::nextButtonStyle() const {
return nullptr;
}
void Step::goBack() { void Step::goBack() {
if (_goCallback) { if (_goCallback) {
_goCallback(nullptr, StackAction::Back, Animate::Back); _goCallback(nullptr, StackAction::Back, Animate::Back);

View file

@ -12,6 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
namespace style {
struct RoundButton;
} // namespace style;
namespace Main { namespace Main {
class Account; class Account;
} // namespace Main; } // namespace Main;
@ -77,6 +81,7 @@ public:
virtual void submit() = 0; virtual void submit() = 0;
[[nodiscard]] virtual rpl::producer<QString> nextButtonText() const; [[nodiscard]] virtual rpl::producer<QString> nextButtonText() const;
[[nodiscard]] virtual const style::RoundButton *nextButtonStyle() const;
[[nodiscard]] int contentLeft() const; [[nodiscard]] int contentLeft() const;
[[nodiscard]] int contentTop() const; [[nodiscard]] int contentTop() const;

View file

@ -74,6 +74,7 @@ Widget::Widget(
: RpWidget(parent) : RpWidget(parent)
, _account(account) , _account(account)
, _data(details::Data{ .controller = controller }) , _data(details::Data{ .controller = controller })
, _nextStyle(&st::introNextButton)
, _back(this, object_ptr<Ui::IconButton>(this, st::introBackButton)) , _back(this, object_ptr<Ui::IconButton>(this, st::introBackButton))
, _settings( , _settings(
this, this,
@ -83,7 +84,7 @@ Widget::Widget(
st::defaultBoxButton)) st::defaultBoxButton))
, _next( , _next(
this, this,
object_ptr<Ui::RoundButton>(this, nullptr, st::introNextButton)) object_ptr<Ui::RoundButton>(this, nullptr, *_nextStyle))
, _connecting(std::make_unique<Window::ConnectionState>( , _connecting(std::make_unique<Window::ConnectionState>(
this, this,
account, account,
@ -127,10 +128,6 @@ Widget::Widget(
_back->entity()->setClickedCallback([=] { backRequested(); }); _back->entity()->setClickedCallback([=] { backRequested(); });
_back->hide(anim::type::instant); _back->hide(anim::type::instant);
_next->entity()->setClickedCallback([=] { getStep()->submit(); });
_next->entity()->setTextTransform(
Ui::RoundButton::TextTransform::NoTransform);
if (_changeLanguage) { if (_changeLanguage) {
_changeLanguage->finishAnimating(); _changeLanguage->finishAnimating();
} }
@ -344,13 +341,31 @@ void Widget::historyMove(StackAction action, Animate animate) {
if (_terms) { if (_terms) {
hideAndDestroy(std::exchange(_terms, { nullptr })); hideAndDestroy(std::exchange(_terms, { nullptr }));
} }
{
const auto st = getStep()->nextButtonStyle();
const auto nextStyle = st ? st : &st::introNextButton;
if (_nextStyle != nextStyle) {
_nextStyle = nextStyle;
_next = nullptr;
_next.create(
this,
object_ptr<Ui::RoundButton>(this, nullptr, *nextStyle));
showControls();
updateControlsGeometry();
}
}
getStep()->finishInit(); getStep()->finishInit();
getStep()->prepareShowAnimated(wasStep); getStep()->prepareShowAnimated(wasStep);
if (wasStep->hasCover() != getStep()->hasCover()) { if (wasStep->hasCover() != getStep()->hasCover()) {
_nextTopFrom = wasStep->contentTop() + st::introNextTop; _nextTopFrom = wasStep->contentTop() + st::introNextTop;
_controlsTopFrom = wasStep->hasCover() ? st::introCoverHeight : 0; _controlsTopFrom = wasStep->hasCover() ? st::introCoverHeight : 0;
_coverShownAnimation.start([this] { updateControlsGeometry(); }, 0., 1., st::introCoverDuration, wasStep->hasCover() ? anim::linear : anim::easeOutCirc); _coverShownAnimation.start(
[this] { updateControlsGeometry(); },
0.,
1.,
st::introCoverDuration,
wasStep->hasCover() ? anim::linear : anim::easeOutCirc);
} }
_stepLifetime.destroy(); _stepLifetime.destroy();
@ -665,6 +680,10 @@ void Widget::showControls() {
} }
void Widget::setupNextButton() { void Widget::setupNextButton() {
_next->entity()->setClickedCallback([=] { getStep()->submit(); });
_next->entity()->setTextTransform(
Ui::RoundButton::TextTransform::NoTransform);
_next->entity()->setText(getStep()->nextButtonText( _next->entity()->setText(getStep()->nextButtonText(
) | rpl::filter([](const QString &text) { ) | rpl::filter([](const QString &text) {
return !text.isEmpty(); return !text.isEmpty();
@ -757,13 +776,18 @@ void Widget::resizeEvent(QResizeEvent *e) {
} }
void Widget::updateControlsGeometry() { void Widget::updateControlsGeometry() {
auto shown = _coverShownAnimation.value(1.); const auto skip = st::introSettingsSkip;
const auto shown = _coverShownAnimation.value(1.);
auto controlsTopTo = getStep()->hasCover() ? st::introCoverHeight : 0; const auto controlsTop = anim::interpolate(
auto controlsTop = anim::interpolate(_controlsTopFrom, controlsTopTo, shown); _controlsTopFrom,
_settings->moveToRight(st::introSettingsSkip, controlsTop + st::introSettingsSkip); getStep()->hasCover() ? st::introCoverHeight : 0,
shown);
_settings->moveToRight(skip, controlsTop + skip);
if (_update) { if (_update) {
_update->moveToRight(st::introSettingsSkip + _settings->width() + st::introSettingsSkip, _settings->y()); _update->moveToRight(
skip + _settings->width() + skip,
_settings->y());
} }
_back->moveToLeft(0, controlsTop); _back->moveToLeft(0, controlsTop);
@ -779,13 +803,19 @@ void Widget::updateControlsGeometry() {
? QRect(0, 0, width(), realNextTop) ? QRect(0, 0, width(), realNextTop)
: QRect()); : QRect());
if (_changeLanguage) { if (_changeLanguage) {
_changeLanguage->moveToLeft((width() - _changeLanguage->width()) / 2, _next->y() + _next->height() + _changeLanguage->height()); _changeLanguage->moveToLeft(
(width() - _changeLanguage->width()) / 2,
_next->y() + _next->height() + _changeLanguage->height());
} }
if (_resetAccount) { if (_resetAccount) {
_resetAccount->moveToLeft((width() - _resetAccount->width()) / 2, height() - st::introResetBottom - _resetAccount->height()); _resetAccount->moveToLeft(
(width() - _resetAccount->width()) / 2,
height() - st::introResetBottom - _resetAccount->height());
} }
if (_terms) { if (_terms) {
_terms->moveToLeft((width() - _terms->width()) / 2, height() - st::introTermsBottom - _terms->height()); _terms->moveToLeft(
(width() - _terms->width()) / 2,
height() - st::introTermsBottom - _terms->height());
} }
} }

View file

@ -186,6 +186,8 @@ private:
int _nextTopFrom = 0; int _nextTopFrom = 0;
int _controlsTopFrom = 0; int _controlsTopFrom = 0;
const style::RoundButton *_nextStyle = nullptr;
object_ptr<Ui::FadeWrap<Ui::IconButton>> _back; object_ptr<Ui::FadeWrap<Ui::IconButton>> _back;
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _update = { nullptr }; object_ptr<Ui::FadeWrap<Ui::RoundButton>> _update = { nullptr };
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _settings; object_ptr<Ui::FadeWrap<Ui::RoundButton>> _settings;