mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Closed beta 10019014: New input fields design and animations.
This commit is contained in:
@@ -51,7 +51,7 @@ introCoverTitle: FlatLabel(defaultFlatLabel) {
|
||||
textFg: introTitleFg;
|
||||
align: align(center);
|
||||
}
|
||||
introCoverTitleTop: 126px;
|
||||
introCoverTitleTop: 136px;
|
||||
introCoverDescription: FlatLabel(defaultFlatLabel) {
|
||||
font: font(15px);
|
||||
textFg: introDescriptionFg;
|
||||
@@ -60,12 +60,12 @@ introCoverDescription: FlatLabel(defaultFlatLabel) {
|
||||
introCoverDescriptionTextStyle: TextStyle(defaultTextStyle) {
|
||||
lineHeight: 24px;
|
||||
}
|
||||
introCoverDescriptionTop: 164px;
|
||||
introCoverDescriptionTop: 174px;
|
||||
introTitle: FlatLabel(defaultFlatLabel) {
|
||||
font: font(17px semibold);
|
||||
textFg: introTitleFg;
|
||||
}
|
||||
introTitleTop: 11px;
|
||||
introTitleTop: 1px;
|
||||
introDescription: FlatLabel(defaultFlatLabel) {
|
||||
font: normalFont;
|
||||
textFg: introDescriptionFg;
|
||||
@@ -73,18 +73,18 @@ introDescription: FlatLabel(defaultFlatLabel) {
|
||||
introDescriptionTextStyle: TextStyle(defaultTextStyle) {
|
||||
lineHeight: 20px;
|
||||
}
|
||||
introDescriptionTop: 44px;
|
||||
introDescriptionTop: 34px;
|
||||
|
||||
introLink: defaultLinkButton;
|
||||
|
||||
introPlaneWidth: 48px;
|
||||
introPlaneHeight: 38px;
|
||||
introHeight: 396px;
|
||||
introStepTopMin: 86px;
|
||||
introHeight: 406px;
|
||||
introStepTopMin: 76px;
|
||||
introStepWidth: 380px;
|
||||
introStepHeight: 256px;
|
||||
introStepHeight: 266px;
|
||||
introStepHeightAdd: 30px;
|
||||
introStepHeightFull: 580px;
|
||||
introStepHeightFull: 590px;
|
||||
introSlideDuration: 200;
|
||||
introCoverDuration: 300;
|
||||
|
||||
@@ -96,30 +96,28 @@ introNextButton: RoundButton(defaultActiveButton) {
|
||||
font: font(17px semibold);
|
||||
}
|
||||
|
||||
introStepFieldTop: 116px;
|
||||
introPhoneTop: 16px;
|
||||
introLinkTop: 21px;
|
||||
introStepFieldTop: 96px;
|
||||
introPhoneTop: 6px;
|
||||
introLinkTop: 24px;
|
||||
introCountry: InputField(defaultInputField) {
|
||||
textMargins: margins(3px, 7px, 3px, 6px);
|
||||
textMargins: margins(3px, 27px, 3px, 6px);
|
||||
font: font(16px);
|
||||
width: 300px;
|
||||
height: 41px;
|
||||
heightMin: 61px;
|
||||
}
|
||||
introCountryCode: InputField(introCountry) {
|
||||
width: 64px;
|
||||
height: 41px;
|
||||
textAlign: align(top);
|
||||
}
|
||||
introPhone: InputField(introCountry) {
|
||||
textMargins: margins(12px, 7px, 12px, 6px);
|
||||
textMargins: margins(12px, 27px, 12px, 6px);
|
||||
width: 225px;
|
||||
height: 41px;
|
||||
}
|
||||
introCode: introCountry;
|
||||
introName: introCountry;
|
||||
introPassword: introCountry;
|
||||
introPasswordTop: 94px;
|
||||
introPasswordHintTop: 146px;
|
||||
introPasswordTop: 74px;
|
||||
introPasswordHintTop: 151px;
|
||||
|
||||
introPasswordHint: FlatLabel(introDescription) {
|
||||
textFg: windowFg;
|
||||
@@ -138,12 +136,12 @@ introResetButton: RoundButton(defaultLightButton) {
|
||||
introResetBottom: 20px;
|
||||
|
||||
introCountryIcon: icon {{ "intro_country_dropdown", menuIconFg }};
|
||||
introCountryIconPosition: point(8px, 17px);
|
||||
introCountryIconPosition: point(8px, 37px);
|
||||
|
||||
introSelectDelta: 30px;
|
||||
|
||||
introErrorTop: 225px;
|
||||
introErrorBelowLinkTop: 213px;
|
||||
introErrorTop: 235px;
|
||||
introErrorBelowLinkTop: 220px;
|
||||
introErrorDuration: 200;
|
||||
|
||||
introError: introDescription;
|
||||
|
@@ -71,7 +71,7 @@ void CodeInput::correctValue(const QString &was, int wasCursor, QString &now, in
|
||||
if (newText != now) {
|
||||
now = newText;
|
||||
setText(now);
|
||||
updatePlaceholder();
|
||||
startPlaceholderAnimation();
|
||||
}
|
||||
if (newPos != nowCursor) {
|
||||
nowCursor = newPos;
|
||||
@@ -176,7 +176,6 @@ void CodeWidget::finished() {
|
||||
cancelled();
|
||||
_sentCode.clear();
|
||||
_code->setText(QString());
|
||||
_code->setDisabled(false);
|
||||
}
|
||||
|
||||
void CodeWidget::cancelled() {
|
||||
@@ -190,18 +189,14 @@ void CodeWidget::stopCheck() {
|
||||
}
|
||||
|
||||
void CodeWidget::onCheckRequest() {
|
||||
int32 status = MTP::state(_sentRequest);
|
||||
auto status = MTP::state(_sentRequest);
|
||||
if (status < 0) {
|
||||
int32 leftms = -status;
|
||||
auto leftms = -status;
|
||||
if (leftms >= 1000) {
|
||||
if (_sentRequest) {
|
||||
MTP::cancel(base::take(_sentRequest));
|
||||
_sentCode.clear();
|
||||
}
|
||||
if (!_code->isEnabled()) {
|
||||
_code->setDisabled(false);
|
||||
_code->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_sentRequest && status == MTP::RequestSent) {
|
||||
@@ -212,7 +207,6 @@ void CodeWidget::onCheckRequest() {
|
||||
void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) {
|
||||
stopCheck();
|
||||
_sentRequest = 0;
|
||||
_code->setDisabled(false);
|
||||
auto &d = result.c_auth_authorization();
|
||||
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
||||
showCodeError(lang(lng_server_error));
|
||||
@@ -226,7 +220,6 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
|
||||
if (MTP::isFloodError(error)) {
|
||||
stopCheck();
|
||||
_sentRequest = 0;
|
||||
_code->setDisabled(false);
|
||||
showCodeError(lang(lng_flood_error));
|
||||
return true;
|
||||
}
|
||||
@@ -234,8 +227,7 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
|
||||
|
||||
stopCheck();
|
||||
_sentRequest = 0;
|
||||
_code->setDisabled(false);
|
||||
const QString &err = error.type();
|
||||
auto &err = error.type();
|
||||
if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED")) { // show error
|
||||
goBack();
|
||||
return true;
|
||||
@@ -248,7 +240,6 @@ bool CodeWidget::codeSubmitFail(const RPCError &error) {
|
||||
return true;
|
||||
} else if (err == qstr("SESSION_PASSWORD_NEEDED")) {
|
||||
getData()->code = _sentCode;
|
||||
_code->setDisabled(false);
|
||||
_checkRequest->start(1000);
|
||||
_sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&CodeWidget::gotPassword), rpcFail(&CodeWidget::codeSubmitFail));
|
||||
return true;
|
||||
@@ -298,7 +289,6 @@ void CodeWidget::callDone(const MTPauth_SentCode &v) {
|
||||
void CodeWidget::gotPassword(const MTPaccount_Password &result) {
|
||||
stopCheck();
|
||||
_sentRequest = 0;
|
||||
_code->setDisabled(false);
|
||||
switch (result.type()) {
|
||||
case mtpc_account_noPassword: { // should not happen
|
||||
_code->setFocus();
|
||||
@@ -317,9 +307,6 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) {
|
||||
void CodeWidget::submit() {
|
||||
if (_sentRequest) return;
|
||||
|
||||
_code->setDisabled(true);
|
||||
setFocus();
|
||||
|
||||
hideError();
|
||||
|
||||
_checkRequest->start(1000);
|
||||
|
@@ -114,20 +114,6 @@ void PhoneWidget::onInputChange() {
|
||||
hidePhoneError();
|
||||
}
|
||||
|
||||
void PhoneWidget::disableAll() {
|
||||
_phone->setDisabled(true);
|
||||
_country->setDisabled(true);
|
||||
_code->setDisabled(true);
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void PhoneWidget::enableAll(bool failed) {
|
||||
_phone->setDisabled(false);
|
||||
_country->setDisabled(false);
|
||||
_code->setDisabled(false);
|
||||
if (failed) _phone->setFocus();
|
||||
}
|
||||
|
||||
void PhoneWidget::submit() {
|
||||
if (_sentRequest || isHidden()) return;
|
||||
|
||||
@@ -137,7 +123,6 @@ void PhoneWidget::submit() {
|
||||
return;
|
||||
}
|
||||
|
||||
disableAll();
|
||||
hidePhoneError();
|
||||
|
||||
_checkRequest->start(1000);
|
||||
@@ -151,12 +136,11 @@ void PhoneWidget::stopCheck() {
|
||||
}
|
||||
|
||||
void PhoneWidget::onCheckRequest() {
|
||||
int32 status = MTP::state(_sentRequest);
|
||||
auto status = MTP::state(_sentRequest);
|
||||
if (status < 0) {
|
||||
int32 leftms = -status;
|
||||
auto leftms = -status;
|
||||
if (leftms >= 1000) {
|
||||
MTP::cancel(base::take(_sentRequest));
|
||||
if (!_phone->isEnabled()) enableAll(true);
|
||||
}
|
||||
}
|
||||
if (!_sentRequest && status == MTP::RequestSent) {
|
||||
@@ -169,7 +153,6 @@ void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) {
|
||||
|
||||
auto &d = result.c_auth_checkedPhone();
|
||||
if (mtpIsTrue(d.vphone_registered)) {
|
||||
disableAll();
|
||||
hidePhoneError();
|
||||
|
||||
_checkRequest->start(1000);
|
||||
@@ -178,7 +161,6 @@ void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) {
|
||||
_sentRequest = MTP::send(MTPauth_SendCode(MTP_flags(flags), MTP_string(_sentPhone), MTPBool(), MTP_int(ApiId), MTP_string(ApiHash)), rpcDone(&PhoneWidget::phoneSubmitDone), rpcFail(&PhoneWidget::phoneSubmitFail));
|
||||
} else {
|
||||
showSignup();
|
||||
enableAll(true);
|
||||
_sentRequest = 0;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +168,6 @@ void PhoneWidget::phoneCheckDone(const MTPauth_CheckedPhone &result) {
|
||||
void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
|
||||
stopCheck();
|
||||
_sentRequest = 0;
|
||||
enableAll(true);
|
||||
|
||||
if (result.type() != mtpc_auth_sentCode) {
|
||||
showPhoneError(lang(lng_server_error));
|
||||
@@ -209,7 +190,6 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
|
||||
}
|
||||
|
||||
void PhoneWidget::toSignUp() {
|
||||
disableAll();
|
||||
hideError(); // Hide error, but leave the signup label visible.
|
||||
|
||||
_checkRequest->start(1000);
|
||||
@@ -223,17 +203,15 @@ bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
|
||||
stopCheck();
|
||||
_sentRequest = 0;
|
||||
showPhoneError(lang(lng_flood_error));
|
||||
enableAll(true);
|
||||
return true;
|
||||
}
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
stopCheck();
|
||||
_sentRequest = 0;
|
||||
const QString &err = error.type();
|
||||
auto &err = error.type();
|
||||
if (err == qstr("PHONE_NUMBER_INVALID")) { // show error
|
||||
showPhoneError(lang(lng_bad_phone));
|
||||
enableAll(true);
|
||||
return true;
|
||||
}
|
||||
if (cDebug()) { // internal server error
|
||||
@@ -241,7 +219,6 @@ bool PhoneWidget::phoneSubmitFail(const RPCError &error) {
|
||||
} else {
|
||||
showPhoneError(lang(lng_server_error));
|
||||
}
|
||||
enableAll(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -271,7 +248,6 @@ void PhoneWidget::finished() {
|
||||
rpcClear();
|
||||
|
||||
cancelled();
|
||||
enableAll(true);
|
||||
}
|
||||
|
||||
void PhoneWidget::cancelled() {
|
||||
|
@@ -68,8 +68,6 @@ private:
|
||||
void toSignUp();
|
||||
|
||||
QString fullNumber() const;
|
||||
void disableAll();
|
||||
void enableAll(bool failed);
|
||||
void stopCheck();
|
||||
|
||||
void showPhoneError(const QString &text);
|
||||
|
@@ -102,16 +102,11 @@ void PwdCheckWidget::stopCheck() {
|
||||
}
|
||||
|
||||
void PwdCheckWidget::onCheckRequest() {
|
||||
int32 status = MTP::state(_sentRequest);
|
||||
auto status = MTP::state(_sentRequest);
|
||||
if (status < 0) {
|
||||
int32 leftms = -status;
|
||||
auto leftms = -status;
|
||||
if (leftms >= 1000) {
|
||||
MTP::cancel(base::take(_sentRequest));
|
||||
if (!_pwdField->isEnabled()) {
|
||||
_pwdField->setDisabled(false);
|
||||
_codeField->setDisabled(false);
|
||||
activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_sentRequest && status == MTP::RequestSent) {
|
||||
@@ -125,8 +120,6 @@ void PwdCheckWidget::pwdSubmitDone(bool recover, const MTPauth_Authorization &re
|
||||
if (recover) {
|
||||
cSetPasswordRecovered(true);
|
||||
}
|
||||
_pwdField->setDisabled(false);
|
||||
_codeField->setDisabled(false);
|
||||
auto &d = result.c_auth_authorization();
|
||||
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
||||
showError(lang(lng_server_error));
|
||||
@@ -139,9 +132,7 @@ bool PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
|
||||
if (MTP::isFloodError(error)) {
|
||||
_sentRequest = 0;
|
||||
stopCheck();
|
||||
_codeField->setDisabled(false);
|
||||
showError(lang(lng_flood_error));
|
||||
_pwdField->setDisabled(false);
|
||||
_pwdField->showError();
|
||||
return true;
|
||||
}
|
||||
@@ -149,9 +140,7 @@ bool PwdCheckWidget::pwdSubmitFail(const RPCError &error) {
|
||||
|
||||
_sentRequest = 0;
|
||||
stopCheck();
|
||||
_pwdField->setDisabled(false);
|
||||
_codeField->setDisabled(false);
|
||||
const QString &err = error.type();
|
||||
auto &err = error.type();
|
||||
if (err == qstr("PASSWORD_HASH_INVALID")) {
|
||||
showError(lang(lng_signin_bad_password));
|
||||
_pwdField->selectAll();
|
||||
@@ -179,8 +168,6 @@ bool PwdCheckWidget::codeSubmitFail(const RPCError &error) {
|
||||
|
||||
_sentRequest = 0;
|
||||
stopCheck();
|
||||
_pwdField->setDisabled(false);
|
||||
_codeField->setDisabled(false);
|
||||
const QString &err = error.type();
|
||||
if (err == qstr("PASSWORD_EMPTY")) {
|
||||
goBack();
|
||||
@@ -214,8 +201,6 @@ void PwdCheckWidget::recoverStarted(const MTPauth_PasswordRecovery &result) {
|
||||
|
||||
bool PwdCheckWidget::recoverStartFail(const RPCError &error) {
|
||||
stopCheck();
|
||||
_pwdField->setDisabled(false);
|
||||
_codeField->setDisabled(false);
|
||||
_pwdField->show();
|
||||
_pwdHint->show();
|
||||
_codeField->hide();
|
||||
@@ -283,7 +268,6 @@ void PwdCheckWidget::onInputChange() {
|
||||
void PwdCheckWidget::submit() {
|
||||
if (_sentRequest) return;
|
||||
if (_pwdField->isHidden()) {
|
||||
if (!_codeField->isEnabled()) return;
|
||||
auto code = _codeField->getLastText().trimmed();
|
||||
if (code.isEmpty()) {
|
||||
_codeField->showError();
|
||||
@@ -292,11 +276,6 @@ void PwdCheckWidget::submit() {
|
||||
|
||||
_sentRequest = MTP::send(MTPauth_RecoverPassword(MTP_string(code)), rpcDone(&PwdCheckWidget::pwdSubmitDone, true), rpcFail(&PwdCheckWidget::codeSubmitFail));
|
||||
} else {
|
||||
if (!_pwdField->isEnabled()) return;
|
||||
|
||||
_pwdField->setDisabled(true);
|
||||
setFocus();
|
||||
|
||||
hideError();
|
||||
|
||||
QByteArray pwdData = _salt + _pwdField->getLastText().toUtf8() + _salt, pwdHash(32, Qt::Uninitialized);
|
||||
|
@@ -42,13 +42,11 @@ SignupWidget::SignupWidget(QWidget *parent, Widget::Data *data) : Step(parent, d
|
||||
, _checkRequest(this) {
|
||||
connect(_checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest()));
|
||||
|
||||
_photo->setClickedCallback([this] {
|
||||
App::CallDelayed(st::defaultActiveButton.ripple.hideDuration, base::lambda_guarded(this, [this] {
|
||||
auto imgExtensions = cImgExtensions();
|
||||
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
|
||||
_readPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter);
|
||||
}));
|
||||
});
|
||||
_photo->setClickedCallback(App::LambdaDelayed(st::defaultActiveButton.ripple.hideDuration, this, [this] {
|
||||
auto imgExtensions = cImgExtensions();
|
||||
auto filter = qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;") + filedialogAllFilesFilter();
|
||||
_readPhotoFileQueryId = FileDialog::queryReadFile(lang(lng_choose_image), filter);
|
||||
}));
|
||||
subscribe(FileDialog::QueryDone(), [this](const FileDialog::QueryUpdate &update) {
|
||||
notifyFileQueryUpdated(update);
|
||||
});
|
||||
@@ -96,7 +94,7 @@ void SignupWidget::resizeEvent(QResizeEvent *e) {
|
||||
_photo->moveToLeft(photoRight - _photo->width(), photoTop);
|
||||
|
||||
auto firstTop = contentTop() + st::introStepFieldTop;
|
||||
auto secondTop = firstTop + st::introName.height + st::introPhoneTop;
|
||||
auto secondTop = firstTop + st::introName.heightMin + st::introPhoneTop;
|
||||
if (_invertOrder) {
|
||||
_last->moveToLeft(contentLeft(), firstTop);
|
||||
_first->moveToLeft(contentLeft(), secondTop);
|
||||
@@ -131,20 +129,11 @@ void SignupWidget::stopCheck() {
|
||||
}
|
||||
|
||||
void SignupWidget::onCheckRequest() {
|
||||
int32 status = MTP::state(_sentRequest);
|
||||
auto status = MTP::state(_sentRequest);
|
||||
if (status < 0) {
|
||||
int32 leftms = -status;
|
||||
auto leftms = -status;
|
||||
if (leftms >= 1000) {
|
||||
MTP::cancel(base::take(_sentRequest));
|
||||
if (!_first->isEnabled()) {
|
||||
_first->setDisabled(false);
|
||||
_last->setDisabled(false);
|
||||
if (_invertOrder) {
|
||||
_first->setFocus();
|
||||
} else {
|
||||
_last->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_sentRequest && status == MTP::RequestSent) {
|
||||
@@ -159,9 +148,7 @@ void SignupWidget::onPhotoReady(const QImage &img) {
|
||||
|
||||
void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
|
||||
stopCheck();
|
||||
_first->setDisabled(false);
|
||||
_last->setDisabled(false);
|
||||
const auto &d(result.c_auth_authorization());
|
||||
auto &d = result.c_auth_authorization();
|
||||
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
|
||||
showError(lang(lng_server_error));
|
||||
return;
|
||||
@@ -172,8 +159,6 @@ void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
|
||||
bool SignupWidget::nameSubmitFail(const RPCError &error) {
|
||||
if (MTP::isFloodError(error)) {
|
||||
stopCheck();
|
||||
_first->setDisabled(false);
|
||||
_last->setDisabled(false);
|
||||
showError(lang(lng_flood_error));
|
||||
if (_invertOrder) {
|
||||
_first->setFocus();
|
||||
@@ -185,9 +170,7 @@ bool SignupWidget::nameSubmitFail(const RPCError &error) {
|
||||
if (MTP::isDefaultHandledError(error)) return false;
|
||||
|
||||
stopCheck();
|
||||
_first->setDisabled(false);
|
||||
_last->setDisabled(false);
|
||||
const QString &err = error.type();
|
||||
auto &err = error.type();
|
||||
if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED") ||
|
||||
err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID") ||
|
||||
err == qstr("PHONE_NUMBER_OCCUPIED")) {
|
||||
@@ -220,6 +203,7 @@ void SignupWidget::onInputChange() {
|
||||
}
|
||||
|
||||
void SignupWidget::submit() {
|
||||
if (_sentRequest) return;
|
||||
if (_invertOrder) {
|
||||
if ((_last->hasFocus() || _last->getLastText().trimmed().length()) && !_first->getLastText().trimmed().length()) {
|
||||
_first->setFocus();
|
||||
@@ -237,11 +221,6 @@ void SignupWidget::submit() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!_first->isEnabled()) return;
|
||||
|
||||
_first->setDisabled(true);
|
||||
_last->setDisabled(true);
|
||||
setFocus();
|
||||
|
||||
showError(QString());
|
||||
|
||||
|
Reference in New Issue
Block a user