mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Proof-of-concept last seen hidden.
This commit is contained in:
@@ -55,6 +55,7 @@ constexpr auto kToggleStickerTimeout = 2 * crl::time(1000);
|
||||
constexpr auto kStarOpacityOff = 0.1;
|
||||
constexpr auto kStarOpacityOn = 1.;
|
||||
constexpr auto kStarPeriod = 3 * crl::time(1000);
|
||||
constexpr auto kShowOrLineOpacity = 0.3;
|
||||
|
||||
using Data::ReactionId;
|
||||
|
||||
@@ -1315,6 +1316,200 @@ void PremiumUnavailableBox(not_null<Ui::GenericBox*> box) {
|
||||
});
|
||||
}
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> MakeShowOrPremiumIcon(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
not_null<const style::icon*> icon) {
|
||||
const auto margin = st::showOrIconMargin;
|
||||
const auto padding = st::showOrIconPadding;
|
||||
const auto inner = padding.top() + icon->height() + padding.bottom();
|
||||
const auto full = margin.top() + inner + margin.bottom();
|
||||
auto result = object_ptr<Ui::FixedHeightWidget>(parent, full);
|
||||
const auto raw = result.data();
|
||||
|
||||
raw->resize(st::boxWideWidth, full);
|
||||
raw->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(raw);
|
||||
auto hq = PainterHighQualityEnabler(p);
|
||||
const auto width = raw->width();
|
||||
const auto position = QPoint((width - inner) / 2, margin.top());
|
||||
const auto rect = QRect(position, QSize(inner, inner));
|
||||
const auto shift = QPoint(padding.left(), padding.top());
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(st::showOrIconBg);
|
||||
p.drawEllipse(rect);
|
||||
icon->paint(p, position + shift, width);
|
||||
}, raw->lifetime());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> MakeShowOrLabel(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
rpl::producer<QString> text) {
|
||||
auto result = object_ptr<Ui::FlatLabel>(
|
||||
parent,
|
||||
std::move(text),
|
||||
st::showOrLabel);
|
||||
const auto raw = result.data();
|
||||
|
||||
raw->paintRequest(
|
||||
) | rpl::start_with_next([=] {
|
||||
auto p = QPainter(raw);
|
||||
|
||||
const auto full = st::showOrLineWidth;
|
||||
const auto left = (raw->width() - full) / 2;
|
||||
const auto text = raw->textMaxWidth() + 2 * st::showOrLabelSkip;
|
||||
const auto fill = (full - text) / 2;
|
||||
const auto stroke = st::lineWidth;
|
||||
const auto top = st::showOrLineTop;
|
||||
p.setOpacity(kShowOrLineOpacity);
|
||||
p.fillRect(left, top, fill, stroke, st::windowSubTextFg);
|
||||
const auto start = left + full - fill;
|
||||
p.fillRect(start, top, fill, stroke, st::windowSubTextFg);
|
||||
}, raw->lifetime());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ShowOrPremiumBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
ShowOrPremium type,
|
||||
QString shortName,
|
||||
Fn<void()> justShow,
|
||||
Fn<void()> toPremium) {
|
||||
struct Skin {
|
||||
rpl::producer<QString> showTitle;
|
||||
rpl::producer<TextWithEntities> showAbout;
|
||||
rpl::producer<QString> showButton;
|
||||
rpl::producer<QString> orPremium;
|
||||
rpl::producer<QString> premiumTitle;
|
||||
rpl::producer<TextWithEntities> premiumAbout;
|
||||
rpl::producer<QString> premiumButton;
|
||||
QString toast;
|
||||
const style::icon *icon = nullptr;
|
||||
};
|
||||
auto skin = (type == ShowOrPremium::LastSeen)
|
||||
? Skin{
|
||||
tr::lng_lastseen_show_title(),
|
||||
tr::lng_lastseen_show_about(
|
||||
lt_user,
|
||||
rpl::single(TextWithEntities{ shortName }),
|
||||
Ui::Text::RichLangValue),
|
||||
tr::lng_lastseen_show_button(),
|
||||
tr::lng_lastseen_or(),
|
||||
tr::lng_lastseen_premium_title(),
|
||||
tr::lng_lastseen_premium_about(
|
||||
lt_user,
|
||||
rpl::single(TextWithEntities{ shortName }),
|
||||
Ui::Text::RichLangValue),
|
||||
tr::lng_lastseen_premium_button(),
|
||||
tr::lng_lastseen_shown_toast(tr::now),
|
||||
&st::showOrIconLastSeen,
|
||||
}
|
||||
: (type == ShowOrPremium::ReadTime)
|
||||
? Skin{
|
||||
tr::lng_readtime_show_title(),
|
||||
tr::lng_readtime_show_about(
|
||||
lt_user,
|
||||
rpl::single(TextWithEntities{ shortName }),
|
||||
Ui::Text::RichLangValue),
|
||||
tr::lng_readtime_show_button(),
|
||||
tr::lng_readtime_or(),
|
||||
tr::lng_readtime_premium_title(),
|
||||
tr::lng_readtime_premium_about(
|
||||
lt_user,
|
||||
rpl::single(TextWithEntities{ shortName }),
|
||||
Ui::Text::RichLangValue),
|
||||
tr::lng_readtime_premium_button(),
|
||||
tr::lng_readtime_shown_toast(tr::now),
|
||||
&st::showOrIconReadTime,
|
||||
}
|
||||
: Skin();
|
||||
|
||||
box->setStyle(st::showOrBox);
|
||||
box->setWidth(st::boxWideWidth);
|
||||
box->addTopButton(st::boxTitleClose, [=] {
|
||||
box->closeBox();
|
||||
});
|
||||
|
||||
box->addRow(MakeShowOrPremiumIcon(box, skin.icon));
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
std::move(skin.showTitle),
|
||||
st::boostCenteredTitle),
|
||||
st::showOrTitlePadding);
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
std::move(skin.showAbout),
|
||||
st::boostText),
|
||||
st::showOrAboutPadding);
|
||||
const auto show = box->addRow(
|
||||
object_ptr<Ui::RoundButton>(
|
||||
box,
|
||||
std::move(skin.showButton),
|
||||
st::showOrShowButton),
|
||||
QMargins(
|
||||
st::showOrBox.buttonPadding.left(),
|
||||
0,
|
||||
st::showOrBox.buttonPadding.right(),
|
||||
0));
|
||||
show->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
||||
box->addRow(
|
||||
MakeShowOrLabel(box, std::move(skin.orPremium)),
|
||||
st::showOrLabelPadding);
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
std::move(skin.premiumTitle),
|
||||
st::boostCenteredTitle),
|
||||
st::showOrTitlePadding);
|
||||
box->addRow(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
std::move(skin.premiumAbout),
|
||||
st::boostText),
|
||||
st::showOrPremiumAboutPadding);
|
||||
|
||||
const auto premium = Ui::CreateChild<Ui::GradientButton>(
|
||||
box.get(),
|
||||
Ui::Premium::ButtonGradientStops());
|
||||
|
||||
const auto &st = st::premiumPreviewBox.button;
|
||||
premium->resize(st::showOrShowButton.width, st::showOrShowButton.height);
|
||||
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
premium,
|
||||
std::move(skin.premiumButton),
|
||||
st::premiumPreviewButtonLabel);
|
||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
rpl::combine(
|
||||
premium->widthValue(),
|
||||
label->widthValue()
|
||||
) | rpl::start_with_next([=](int outer, int width) {
|
||||
label->moveToLeft(
|
||||
(outer - width) / 2,
|
||||
st::premiumPreviewBox.button.textTop,
|
||||
outer);
|
||||
}, label->lifetime());
|
||||
|
||||
box->setShowFinishedCallback([=] {
|
||||
premium->startGlareAnimation();
|
||||
});
|
||||
|
||||
box->addButton(
|
||||
object_ptr<Ui::AbstractButton>::fromRaw(premium));
|
||||
|
||||
show->setClickedCallback([box, justShow, toast = skin.toast] {
|
||||
justShow();
|
||||
box->uiShow()->showToast(toast);
|
||||
box->closeBox();
|
||||
});
|
||||
premium->setClickedCallback(std::move(toPremium));
|
||||
}
|
||||
|
||||
void DoubledLimitsPreviewBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Main::Session*> session) {
|
||||
|
@@ -83,6 +83,17 @@ void ShowPremiumPreviewToBuy(
|
||||
|
||||
void PremiumUnavailableBox(not_null<Ui::GenericBox*> box);
|
||||
|
||||
enum class ShowOrPremium : uchar {
|
||||
LastSeen,
|
||||
ReadTime,
|
||||
};
|
||||
void ShowOrPremiumBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
ShowOrPremium type,
|
||||
QString shortName,
|
||||
Fn<void()> justShow,
|
||||
Fn<void()> toPremium);
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::GradientButton> CreateUnlockButton(
|
||||
QWidget *parent,
|
||||
rpl::producer<QString> text);
|
||||
|
Reference in New Issue
Block a user