Slightly improved style of box for reporting of sponsored messages.

This commit is contained in:
23rd 2024-03-31 20:52:19 +03:00 committed by John Preston
parent 04acf08d34
commit d3cd3bb0a4
4 changed files with 52 additions and 3 deletions

View file

@ -546,6 +546,9 @@ auto SponsoredMessages::createReportCallback(const FullMsgId &fullId)
}; };
list.erase(ranges::remove_if(list, proj), end(list)); list.erase(ranges::remove_if(list, proj), end(list));
} }
if (optionId == Result::Id("1")) { // I don't like it.
return { .result = Result::FinalStep::Silence };
}
return { .result = Result::FinalStep::Reported }; return { .result = Result::FinalStep::Reported };
})); }));
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {

View file

@ -33,6 +33,7 @@ struct SponsoredReportResult final {
Hidden, Hidden,
Reported, Reported,
Premium, Premium,
Silence,
}; };
Options options; Options options;
QString title; QString title;

View file

@ -117,3 +117,8 @@ sponsoredAboutSplitIcon: icon {{ "sponsored/revenue_split", boxTextFg }};
channelEarnLearnTitleIcon: icon {{ "sponsored/large_earn", activeButtonFg }}; channelEarnLearnTitleIcon: icon {{ "sponsored/large_earn", activeButtonFg }};
channelEarnLearnChannelIcon: icon {{ "sponsored/channel", boxTextFg }}; channelEarnLearnChannelIcon: icon {{ "sponsored/channel", boxTextFg }};
channelEarnLearnWithdrawalsIcon: icon {{ "sponsored/withdrawals", boxTextFg }}; channelEarnLearnWithdrawalsIcon: icon {{ "sponsored/withdrawals", boxTextFg }};
sponsoredReportLabel: FlatLabel(defaultFlatLabel) {
style: boxTextStyle;
minWidth: 150px;
}

View file

@ -238,8 +238,42 @@ void ShowReportSponsoredBox(
const auto button = box->verticalLayout()->add( const auto button = box->verticalLayout()->add(
object_ptr<Ui::SettingsButton>( object_ptr<Ui::SettingsButton>(
box, box,
rpl::single(option.text), rpl::single(QString()),
st::settingsButtonNoIcon)); st::settingsButtonNoIcon));
const auto label = Ui::CreateChild<Ui::FlatLabel>(
button,
rpl::single(option.text),
st::sponsoredReportLabel);
const auto icon = Ui::CreateChild<Ui::RpWidget>(
button);
icon->resize(st::settingsPremiumArrow.size());
icon->paintRequest(
) | rpl::start_with_next([=, w = icon->width()] {
auto p = Painter(icon);
st::settingsPremiumArrow.paint(p, 0, 0, w);
}, icon->lifetime());
button->sizeValue(
) | rpl::start_with_next([=](const QSize &size) {
const auto left = button->st().padding.left();
const auto right = button->st().padding.right();
icon->moveToRight(
right,
(size.height() - icon->height()) / 2);
label->resizeToWidth(size.width()
- icon->width()
- left
- st::settingsButtonRightSkip
- right);
label->moveToLeft(
left,
(size.height() - label->height()) / 2);
button->resize(
button->width(),
rect::m::sum::v(button->st().padding)
+ label->height());
}, button->lifetime());
label->setAttribute(Qt::WA_TransparentForMouseEvents);
icon->setAttribute(Qt::WA_TransparentForMouseEvents);
button->setClickedCallback([=] { button->setClickedCallback([=] {
repeatRequest(repeatRequest, option.id); repeatRequest(repeatRequest, option.id);
}); });
@ -268,9 +302,12 @@ void ShowReportSponsoredBox(
[=] { show->hideLayer(); }); [=] { show->hideLayer(); });
})); }));
} else { } else {
constexpr auto kToastDuration = crl::time(4000);
switch (result.result) { switch (result.result) {
case Data::SponsoredReportResult::FinalStep::Hidden: { case Data::SponsoredReportResult::FinalStep::Hidden: {
show->showToast(tr::lng_report_sponsored_hidden(tr::now)); show->showToast(
tr::lng_report_sponsored_hidden(tr::now),
kToastDuration);
} break; } break;
case Data::SponsoredReportResult::FinalStep::Reported: { case Data::SponsoredReportResult::FinalStep::Reported: {
auto text = tr::lng_report_sponsored_reported( auto text = tr::lng_report_sponsored_reported(
@ -278,7 +315,10 @@ void ShowReportSponsoredBox(
lt_link, lt_link,
guideLink, guideLink,
Ui::Text::WithEntities); Ui::Text::WithEntities);
show->showToast({ .text = std::move(text) }); show->showToast({
.text = std::move(text),
.duration = kToastDuration,
});
} break; } break;
case Data::SponsoredReportResult::FinalStep::Premium: { case Data::SponsoredReportResult::FinalStep::Premium: {
ShowPremiumPreviewBox(show, PremiumFeature::NoAds); ShowPremiumPreviewBox(show, PremiumFeature::NoAds);