Improved style of box for denied unconfirmed authentications.
This commit is contained in:
BIN
Telegram/Resources/animations/ban.tgs
Normal file
BIN
Telegram/Resources/animations/ban.tgs
Normal file
Binary file not shown.
@@ -51,6 +51,7 @@
|
||||
<file alias="show_or_premium_lastseen.tgs">../../animations/show_or_premium_lastseen.tgs</file>
|
||||
<file alias="show_or_premium_readtime.tgs">../../animations/show_or_premium_readtime.tgs</file>
|
||||
<file alias="passkeys.tgs">../../animations/passkeys.tgs</file>
|
||||
<file alias="ban.tgs">../../animations/ban.tgs</file>
|
||||
|
||||
<file alias="profile_muting.tgs">../../animations/profile/profile_muting.tgs</file>
|
||||
<file alias="profile_unmuting.tgs">../../animations/profile/profile_unmuting.tgs</file>
|
||||
|
||||
@@ -842,6 +842,9 @@ dialogsTopBarSuggestionTitleStyle: TextStyle(defaultTextStyle) {
|
||||
dialogsTopBarSuggestionAboutStyle: TextStyle(defaultTextStyle) {
|
||||
font: font(11px);
|
||||
}
|
||||
dialogsSuggestionDeniedAuthLottie: size(70px, 70px);
|
||||
dialogsSuggestionDeniedAuthLottieCircle: size(90px, 90px);
|
||||
dialogsSuggestionDeniedAuthLottieMargins: margins(10px, 10px, 10px, 10px);
|
||||
|
||||
dialogsMiniQuoteIcon: icon{{ "chat/mini_quote", dialogsTextFg }};
|
||||
|
||||
|
||||
@@ -130,21 +130,7 @@ void ShowAuthToast(
|
||||
}
|
||||
if (const auto controller = FindSessionController(parent)) {
|
||||
const auto count = float64(list.size());
|
||||
controller->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
box->setTitle(tr::lng_unconfirmed_auth_denied_title(
|
||||
lt_count,
|
||||
rpl::single(count)));
|
||||
Ui::InformBox(box, {
|
||||
.text = TextWithEntities()
|
||||
.append(messageText)
|
||||
.append('\n')
|
||||
.append(
|
||||
tr::lng_unconfirmed_auth_denied_warning(
|
||||
tr::now,
|
||||
tr::bold)),
|
||||
.confirmText = tr::lng_archive_hint_button(tr::now),
|
||||
});
|
||||
}));
|
||||
controller->show(Box(ShowAuthDeniedBox, count, messageText));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,8 +10,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/call_delayed.h"
|
||||
#include "data/data_authorization.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/rect.h"
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "ui/effects/animation_value.h"
|
||||
#include "ui/layers/generic_box.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/power_saving.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/text/format_values.h"
|
||||
#include "ui/text/text_custom_emoji.h"
|
||||
#include "ui/ui_rpl_filter.h"
|
||||
@@ -25,11 +30,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/wrap/slide_wrap.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_premium.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
@@ -156,6 +162,143 @@ not_null<Ui::SlideWrap<Ui::VerticalLayout>*> CreateUnconfirmedAuthContent(
|
||||
return wrap;
|
||||
}
|
||||
|
||||
void ShowAuthDeniedBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
float64 count,
|
||||
const QString &messageText) {
|
||||
box->setStyle(st::showOrBox);
|
||||
box->setWidth(st::boxWideWidth);
|
||||
const auto buttonPadding = QMargins(
|
||||
st::showOrBox.buttonPadding.left(),
|
||||
0,
|
||||
st::showOrBox.buttonPadding.right(),
|
||||
0);
|
||||
auto icon = Settings::CreateLottieIcon(
|
||||
box,
|
||||
{
|
||||
.name = u"ban"_q,
|
||||
.sizeOverride = st::dialogsSuggestionDeniedAuthLottie,
|
||||
},
|
||||
st::dialogsSuggestionDeniedAuthLottieMargins);
|
||||
Settings::AddLottieIconWithCircle(
|
||||
box->verticalLayout(),
|
||||
std::move(icon.widget),
|
||||
st::settingsBlockedListIconPadding,
|
||||
st::dialogsSuggestionDeniedAuthLottieCircle);
|
||||
box->setShowFinishedCallback([=, animate = std::move(icon.animate)] {
|
||||
animate(anim::repeat::once);
|
||||
});
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_unconfirmed_auth_denied_title(
|
||||
lt_count,
|
||||
rpl::single(count)),
|
||||
st::boostCenteredTitle),
|
||||
st::showOrTitlePadding + buttonPadding,
|
||||
style::al_top);
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
messageText,
|
||||
st::boostText),
|
||||
st::showOrAboutPadding + buttonPadding,
|
||||
style::al_top);
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
const auto warning = box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_unconfirmed_auth_denied_warning(tr::bold),
|
||||
st::boostText),
|
||||
st::showOrAboutPadding + buttonPadding
|
||||
+ QMargins(st::boostTextSkip, 0, st::boostTextSkip, 0),
|
||||
style::al_top);
|
||||
warning->setTextColorOverride(st::attentionButtonFg->c);
|
||||
const auto warningBg = Ui::CreateChild<Ui::RpWidget>(
|
||||
box->verticalLayout());
|
||||
warning->geometryValue() | rpl::on_next([=](QRect r) {
|
||||
warningBg->setGeometry(r + Margins(st::boostTextSkip));
|
||||
}, warningBg->lifetime());
|
||||
warningBg->paintOn([=](QPainter &p) {
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::attentionButtonBgOver);
|
||||
p.drawRoundedRect(
|
||||
warningBg->rect(),
|
||||
st::buttonRadius,
|
||||
st::buttonRadius);
|
||||
});
|
||||
warningBg->show();
|
||||
warning->raise();
|
||||
warningBg->stackUnder(warning);
|
||||
const auto confirm = box->addButton(
|
||||
object_ptr<Ui::RoundButton>(
|
||||
box,
|
||||
rpl::single(QString()),
|
||||
st::defaultActiveButton));
|
||||
confirm->setClickedCallback([=] {
|
||||
box->closeBox();
|
||||
});
|
||||
confirm->resize(
|
||||
st::showOrShowButton.width,
|
||||
st::showOrShowButton.height);
|
||||
|
||||
const auto textLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||
confirm,
|
||||
tr::lng_archive_hint_button(),
|
||||
st::defaultSubsectionTitle);
|
||||
textLabel->setTextColorOverride(st::defaultActiveButton.textFg->c);
|
||||
textLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
const auto timerLabel = Ui::CreateChild<Ui::FlatLabel>(
|
||||
confirm,
|
||||
rpl::single(QString()),
|
||||
st::defaultSubsectionTitle);
|
||||
timerLabel->setTextColorOverride(
|
||||
anim::with_alpha(st::defaultActiveButton.textFg->c, 0.75));
|
||||
timerLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
constexpr auto kTimer = 5;
|
||||
const auto remaining = confirm->lifetime().make_state<int>(kTimer);
|
||||
const auto timerLifetime
|
||||
= confirm->lifetime().make_state<rpl::lifetime>();
|
||||
const auto timer = timerLifetime->make_state<base::Timer>([=] {
|
||||
if ((*remaining) > 0) {
|
||||
timerLabel->setText(QString::number((*remaining)--));
|
||||
} else {
|
||||
timerLabel->hide();
|
||||
confirm->setAttribute(Qt::WA_TransparentForMouseEvents, false);
|
||||
box->setCloseByEscape(true);
|
||||
box->setCloseByOutsideClick(true);
|
||||
timerLifetime->destroy();
|
||||
}
|
||||
});
|
||||
box->setCloseByEscape(false);
|
||||
box->setCloseByOutsideClick(false);
|
||||
confirm->setAttribute(Qt::WA_TransparentForMouseEvents, true);
|
||||
timerLabel->setText(QString::number((*remaining)));
|
||||
timer->callEach(1000);
|
||||
|
||||
rpl::combine(
|
||||
confirm->sizeValue(),
|
||||
textLabel->sizeValue(),
|
||||
timerLabel->sizeValue(),
|
||||
timerLabel->shownValue()
|
||||
) | rpl::on_next([=](QSize btn, QSize text, QSize timer, bool shown) {
|
||||
const auto skip = st::normalFont->spacew;
|
||||
const auto totalWidth = shown
|
||||
? (text.width() + skip + timer.width())
|
||||
: text.width();
|
||||
const auto left = (btn.width() - totalWidth) / 2;
|
||||
textLabel->moveToLeft(left, (btn.height() - text.height()) / 2);
|
||||
timerLabel->moveToLeft(
|
||||
left + text.width() + skip,
|
||||
(btn.height() - timer.height()) / 2);
|
||||
}, confirm->lifetime());
|
||||
}
|
||||
|
||||
TopBarSuggestionContent::TopBarSuggestionContent(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
Fn<bool()> emojiPaused)
|
||||
|
||||
@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace Ui {
|
||||
class DynamicImage;
|
||||
class GenericBox;
|
||||
class IconButton;
|
||||
class VerticalLayout;
|
||||
template<typename Widget>
|
||||
@@ -32,6 +33,11 @@ not_null<Ui::SlideWrap<Ui::VerticalLayout>*> CreateUnconfirmedAuthContent(
|
||||
const std::vector<Data::UnreviewedAuth> &list,
|
||||
Fn<void(bool)> callback);
|
||||
|
||||
void ShowAuthDeniedBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
float64 count,
|
||||
const QString &messageText);
|
||||
|
||||
class TopBarSuggestionContent : public Ui::RippleButton {
|
||||
public:
|
||||
enum class RightIcon {
|
||||
|
||||
Reference in New Issue
Block a user