Show gifts inside media view in stories.

This commit is contained in:
John Preston 2025-01-07 20:47:43 +04:00
parent 51213b499f
commit 37d32b32f8
17 changed files with 299 additions and 175 deletions

View file

@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h" #include "mainwidget.h"
#include "payments/payments_checkout_process.h" #include "payments/payments_checkout_process.h"
#include "payments/payments_form.h" #include "payments/payments_form.h"
#include "settings/settings_credits_graphics.h"
#include "settings/settings_premium.h" #include "settings/settings_premium.h"
#include "ui/basic_click_handlers.h" // UrlClickHandler::Open. #include "ui/basic_click_handlers.h" // UrlClickHandler::Open.
#include "ui/boxes/boost_box.h" // StartFireworks. #include "ui/boxes/boost_box.h" // StartFireworks.
@ -128,12 +129,12 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000);
} }
[[nodiscard]] object_ptr<Ui::RpWidget> MakePeerTableValue( [[nodiscard]] object_ptr<Ui::RpWidget> MakePeerTableValue(
not_null<QWidget*> parent, not_null<Ui::TableLayout*> table,
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
PeerId id, PeerId id,
rpl::producer<QString> button = nullptr, rpl::producer<QString> button = nullptr,
Fn<void()> handler = nullptr) { Fn<void()> handler = nullptr) {
auto result = object_ptr<Ui::AbstractButton>(parent); auto result = object_ptr<Ui::AbstractButton>(table);
const auto raw = result.data(); const auto raw = result.data();
const auto &st = st::giveawayGiftCodeUserpic; const auto &st = st::giveawayGiftCodeUserpic;
@ -144,12 +145,12 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000);
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
raw, raw,
(button && handler) ? peer->shortName() : peer->name(), (button && handler) ? peer->shortName() : peer->name(),
st::giveawayGiftCodeValue); table->st().defaultValue);
const auto send = (button && handler) const auto send = (button && handler)
? Ui::CreateChild<Ui::RoundButton>( ? Ui::CreateChild<Ui::RoundButton>(
raw, raw,
std::move(button), std::move(button),
st::starGiftSmallButton) table->st().smallButton)
: nullptr; : nullptr;
if (send) { if (send) {
send->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); send->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
@ -171,8 +172,8 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000);
send->moveToLeft( send->moveToLeft(
position.x() + label->width() + st::normalFont->spacew, position.x() + label->width() + st::normalFont->spacew,
(position.y() (position.y()
+ st::giveawayGiftCodeValue.style.font->ascent + table->st().defaultValue.style.font->ascent
- st::starGiftSmallButton.style.font->ascent), - table->st().smallButton.style.font->ascent),
width); width);
} }
}, label->lifetime()); }, label->lifetime());
@ -189,8 +190,8 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000);
} }
[[nodiscard]] object_ptr<Ui::RpWidget> MakeHiddenPeerTableValue( [[nodiscard]] object_ptr<Ui::RpWidget> MakeHiddenPeerTableValue(
not_null<QWidget*> parent) { not_null<Ui::TableLayout*> table) {
auto result = object_ptr<Ui::RpWidget>(parent); auto result = object_ptr<Ui::RpWidget>(table);
const auto raw = result.data(); const auto raw = result.data();
const auto &st = st::giveawayGiftCodeUserpic; const auto &st = st::giveawayGiftCodeUserpic;
@ -207,7 +208,7 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000);
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
raw, raw,
tr::lng_gift_from_hidden(), tr::lng_gift_from_hidden(),
st::giveawayGiftCodeValue); table->st().defaultValue);
raw->widthValue( raw->widthValue(
) | rpl::start_with_next([=](int width) { ) | rpl::start_with_next([=](int width) {
const auto position = st::giveawayGiftCodeNamePosition; const auto position = st::giveawayGiftCodeNamePosition;
@ -234,7 +235,7 @@ void AddTableRow(
? object_ptr<Ui::FlatLabel>( ? object_ptr<Ui::FlatLabel>(
table, table,
std::move(label), std::move(label),
st::giveawayGiftCodeLabel) table->st().defaultLabel)
: object_ptr<Ui::FlatLabel>(nullptr)), : object_ptr<Ui::FlatLabel>(nullptr)),
std::move(value), std::move(value),
st::giveawayGiftCodeLabelMargin, st::giveawayGiftCodeLabelMargin,
@ -242,23 +243,23 @@ void AddTableRow(
} }
[[nodiscard]] object_ptr<Ui::RpWidget> MakeAttributeValue( [[nodiscard]] object_ptr<Ui::RpWidget> MakeAttributeValue(
not_null<Ui::RpWidget*> parent, not_null<Ui::TableLayout*> table,
const Data::UniqueGiftAttribute &attribute, const Data::UniqueGiftAttribute &attribute,
Fn<void(not_null<Ui::RpWidget*>, int)> showTooltip) { Fn<void(not_null<Ui::RpWidget*>, int)> showTooltip) {
auto result = object_ptr<Ui::RpWidget>(parent); auto result = object_ptr<Ui::RpWidget>(table);
const auto raw = result.data(); const auto raw = result.data();
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
raw, raw,
attribute.name, attribute.name,
st::giveawayGiftCodeValue); table->st().defaultValue);
const auto permille = attribute.rarityPermille; const auto permille = attribute.rarityPermille;
const auto text = QString::number(permille / 10.) + '%'; const auto text = QString::number(permille / 10.) + '%';
const auto rarity = Ui::CreateChild<Ui::RoundButton>( const auto rarity = Ui::CreateChild<Ui::RoundButton>(
raw, raw,
rpl::single(text), rpl::single(text),
st::starGiftSmallButton); table->st().smallButton);
rarity->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); rarity->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
rpl::combine( rpl::combine(
@ -272,8 +273,8 @@ void AddTableRow(
label->moveToLeft(0, 0, width); label->moveToLeft(0, 0, width);
rarity->moveToLeft( rarity->moveToLeft(
label->width() + st::normalFont->spacew, label->width() + st::normalFont->spacew,
(st::giveawayGiftCodeValue.style.font->ascent (table->st().defaultValue.style.font->ascent
- st::starGiftSmallButton.style.font->ascent), - table->st().smallButton.style.font->ascent),
width); width);
}, label->lifetime()); }, label->lifetime());
@ -293,11 +294,11 @@ void AddTableRow(
} }
[[nodiscard]] object_ptr<Ui::RpWidget> MakeStarGiftStarsValue( [[nodiscard]] object_ptr<Ui::RpWidget> MakeStarGiftStarsValue(
not_null<QWidget*> parent, not_null<Ui::TableLayout*> table,
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
const Data::CreditsHistoryEntry &entry, const Data::CreditsHistoryEntry &entry,
Fn<void()> convertToStars) { Fn<void()> convertToStars) {
auto result = object_ptr<Ui::RpWidget>(parent); auto result = object_ptr<Ui::RpWidget>(table);
const auto raw = result.data(); const auto raw = result.data();
const auto session = &show->session(); const auto session = &show->session();
@ -312,7 +313,7 @@ void AddTableRow(
raw, raw,
rpl::single(star.append( rpl::single(star.append(
' ' + Lang::FormatStarsAmountDecimal(entry.credits))), ' ' + Lang::FormatStarsAmountDecimal(entry.credits))),
st::giveawayGiftCodeValue, table->st().defaultValue,
st::defaultPopupMenu, st::defaultPopupMenu,
std::move(makeContext)); std::move(makeContext));
@ -322,7 +323,7 @@ void AddTableRow(
tr::lng_gift_sell_small( tr::lng_gift_sell_small(
lt_count_decimal, lt_count_decimal,
rpl::single(entry.starsConverted * 1.)), rpl::single(entry.starsConverted * 1.)),
st::starGiftSmallButton) table->st().smallButton)
: nullptr; : nullptr;
if (convert) { if (convert) {
convert->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); convert->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
@ -340,8 +341,8 @@ void AddTableRow(
if (convert) { if (convert) {
convert->moveToLeft( convert->moveToLeft(
label->width() + st::normalFont->spacew, label->width() + st::normalFont->spacew,
(st::giveawayGiftCodeValue.style.font->ascent (table->st().defaultValue.style.font->ascent
- st::starGiftSmallButton.style.font->ascent), - table->st().smallButton.style.font->ascent),
width); width);
} }
}, label->lifetime()); }, label->lifetime());
@ -358,10 +359,10 @@ void AddTableRow(
} }
[[nodiscard]] object_ptr<Ui::RpWidget> MakeVisibilityTableValue( [[nodiscard]] object_ptr<Ui::RpWidget> MakeVisibilityTableValue(
not_null<QWidget*> parent, not_null<Ui::TableLayout*> table,
bool savedToProfile, bool savedToProfile,
Fn<void(bool)> toggleVisibility) { Fn<void(bool)> toggleVisibility) {
auto result = object_ptr<Ui::RpWidget>(parent); auto result = object_ptr<Ui::RpWidget>(table);
const auto raw = result.data(); const auto raw = result.data();
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
@ -369,7 +370,7 @@ void AddTableRow(
(savedToProfile (savedToProfile
? tr::lng_gift_visibility_shown() ? tr::lng_gift_visibility_shown()
: tr::lng_gift_visibility_hidden()), : tr::lng_gift_visibility_hidden()),
st::giveawayGiftCodeValue, table->st().defaultValue,
st::defaultPopupMenu); st::defaultPopupMenu);
const auto toggle = Ui::CreateChild<Ui::RoundButton>( const auto toggle = Ui::CreateChild<Ui::RoundButton>(
@ -377,7 +378,7 @@ void AddTableRow(
(savedToProfile (savedToProfile
? tr::lng_gift_visibility_hide() ? tr::lng_gift_visibility_hide()
: tr::lng_gift_visibility_show()), : tr::lng_gift_visibility_show()),
st::starGiftSmallButton); table->st().smallButton);
toggle->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); toggle->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
toggle->setClickedCallback([=] { toggle->setClickedCallback([=] {
toggleVisibility(!savedToProfile); toggleVisibility(!savedToProfile);
@ -394,8 +395,8 @@ void AddTableRow(
label->moveToLeft(0, 0, width); label->moveToLeft(0, 0, width);
toggle->moveToLeft( toggle->moveToLeft(
label->width() + st::normalFont->spacew, label->width() + st::normalFont->spacew,
(st::giveawayGiftCodeValue.style.font->ascent (table->st().defaultValue.style.font->ascent
- st::starGiftSmallButton.style.font->ascent), - table->st().smallButton.style.font->ascent),
width); width);
}, label->lifetime()); }, label->lifetime());
@ -411,21 +412,21 @@ void AddTableRow(
} }
[[nodiscard]] object_ptr<Ui::RpWidget> MakeNonUniqueStatusTableValue( [[nodiscard]] object_ptr<Ui::RpWidget> MakeNonUniqueStatusTableValue(
not_null<QWidget*> parent, not_null<Ui::TableLayout*> table,
Fn<void()> startUpgrade) { Fn<void()> startUpgrade) {
auto result = object_ptr<Ui::RpWidget>(parent); auto result = object_ptr<Ui::RpWidget>(table);
const auto raw = result.data(); const auto raw = result.data();
const auto label = Ui::CreateChild<Ui::FlatLabel>( const auto label = Ui::CreateChild<Ui::FlatLabel>(
raw, raw,
tr::lng_gift_unique_status_non(), tr::lng_gift_unique_status_non(),
st::giveawayGiftCodeValue, table->st().defaultValue,
st::defaultPopupMenu); st::defaultPopupMenu);
const auto upgrade = Ui::CreateChild<Ui::RoundButton>( const auto upgrade = Ui::CreateChild<Ui::RoundButton>(
raw, raw,
tr::lng_gift_unique_status_upgrade(), tr::lng_gift_unique_status_upgrade(),
st::starGiftSmallButton); table->st().smallButton);
upgrade->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); upgrade->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
upgrade->setClickedCallback(startUpgrade); upgrade->setClickedCallback(startUpgrade);
@ -440,8 +441,8 @@ void AddTableRow(
label->moveToLeft(0, 0, width); label->moveToLeft(0, 0, width);
upgrade->moveToLeft( upgrade->moveToLeft(
label->width() + st::normalFont->spacew, label->width() + st::normalFont->spacew,
(st::giveawayGiftCodeValue.style.font->ascent (table->st().defaultValue.style.font->ascent
- st::starGiftSmallButton.style.font->ascent), - table->st().smallButton.style.font->ascent),
width); width);
}, label->lifetime()); }, label->lifetime());
@ -464,7 +465,7 @@ not_null<Ui::FlatLabel*> AddTableRow(
auto widget = object_ptr<Ui::FlatLabel>( auto widget = object_ptr<Ui::FlatLabel>(
table, table,
std::move(value), std::move(value),
st::giveawayGiftCodeValue, table->st().defaultValue,
st::defaultPopupMenu, st::defaultPopupMenu,
std::move(makeContext)); std::move(makeContext));
const auto result = widget.data(); const auto result = widget.data();
@ -494,12 +495,13 @@ void AddTableRow(
void AddTable( void AddTable(
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
Settings::CreditsEntryBoxStyleOverrides st,
const Api::GiftCode &current, const Api::GiftCode &current,
bool skipReason) { bool skipReason) {
auto table = container->add( auto table = container->add(
object_ptr<Ui::TableLayout>( object_ptr<Ui::TableLayout>(
container, container,
st::giveawayGiftCodeTable), st.table ? *st.table : st::giveawayGiftCodeTable),
st::giveawayGiftCodeTableMargin); st::giveawayGiftCodeTableMargin);
if (current.from) { if (current.from) {
AddTableRow( AddTableRow(
@ -678,7 +680,7 @@ void GiftCodeBox(
st::giveawayGiftCodeLinkMargin); st::giveawayGiftCodeLinkMargin);
const auto show = controller->uiShow(); const auto show = controller->uiShow();
AddTable(box->verticalLayout(), show, state->data.current(), false); AddTable(box->verticalLayout(), show, {}, state->data.current(), false);
auto shareLink = tr::lng_gift_link_also_send_link( auto shareLink = tr::lng_gift_link_also_send_link(
) | rpl::map([](const QString &text) { ) | rpl::map([](const QString &text) {
@ -760,7 +762,6 @@ void GiftCodeBox(
}, button->lifetime()); }, button->lifetime());
} }
void GiftCodePendingBox( void GiftCodePendingBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
not_null<Window::SessionNavigation*> controller, not_null<Window::SessionNavigation*> controller,
@ -839,7 +840,7 @@ void GiftCodePendingBox(
} }
const auto show = controller->uiShow(); const auto show = controller->uiShow();
AddTable(box->verticalLayout(), show, data, true); AddTable(box->verticalLayout(), show, {}, data, true);
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
@ -1192,6 +1193,7 @@ void ResolveGiveawayInfo(
void AddStarGiftTable( void AddStarGiftTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::CreditsHistoryEntry &entry, const Data::CreditsHistoryEntry &entry,
Fn<void(bool)> toggleVisibility, Fn<void(bool)> toggleVisibility,
Fn<void()> convertToStars, Fn<void()> convertToStars,
@ -1199,7 +1201,7 @@ void AddStarGiftTable(
auto table = container->add( auto table = container->add(
object_ptr<Ui::TableLayout>( object_ptr<Ui::TableLayout>(
container, container,
st::giveawayGiftCodeTable), st.table ? *st.table : st::giveawayGiftCodeTable),
st::giveawayGiftCodeTableMargin); st::giveawayGiftCodeTableMargin);
const auto peerId = PeerId(entry.barePeerId); const auto peerId = PeerId(entry.barePeerId);
const auto session = &show->session(); const auto session = &show->session();
@ -1344,17 +1346,17 @@ void AddStarGiftTable(
AddTableRow( AddTableRow(
table, table,
tr::lng_gift_unique_model(), tr::lng_gift_unique_model(),
MakeAttributeValue(container, unique->model, showTooltip), MakeAttributeValue(table, unique->model, showTooltip),
marginWithButton); marginWithButton);
AddTableRow( AddTableRow(
table, table,
tr::lng_gift_unique_backdrop(), tr::lng_gift_unique_backdrop(),
MakeAttributeValue(container, unique->backdrop, showTooltip), MakeAttributeValue(table, unique->backdrop, showTooltip),
marginWithButton); marginWithButton);
AddTableRow( AddTableRow(
table, table,
tr::lng_gift_unique_symbol(), tr::lng_gift_unique_symbol(),
MakeAttributeValue(container, unique->pattern, showTooltip), MakeAttributeValue(table, unique->pattern, showTooltip),
marginWithButton); marginWithButton);
} else { } else {
AddTableRow( AddTableRow(
@ -1458,7 +1460,9 @@ void AddStarGiftTable(
lt_text, lt_text,
rpl::single(original.message), rpl::single(original.message),
Ui::Text::WithEntities))), Ui::Text::WithEntities))),
st::giveawayGiftMessage, (st.tableValueMessage
? *st.tableValueMessage
: st::giveawayGiftMessage),
st::defaultPopupMenu, st::defaultPopupMenu,
makeContext); makeContext);
const auto showBoxLink = [=](not_null<PeerData*> peer) { const auto showBoxLink = [=](not_null<PeerData*> peer) {
@ -1487,7 +1491,9 @@ void AddStarGiftTable(
auto label = object_ptr<Ui::FlatLabel>( auto label = object_ptr<Ui::FlatLabel>(
table, table,
rpl::single(entry.description), rpl::single(entry.description),
st::giveawayGiftMessage, (st.tableValueMessage
? *st.tableValueMessage
: st::giveawayGiftMessage),
st::defaultPopupMenu, st::defaultPopupMenu,
makeContext); makeContext);
label->setSelectable(true); label->setSelectable(true);
@ -1502,6 +1508,7 @@ void AddStarGiftTable(
void AddCreditsHistoryEntryTable( void AddCreditsHistoryEntryTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::CreditsHistoryEntry &entry) { const Data::CreditsHistoryEntry &entry) {
if (!entry) { if (!entry) {
return; return;
@ -1509,7 +1516,7 @@ void AddCreditsHistoryEntryTable(
auto table = container->add( auto table = container->add(
object_ptr<Ui::TableLayout>( object_ptr<Ui::TableLayout>(
container, container,
st::giveawayGiftCodeTable), st.table ? *st.table : st::giveawayGiftCodeTable),
st::giveawayGiftCodeTableMargin); st::giveawayGiftCodeTableMargin);
const auto peerId = PeerId(entry.barePeerId); const auto peerId = PeerId(entry.barePeerId);
const auto actorId = PeerId(entry.bareActorId); const auto actorId = PeerId(entry.bareActorId);
@ -1570,7 +1577,7 @@ void AddCreditsHistoryEntryTable(
auto label = object_ptr<Ui::FlatLabel>( auto label = object_ptr<Ui::FlatLabel>(
table, table,
rpl::single(Ui::Text::Link(link)), rpl::single(Ui::Text::Link(link)),
st::giveawayGiftCodeValue); table->st().defaultValue);
label->setClickHandlerFilter([=](const auto &...) { label->setClickHandlerFilter([=](const auto &...) {
if (const auto window = show->resolveWindow()) { if (const auto window = show->resolveWindow()) {
window->showPeerHistory(channel, {}, msgId); window->showPeerHistory(channel, {}, msgId);
@ -1666,9 +1673,11 @@ void AddCreditsHistoryEntryTable(
table, table,
rpl::single( rpl::single(
Ui::Text::Wrapped({ entry.id }, EntityType::Code, {})), Ui::Text::Wrapped({ entry.id }, EntityType::Code, {})),
oneLine (oneLine
? st::giveawayGiftCodeValue ? table->st().defaultValue
: st::giveawayGiftCodeValueMultiline); : st.tableValueMultiline
? *st.tableValueMultiline
: st::giveawayGiftCodeValueMultiline));
label->setClickHandlerFilter([=](const auto &...) { label->setClickHandlerFilter([=](const auto &...) {
TextUtilities::SetClipboardText( TextUtilities::SetClipboardText(
TextForMimeData::Simple(entry.id)); TextForMimeData::Simple(entry.id));
@ -1714,6 +1723,7 @@ void AddCreditsHistoryEntryTable(
void AddSubscriptionEntryTable( void AddSubscriptionEntryTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::SubscriptionEntry &s) { const Data::SubscriptionEntry &s) {
if (!s) { if (!s) {
return; return;
@ -1721,7 +1731,7 @@ void AddSubscriptionEntryTable(
auto table = container->add( auto table = container->add(
object_ptr<Ui::TableLayout>( object_ptr<Ui::TableLayout>(
container, container,
st::giveawayGiftCodeTable), st.table ? *st.table : st::giveawayGiftCodeTable),
st::giveawayGiftCodeTableMargin); st::giveawayGiftCodeTableMargin);
const auto peerId = PeerId(s.barePeerId); const auto peerId = PeerId(s.barePeerId);
const auto user = peerIsUser(peerId) const auto user = peerIsUser(peerId)
@ -1767,12 +1777,13 @@ void AddSubscriptionEntryTable(
void AddSubscriberEntryTable( void AddSubscriberEntryTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
not_null<PeerData*> peer, not_null<PeerData*> peer,
TimeId date) { TimeId date) {
auto table = container->add( auto table = container->add(
object_ptr<Ui::TableLayout>( object_ptr<Ui::TableLayout>(
container, container,
st::giveawayGiftCodeTable), st.table ? *st.table : st::giveawayGiftCodeTable),
st::giveawayGiftCodeTableMargin); st::giveawayGiftCodeTableMargin);
AddTableRow( AddTableRow(
table, table,
@ -1790,11 +1801,12 @@ void AddSubscriberEntryTable(
void AddCreditsBoostTable( void AddCreditsBoostTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::Boost &b) { const Data::Boost &b) {
auto table = container->add( auto table = container->add(
object_ptr<Ui::TableLayout>( object_ptr<Ui::TableLayout>(
container, container,
st::giveawayGiftCodeTable), st.table ? *st.table : st::giveawayGiftCodeTable),
st::giveawayGiftCodeTableMargin); st::giveawayGiftCodeTableMargin);
const auto peerId = b.giveawayMessage.peer; const auto peerId = b.giveawayMessage.peer;
if (!peerId) { if (!peerId) {

View file

@ -25,6 +25,10 @@ struct GiveawayResults;
struct SubscriptionEntry; struct SubscriptionEntry;
} // namespace Data } // namespace Data
namespace Settings {
struct CreditsEntryBoxStyleOverrides;
} // namespace Settings
namespace Ui { namespace Ui {
class GenericBox; class GenericBox;
class VerticalLayout; class VerticalLayout;
@ -61,6 +65,7 @@ void ResolveGiveawayInfo(
void AddStarGiftTable( void AddStarGiftTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::CreditsHistoryEntry &entry, const Data::CreditsHistoryEntry &entry,
Fn<void(bool)> toggleVisibility, Fn<void(bool)> toggleVisibility,
Fn<void()> convertToStars, Fn<void()> convertToStars,
@ -68,19 +73,23 @@ void AddStarGiftTable(
void AddCreditsHistoryEntryTable( void AddCreditsHistoryEntryTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::CreditsHistoryEntry &entry); const Data::CreditsHistoryEntry &entry);
void AddSubscriptionEntryTable( void AddSubscriptionEntryTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::SubscriptionEntry &s); const Data::SubscriptionEntry &s);
void AddSubscriberEntryTable( void AddSubscriberEntryTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
not_null<PeerData*> peer, not_null<PeerData*> peer,
TimeId date); TimeId date);
void AddCreditsBoostTable( void AddCreditsBoostTable(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
Settings::CreditsEntryBoxStyleOverrides st,
const Data::Boost &boost); const Data::Boost &boost);

View file

@ -1020,7 +1020,7 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
Ui::AddSkip(content); Ui::AddSkip(content);
const auto show = controller->uiShow(); const auto show = controller->uiShow();
AddSubscriberEntryTable(show, content, row->peer(), data.date); AddSubscriberEntryTable(show, content, {}, row->peer(), data.date);
Ui::AddSkip(content); Ui::AddSkip(content);
Ui::AddSkip(content); Ui::AddSkip(content);

View file

@ -53,6 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "core/application.h" #include "core/application.h"
#include "core/core_settings.h" #include "core/core_settings.h"
#include "styles/style_calls.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_menu_icons.h" #include "styles/style_menu_icons.h"
@ -197,16 +198,16 @@ ShareBox::ShareBox(QWidget*, Descriptor &&descriptor)
, _api(&_descriptor.session->mtp()) , _api(&_descriptor.session->mtp())
, _select( , _select(
this, this,
(_descriptor.stMultiSelect (_descriptor.st.multiSelect
? *_descriptor.stMultiSelect ? *_descriptor.st.multiSelect
: st::defaultMultiSelect), : st::defaultMultiSelect),
tr::lng_participant_filter()) tr::lng_participant_filter())
, _comment( , _comment(
this, this,
object_ptr<Ui::InputField>( object_ptr<Ui::InputField>(
this, this,
(_descriptor.stComment (_descriptor.st.comment
? *_descriptor.stComment ? *_descriptor.st.comment
: st::shareComment), : st::shareComment),
Ui::InputField::Mode::MultiLine, Ui::InputField::Mode::MultiLine,
tr::lng_photos_comment()), tr::lng_photos_comment()),
@ -251,7 +252,7 @@ void ShareBox::prepareCommentField() {
.session = _descriptor.session, .session = _descriptor.session,
.show = Main::MakeSessionShow(show, _descriptor.session), .show = Main::MakeSessionShow(show, _descriptor.session),
.field = field, .field = field,
.fieldStyle = _descriptor.stLabel, .fieldStyle = _descriptor.st.label,
}); });
} }
field->setSubmitSettings(Core::App().settings().sendSubmitWay()); field->setSubmitSettings(Core::App().settings().sendSubmitWay());
@ -569,7 +570,7 @@ void ShareBox::showMenu(not_null<Ui::RpWidget*> parent) {
[=](Api::SendOptions options) { submit(options); }, [=](Api::SendOptions options) { submit(options); },
action.options, action.options,
HistoryView::DefaultScheduleTime(), HistoryView::DefaultScheduleTime(),
_descriptor.scheduleBoxStyle)); *_descriptor.st.scheduleBox));
}); });
_menu->setForcedVerticalOrigin(Ui::PopupMenu::VerticalOrigin::Bottom); _menu->setForcedVerticalOrigin(Ui::PopupMenu::VerticalOrigin::Bottom);
const auto result = FillSendMenu( const auto result = FillSendMenu(
@ -704,7 +705,9 @@ ShareBox::Inner::Inner(
: RpWidget(parent) : RpWidget(parent)
, _descriptor(descriptor) , _descriptor(descriptor)
, _show(std::move(show)) , _show(std::move(show))
, _st(_descriptor.st ? *_descriptor.st : st::shareBoxList) , _st(_descriptor.st.peerList
? *_descriptor.st.peerList
: st::shareBoxList)
, _defaultChatsIndexed( , _defaultChatsIndexed(
std::make_unique<Dialogs::IndexedList>( std::make_unique<Dialogs::IndexedList>(
Dialogs::SortMode::Add)) Dialogs::SortMode::Add))
@ -1612,9 +1615,37 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
}; };
} }
ShareBoxStyleOverrides DarkShareBoxStyle() {
using namespace HistoryView;
const auto schedule = [&] {
auto date = Ui::ChooseDateTimeStyleArgs();
date.labelStyle = &st::groupCallBoxLabel;
date.dateFieldStyle = &st::groupCallScheduleDateField;
date.timeFieldStyle = &st::groupCallScheduleTimeField;
date.separatorStyle = &st::callMuteButtonLabel;
date.atStyle = &st::callMuteButtonLabel;
date.calendarStyle = &st::groupCallCalendarColors;
auto st = ScheduleBoxStyleArgs();
st.topButtonStyle = &st::groupCallMenuToggle;
st.popupMenuStyle = &st::groupCallPopupMenu;
st.chooseDateTimeArgs = std::move(date);
return st;
};
return {
.multiSelect = &st::groupCallMultiSelect,
.comment = &st::groupCallShareBoxComment,
.peerList = &st::groupCallShareBoxList,
.label = &st::groupCallField,
.scheduleBox = std::make_shared<ScheduleBoxStyleArgs>(schedule()),
};
}
void FastShareMessage( void FastShareMessage(
std::shared_ptr<Main::SessionShow> show, std::shared_ptr<Main::SessionShow> show,
not_null<HistoryItem*> item) { not_null<HistoryItem*> item,
ShareBoxStyleOverrides st) {
const auto history = item->history(); const auto history = item->history();
const auto owner = &history->owner(); const auto owner = &history->owner();
const auto session = &history->session(); const auto session = &history->session();
@ -1683,6 +1714,7 @@ void FastShareMessage(
history, history,
msgIds), msgIds),
.filterCallback = std::move(filterCallback), .filterCallback = std::move(filterCallback),
.st = st,
.forwardOptions = { .forwardOptions = {
.sendersCount = ItemsForwardSendersCount(items), .sendersCount = ItemsForwardSendersCount(items),
.captionsCount = ItemsForwardCaptionsCount(items), .captionsCount = ItemsForwardCaptionsCount(items),
@ -1694,19 +1726,22 @@ void FastShareMessage(
void FastShareMessage( void FastShareMessage(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<HistoryItem*> item) { not_null<HistoryItem*> item,
FastShareMessage(controller->uiShow(), item); ShareBoxStyleOverrides st) {
FastShareMessage(controller->uiShow(), item, st);
} }
void FastShareLink( void FastShareLink(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
const QString &url) { const QString &url,
FastShareLink(controller->uiShow(), url); ShareBoxStyleOverrides st) {
FastShareLink(controller->uiShow(), url, st);
} }
void FastShareLink( void FastShareLink(
std::shared_ptr<Main::SessionShow> show, std::shared_ptr<Main::SessionShow> show,
const QString &url) { const QString &url,
ShareBoxStyleOverrides st) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
const auto sending = std::make_shared<bool>(); const auto sending = std::make_shared<bool>();
auto copyCallback = [=] { auto copyCallback = [=] {
@ -1770,6 +1805,7 @@ void FastShareLink(
.copyCallback = std::move(copyCallback), .copyCallback = std::move(copyCallback),
.submitCallback = std::move(submitCallback), .submitCallback = std::move(submitCallback),
.filterCallback = std::move(filterCallback), .filterCallback = std::move(filterCallback),
.st = st,
.premiumRequiredError = SharePremiumRequiredError(), .premiumRequiredError = SharePremiumRequiredError(),
}), }),
Ui::LayerOption::KeepOther, Ui::LayerOption::KeepOther,

View file

@ -61,18 +61,31 @@ class PopupMenu;
class ShareBox; class ShareBox;
struct ShareBoxStyleOverrides {
const style::MultiSelect *multiSelect = nullptr;
const style::InputField *comment = nullptr;
const style::PeerList *peerList = nullptr;
const style::InputField *label = nullptr;
std::shared_ptr<HistoryView::ScheduleBoxStyleArgs> scheduleBox;
};
[[nodiscard]] ShareBoxStyleOverrides DarkShareBoxStyle();
void FastShareMessage( void FastShareMessage(
std::shared_ptr<Main::SessionShow> show, std::shared_ptr<Main::SessionShow> show,
not_null<HistoryItem*> item); not_null<HistoryItem*> item,
ShareBoxStyleOverrides st = {});
void FastShareMessage( void FastShareMessage(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<HistoryItem*> item); not_null<HistoryItem*> item,
ShareBoxStyleOverrides st = {});
void FastShareLink( void FastShareLink(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
const QString &url); const QString &url,
ShareBoxStyleOverrides st = {});
void FastShareLink( void FastShareLink(
std::shared_ptr<Main::SessionShow> show, std::shared_ptr<Main::SessionShow> show,
const QString &url); const QString &url,
ShareBoxStyleOverrides st = {});
struct RecipientPremiumRequiredError; struct RecipientPremiumRequiredError;
[[nodiscard]] auto SharePremiumRequiredError() [[nodiscard]] auto SharePremiumRequiredError()
@ -100,16 +113,12 @@ public:
FilterCallback filterCallback; FilterCallback filterCallback;
object_ptr<Ui::RpWidget> bottomWidget = { nullptr }; object_ptr<Ui::RpWidget> bottomWidget = { nullptr };
rpl::producer<QString> copyLinkText; rpl::producer<QString> copyLinkText;
const style::MultiSelect *stMultiSelect = nullptr; ShareBoxStyleOverrides st;
const style::InputField *stComment = nullptr;
const style::PeerList *st = nullptr;
const style::InputField *stLabel = nullptr;
struct { struct {
int sendersCount = 0; int sendersCount = 0;
int captionsCount = 0; int captionsCount = 0;
bool show = false; bool show = false;
} forwardOptions; } forwardOptions;
HistoryView::ScheduleBoxStyleArgs scheduleBoxStyle;
using PremiumRequiredError = RecipientPremiumRequiredError; using PremiumRequiredError = RecipientPremiumRequiredError;
Fn<PremiumRequiredError(not_null<UserData*>)> premiumRequiredError; Fn<PremiumRequiredError(not_null<UserData*>)> premiumRequiredError;

View file

@ -2345,7 +2345,7 @@ void UpgradeBox(
} }
}, box->lifetime()); }, box->lifetime());
AddUniqueCloseButton(box); AddUniqueCloseButton(box, {});
} }
const std::vector<PatternPoint> &PatternPoints() { const std::vector<PatternPoint> &PatternPoints() {
@ -2502,6 +2502,7 @@ void ShowStarGiftUpgradeBox(StarGiftUpgradeArgs &&args) {
void AddUniqueCloseButton( void AddUniqueCloseButton(
not_null<GenericBox*> box, not_null<GenericBox*> box,
Settings::CreditsEntryBoxStyleOverrides st,
Fn<void(not_null<Ui::PopupMenu*>)> fillMenu) { Fn<void(not_null<Ui::PopupMenu*>)> fillMenu) {
const auto close = Ui::CreateChild<IconButton>( const auto close = Ui::CreateChild<IconButton>(
box, box,
@ -2537,7 +2538,7 @@ void AddUniqueCloseButton(
} }
*state = base::make_unique_q<Ui::PopupMenu>( *state = base::make_unique_q<Ui::PopupMenu>(
menu, menu,
st::popupMenuWithIcons); st.menu ? *st.menu : st::popupMenuWithIcons);
fillMenu(state->get()); fillMenu(state->get());
if (!(*state)->empty()) { if (!(*state)->empty()) {
(*state)->popup(QCursor::pos()); (*state)->popup(QCursor::pos());

View file

@ -17,6 +17,10 @@ namespace Payments {
enum class CheckoutResult; enum class CheckoutResult;
} // namespace Payments } // namespace Payments
namespace Settings {
struct CreditsEntryBoxStyleOverrides;
} // namespace Settings
namespace Window { namespace Window {
class SessionController; class SessionController;
} // namespace Window } // namespace Window
@ -76,6 +80,7 @@ void ShowStarGiftUpgradeBox(StarGiftUpgradeArgs &&args);
void AddUniqueCloseButton( void AddUniqueCloseButton(
not_null<GenericBox*> box, not_null<GenericBox*> box,
Settings::CreditsEntryBoxStyleOverrides st,
Fn<void(not_null<PopupMenu*>)> fillMenu = nullptr); Fn<void(not_null<PopupMenu*>)> fillMenu = nullptr);
void RequestStarsFormAndSubmit( void RequestStarsFormAndSubmit(

View file

@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "webrtc/webrtc_audio_input_tester.h" #include "webrtc/webrtc_audio_input_tester.h"
#include "webrtc/webrtc_device_resolver.h" #include "webrtc/webrtc_device_resolver.h"
#include "settings/settings_calls.h" #include "settings/settings_calls.h"
#include "settings/settings_credits_graphics.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "api/api_invite_links.h" #include "api/api_invite_links.h"
@ -183,22 +184,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
return Data::CanSend(thread, ChatRestriction::SendOther); return Data::CanSend(thread, ChatRestriction::SendOther);
}; };
const auto scheduleStyle = [&] { const auto st = ::Settings::DarkCreditsEntryBoxStyle();
auto date = Ui::ChooseDateTimeStyleArgs();
date.labelStyle = &st::groupCallBoxLabel;
date.dateFieldStyle = &st::groupCallScheduleDateField;
date.timeFieldStyle = &st::groupCallScheduleTimeField;
date.separatorStyle = &st::callMuteButtonLabel;
date.atStyle = &st::callMuteButtonLabel;
date.calendarStyle = &st::groupCallCalendarColors;
auto st = HistoryView::ScheduleBoxStyleArgs();
st.topButtonStyle = &st::groupCallMenuToggle;
st.popupMenuStyle = &st::groupCallPopupMenu;
st.chooseDateTimeArgs = std::move(date);
return st;
};
auto result = Box<ShareBox>(ShareBox::Descriptor{ auto result = Box<ShareBox>(ShareBox::Descriptor{
.session = &peer->session(), .session = &peer->session(),
.copyCallback = std::move(copyCallback), .copyCallback = std::move(copyCallback),
@ -211,11 +197,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
: rpl::single(false)), : rpl::single(false)),
tr::lng_group_call_copy_speaker_link(), tr::lng_group_call_copy_speaker_link(),
tr::lng_group_call_copy_listener_link()), tr::lng_group_call_copy_listener_link()),
.stMultiSelect = &st::groupCallMultiSelect, .st = st.shareBox ? *st.shareBox : ShareBoxStyleOverrides(),
.stComment = &st::groupCallShareBoxComment,
.st = &st::groupCallShareBoxList,
.stLabel = &st::groupCallField,
.scheduleBoxStyle = scheduleStyle(),
.premiumRequiredError = SharePremiumRequiredError(), .premiumRequiredError = SharePremiumRequiredError(),
}); });
*box = result.data(); *box = result.data();

View file

@ -1702,7 +1702,8 @@ bool StartUrlRequiresActivate(const QString &url) {
void ResolveAndShowUniqueGift( void ResolveAndShowUniqueGift(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
const QString &slug) { const QString &slug,
::Settings::CreditsEntryBoxStyleOverrides st) {
struct Request { struct Request {
base::weak_ptr<Main::Session> weak; base::weak_ptr<Main::Session> weak;
QString slug; QString slug;
@ -1732,7 +1733,7 @@ void ResolveAndShowUniqueGift(
session->data().processUsers(data.vusers()); session->data().processUsers(data.vusers());
if (const auto gift = Api::FromTL(session, data.vgift())) { if (const auto gift = Api::FromTL(session, data.vgift())) {
using namespace ::Settings; using namespace ::Settings;
show->show(Box(GlobalStarGiftBox, show, *gift)); show->show(Box(GlobalStarGiftBox, show, *gift, st));
} }
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
clear(); clear();
@ -1740,4 +1741,10 @@ void ResolveAndShowUniqueGift(
}).send(); }).send();
} }
void ResolveAndShowUniqueGift(
std::shared_ptr<ChatHelpers::Show> show,
const QString &slug) {
ResolveAndShowUniqueGift(std::move(show), slug, {});
}
} // namespace Core } // namespace Core

View file

@ -15,6 +15,10 @@ namespace ChatHelpers {
class Show; class Show;
} // namespace ChatHelpers } // namespace ChatHelpers
namespace Settings {
struct CreditsEntryBoxStyleOverrides;
} // namespace Settings
namespace Window { namespace Window {
class SessionController; class SessionController;
} // namespace Window } // namespace Window
@ -38,6 +42,10 @@ struct LocalUrlHandler {
[[nodiscard]] bool StartUrlRequiresActivate(const QString &url); [[nodiscard]] bool StartUrlRequiresActivate(const QString &url);
void ResolveAndShowUniqueGift(
std::shared_ptr<ChatHelpers::Show> show,
const QString &slug,
::Settings::CreditsEntryBoxStyleOverrides st);
void ResolveAndShowUniqueGift( void ResolveAndShowUniqueGift(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
const QString &slug); const QString &slug);

View file

@ -983,11 +983,11 @@ void ConfirmUpdate(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
table, table,
std::move(label), std::move(label),
st::giveawayGiftCodeLabel), table->st().defaultLabel),
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
table, table,
value, value,
st::giveawayGiftCodeValue, table->st().defaultValue,
st::defaultPopupMenu), st::defaultPopupMenu),
st::giveawayGiftCodeLabelMargin, st::giveawayGiftCodeLabelMargin,
st::giveawayGiftCodeValueMargin); st::giveawayGiftCodeValueMargin);

View file

@ -78,22 +78,8 @@ giveawayGiftCodeTable: Table(defaultTable) {
labelMinWidth: 91px; labelMinWidth: 91px;
} }
giveawayGiftCodeTableMargin: margins(24px, 4px, 24px, 4px); giveawayGiftCodeTableMargin: margins(24px, 4px, 24px, 4px);
giveawayGiftCodeLabel: FlatLabel(defaultFlatLabel) {
textFg: menuIconColor;
maxHeight: 24px;
style: TextStyle(semiboldTextStyle) {
font: font(12px semibold);
}
}
giveawayGiftCodeLabelMargin: margins(13px, 10px, 13px, 10px); giveawayGiftCodeLabelMargin: margins(13px, 10px, 13px, 10px);
giveawayGiftCodeValue: FlatLabel(defaultFlatLabel) { giveawayGiftCodeValueMultiline: FlatLabel(defaultTableValue) {
maxHeight: 24px;
style: TextStyle(defaultTextStyle) {
font: font(12px);
linkUnderline: kLinkUnderlineNever;
}
}
giveawayGiftCodeValueMultiline: FlatLabel(giveawayGiftCodeValue) {
minWidth: 128px; minWidth: 128px;
maxHeight: 100px; maxHeight: 100px;
style: TextStyle(defaultTextStyle) { style: TextStyle(defaultTextStyle) {
@ -101,7 +87,7 @@ giveawayGiftCodeValueMultiline: FlatLabel(giveawayGiftCodeValue) {
linkUnderline: kLinkUnderlineNever; linkUnderline: kLinkUnderlineNever;
} }
} }
giveawayGiftMessage: FlatLabel(giveawayGiftCodeValue) { giveawayGiftMessage: FlatLabel(defaultTableValue) {
minWidth: 128px; minWidth: 128px;
maxHeight: 0px; maxHeight: 0px;
} }
@ -217,19 +203,53 @@ starConvertButtonLoading: InfiniteRadialAnimation(startGiveawayButtonLoading) {
thickness: 2px; thickness: 2px;
} }
starGiftSmallButton: RoundButton(defaultActiveButton) { starGiftSmallButton: defaultTableSmallButton;
textFg: windowActiveTextFg; darkGiftCodeBox: Box(giveawayGiftCodeBox) {
textFgOver: windowActiveTextFg; button: RoundButton(defaultActiveButton) {
textBg: lightButtonBgOver; height: 42px;
textBgOver: lightButtonBgOver; textTop: 12px;
width: -12px; style: semiboldTextStyle;
height: 18px;
radius: 9px;
textTop: 0px;
style: TextStyle(defaultTextStyle) {
font: font(12px);
} }
ripple: RippleAnimation(defaultRippleAnimation) { bg: groupCallMembersBg;
color: lightButtonBgRipple; title: FlatLabel(boxTitle) {
textFg: groupCallMembersFg;
}
titleAdditionalFg: groupCallMemberNotJoinedStatus;
}
darkGiftLink: icon {{ "menu/copy", groupCallMembersFg }};
darkGiftShare: icon {{ "menu/share", groupCallMembersFg }};
darkGiftTransfer: icon {{ "chat/input_replace", groupCallMembersFg }};
darkGiftPalette: TextPalette(defaultTextPalette) {
linkFg: mediaviewTextLinkFg;
monoFg: groupCallMembersFg;
spoilerFg: groupCallMembersFg;
}
darkGiftTable: Table(giveawayGiftCodeTable) {
headerBg: groupCallMembersBgOver;
borderFg: mediaviewMenuBgOver;
smallButton: RoundButton(defaultTableSmallButton) {
textFg: groupCallMembersFg;
textFgOver: groupCallMembersFg;
textBg: groupCallMenuBgRipple;
textBgOver: groupCallMenuBgRipple;
ripple: RippleAnimation(defaultRippleAnimation) {
color: mediaviewMenuBgOver;
}
}
defaultLabel: FlatLabel(defaultTableLabel) {
textFg: groupCallMembersFg;
palette: darkGiftPalette;
}
defaultValue: FlatLabel(defaultTableValue) {
textFg: groupCallMembersFg;
palette: darkGiftPalette;
} }
} }
darkGiftTableValueMultiline: FlatLabel(giveawayGiftCodeValueMultiline) {
textFg: groupCallMembersFg;
palette: darkGiftPalette;
}
darkGiftTableMessage: FlatLabel(giveawayGiftMessage) {
textFg: groupCallMembersFg;
palette: darkGiftPalette;
}

View file

@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/stories/media_stories_stealth.h" #include "media/stories/media_stories_stealth.h"
#include "media/stories/media_stories_view.h" #include "media/stories/media_stories_view.h"
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
#include "settings/settings_credits_graphics.h"
#include "ui/boxes/confirm_box.h" #include "ui/boxes/confirm_box.h"
#include "ui/boxes/report_box_graphics.h" #include "ui/boxes/report_box_graphics.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
@ -1959,7 +1960,10 @@ ClickHandlerPtr MakeUrlAreaHandler(
const auto slug = raw.mid( const auto slug = raw.mid(
prefix.size() prefix.size()
).split('&').front().split('#').front(); ).split('&').front().split('#').front();
Core::ResolveAndShowUniqueGift(strong->uiShow(), slug); Core::ResolveAndShowUniqueGift(
strong->uiShow(),
slug,
::Settings::DarkCreditsEntryBoxStyle());
} else { } else {
HiddenUrlClickHandler::onClick(context); HiddenUrlClickHandler::onClick(context);
} }

View file

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_context_menu.h" // CopyStoryLink. #include "history/view/history_view_context_menu.h" // CopyStoryLink.
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "settings/settings_credits_graphics.h"
#include "ui/boxes/confirm_box.h" #include "ui/boxes/confirm_box.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "styles/style_calls.h" #include "styles/style_calls.h"
@ -167,35 +168,15 @@ namespace Media::Stories {
++state->requests; ++state->requests;
} }
}; };
const auto st = viewerStyle
const auto viewerScheduleStyle = [&] { ? ::Settings::DarkCreditsEntryBoxStyle()
auto date = Ui::ChooseDateTimeStyleArgs(); : ::Settings::CreditsEntryBoxStyleOverrides();
date.labelStyle = &st::groupCallBoxLabel;
date.dateFieldStyle = &st::groupCallScheduleDateField;
date.timeFieldStyle = &st::groupCallScheduleTimeField;
date.separatorStyle = &st::callMuteButtonLabel;
date.atStyle = &st::callMuteButtonLabel;
date.calendarStyle = &st::groupCallCalendarColors;
auto st = HistoryView::ScheduleBoxStyleArgs();
st.topButtonStyle = &st::groupCallMenuToggle;
st.popupMenuStyle = &st::groupCallPopupMenu;
st.chooseDateTimeArgs = std::move(date);
return st;
};
return Box<ShareBox>(ShareBox::Descriptor{ return Box<ShareBox>(ShareBox::Descriptor{
.session = session, .session = session,
.copyCallback = std::move(copyLinkCallback), .copyCallback = std::move(copyLinkCallback),
.submitCallback = std::move(submitCallback), .submitCallback = std::move(submitCallback),
.filterCallback = std::move(filterCallback), .filterCallback = std::move(filterCallback),
.stMultiSelect = viewerStyle ? &st::groupCallMultiSelect : nullptr, .st = st.shareBox ? *st.shareBox : ShareBoxStyleOverrides(),
.stComment = viewerStyle ? &st::groupCallShareBoxComment : nullptr,
.st = viewerStyle ? &st::groupCallShareBoxList : nullptr,
.stLabel = viewerStyle ? &st::groupCallField : nullptr,
.scheduleBoxStyle = (viewerStyle
? viewerScheduleStyle()
: HistoryView::ScheduleBoxStyleArgs()),
.premiumRequiredError = SharePremiumRequiredError(), .premiumRequiredError = SharePremiumRequiredError(),
}); });
} }

View file

@ -86,12 +86,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "styles/style_calls.h"
#include "styles/style_channel_earn.h" #include "styles/style_channel_earn.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_credits.h" #include "styles/style_credits.h"
#include "styles/style_giveaway.h" #include "styles/style_giveaway.h"
#include "styles/style_info.h" #include "styles/style_info.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_media_view.h"
#include "styles/style_menu_icons.h" #include "styles/style_menu_icons.h"
#include "styles/style_premium.h" #include "styles/style_premium.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
@ -775,7 +777,7 @@ void BoostCreditsBox(
Ui::AddSkip(content); Ui::AddSkip(content);
} }
AddCreditsBoostTable(controller->uiShow(), content, b); AddCreditsBoostTable(controller->uiShow(), content, {}, b);
Ui::AddSkip(content); Ui::AddSkip(content);
box->addRow(object_ptr<Ui::CenterWrap<>>( box->addRow(object_ptr<Ui::CenterWrap<>>(
@ -826,9 +828,10 @@ void ProcessReceivedSubscriptions(
} }
void FillUniqueGiftMenu( void FillUniqueGiftMenu(
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::PopupMenu*> menu, not_null<Ui::PopupMenu*> menu,
const Data::CreditsHistoryEntry &e) { const Data::CreditsHistoryEntry &e,
CreditsEntryBoxStyleOverrides st) {
Expects(e.uniqueGift != nullptr); Expects(e.uniqueGift != nullptr);
const auto unique = e.uniqueGift; const auto unique = e.uniqueGift;
@ -837,11 +840,15 @@ void FillUniqueGiftMenu(
menu->addAction(tr::lng_context_copy_link(tr::now), [=] { menu->addAction(tr::lng_context_copy_link(tr::now), [=] {
TextUtilities::SetClipboardText({ url }); TextUtilities::SetClipboardText({ url });
show->showToast(tr::lng_channel_public_link_copied(tr::now)); show->showToast(tr::lng_channel_public_link_copied(tr::now));
}, &st::menuIconLink); }, st.link ? st.link : &st::menuIconLink);
const auto shareBoxSt = st.shareBox;
menu->addAction(tr::lng_chat_link_share(tr::now), [=] { menu->addAction(tr::lng_chat_link_share(tr::now), [=] {
FastShareLink(show, url); FastShareLink(
}, &st::menuIconShare); show,
url,
shareBoxSt ? *shareBoxSt : ShareBoxStyleOverrides());
}, st.share ? st.share : &st::menuIconShare);
const auto messageId = MsgId(e.bareMsgId); const auto messageId = MsgId(e.bareMsgId);
const auto transfer = e.in const auto transfer = e.in
@ -852,15 +859,31 @@ void FillUniqueGiftMenu(
if (const auto window = show->resolveWindow()) { if (const auto window = show->resolveWindow()) {
ShowTransferGiftBox(window, unique, messageId); ShowTransferGiftBox(window, unique, messageId);
} }
}, &st::menuIconReplace); }, st.transfer ? st.transfer : &st::menuIconReplace);
} }
} }
CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle() {
return {
.box = &st::darkGiftCodeBox,
.menu = &st::mediaviewPopupMenu,
.table = &st::darkGiftTable,
.tableValueMultiline = &st::darkGiftTableValueMultiline,
.tableValueMessage = &st::darkGiftTableMessage,
.link = &st::darkGiftLink,
.share = &st::darkGiftShare,
.transfer = &st::darkGiftTransfer,
.shareBox = std::make_shared<ShareBoxStyleOverrides>(
DarkShareBoxStyle()),
};
}
void GenericCreditsEntryBox( void GenericCreditsEntryBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
const Data::CreditsHistoryEntry &e, const Data::CreditsHistoryEntry &e,
const Data::SubscriptionEntry &s) { const Data::SubscriptionEntry &s,
CreditsEntryBoxStyleOverrides st) {
const auto session = &show->session(); const auto session = &show->session();
const auto owner = &session->data(); const auto owner = &session->data();
const auto item = owner->message( const auto item = owner->message(
@ -889,7 +912,7 @@ void GenericCreditsEntryBox(
const auto couldConvert = forConvert && timeExceeded; const auto couldConvert = forConvert && timeExceeded;
const auto nonConvertible = (gotStarGift && !e.starsConverted); const auto nonConvertible = (gotStarGift && !e.starsConverted);
box->setStyle(st::giveawayGiftCodeBox); box->setStyle(st.box ? *st.box : st::giveawayGiftCodeBox);
box->setWidth(st::boxWideWidth); box->setWidth(st::boxWideWidth);
box->setNoContentMargin(true); box->setNoContentMargin(true);
@ -925,8 +948,8 @@ void GenericCreditsEntryBox(
AddSkip(content, st::defaultVerticalListSkip * 2); AddSkip(content, st::defaultVerticalListSkip * 2);
AddUniqueCloseButton(box, [=](not_null<Ui::PopupMenu*> menu) { AddUniqueCloseButton(box, st, [=](not_null<Ui::PopupMenu*> menu) {
FillUniqueGiftMenu(show, menu, e); FillUniqueGiftMenu(show, menu, e, st);
}); });
} else if (const auto callback = Ui::PaintPreviewCallback(session, e)) { } else if (const auto callback = Ui::PaintPreviewCallback(session, e)) {
const auto thumb = content->add(object_ptr<Ui::CenterWrap<>>( const auto thumb = content->add(object_ptr<Ui::CenterWrap<>>(
@ -1423,13 +1446,14 @@ void GenericCreditsEntryBox(
AddStarGiftTable( AddStarGiftTable(
show, show,
content, content,
st,
e, e,
canToggle ? toggleVisibility : Fn<void(bool)>(), canToggle ? toggleVisibility : Fn<void(bool)>(),
canConvert ? convert : Fn<void()>(), canConvert ? convert : Fn<void()>(),
canUpgrade ? upgrade : Fn<void()>()); canUpgrade ? upgrade : Fn<void()>());
} else { } else {
AddCreditsHistoryEntryTable(show, content, e); AddCreditsHistoryEntryTable(show, content, st, e);
AddSubscriptionEntryTable(show, content, s); AddSubscriptionEntryTable(show, content, st, s);
} }
Ui::AddSkip(content); Ui::AddSkip(content);
@ -1678,7 +1702,8 @@ void CreditsPrizeBox(
void GlobalStarGiftBox( void GlobalStarGiftBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
const Data::StarGift &data) { const Data::StarGift &data,
CreditsEntryBoxStyleOverrides st) {
const auto ownerId = data.unique ? data.unique->ownerId.value : 0; const auto ownerId = data.unique ? data.unique->ownerId.value : 0;
Settings::GenericCreditsEntryBox( Settings::GenericCreditsEntryBox(
box, box,
@ -1697,7 +1722,8 @@ void GlobalStarGiftBox(
.in = (ownerId == show->session().userPeerId().value), .in = (ownerId == show->session().userPeerId().value),
.gift = true, .gift = true,
}, },
Data::SubscriptionEntry()); Data::SubscriptionEntry(),
st);
} }
void UserStarGiftBox( void UserStarGiftBox(

View file

@ -11,6 +11,7 @@ template <typename Object>
class object_ptr; class object_ptr;
class PeerData; class PeerData;
struct ShareBoxStyleOverrides;
namespace ChatHelpers { namespace ChatHelpers {
class Show; class Show;
@ -26,6 +27,10 @@ struct UserStarGift;
struct StarGift; struct StarGift;
} // namespace Data } // namespace Data
namespace HistoryView {
struct ScheduleBoxStyleArgs;
} // namespace HistoryView
namespace Main { namespace Main {
class Session; class Session;
class SessionShow; class SessionShow;
@ -36,6 +41,10 @@ class SessionController;
} // namespace Window } // namespace Window
namespace style { namespace style {
struct Box;
struct Table;
struct FlatLabel;
struct PopupMenu;
struct PeerListItem; struct PeerListItem;
} // namespace style } // namespace style
@ -81,11 +90,25 @@ void AddWithdrawalWidget(
bool withdrawalEnabled, bool withdrawalEnabled,
rpl::producer<QString> usdValue); rpl::producer<QString> usdValue);
struct CreditsEntryBoxStyleOverrides {
const style::Box *box = nullptr;
const style::PopupMenu *menu = nullptr;
const style::Table *table = nullptr;
const style::FlatLabel *tableValueMultiline = nullptr;
const style::FlatLabel *tableValueMessage = nullptr;
const style::icon *link = nullptr;
const style::icon *share = nullptr;
const style::icon *transfer = nullptr;
std::shared_ptr<ShareBoxStyleOverrides> shareBox;
};
[[nodiscard]] CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle();
void GenericCreditsEntryBox( void GenericCreditsEntryBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
const Data::CreditsHistoryEntry &e, const Data::CreditsHistoryEntry &e,
const Data::SubscriptionEntry &s); const Data::SubscriptionEntry &s,
CreditsEntryBoxStyleOverrides st = {});
void ReceiptCreditsBox( void ReceiptCreditsBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
@ -110,7 +133,8 @@ void CreditsPrizeBox(
void GlobalStarGiftBox( void GlobalStarGiftBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
std::shared_ptr<ChatHelpers::Show> show, std::shared_ptr<ChatHelpers::Show> show,
const Data::StarGift &data); const Data::StarGift &data,
CreditsEntryBoxStyleOverrides st = {});
void UserStarGiftBox( void UserStarGiftBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,

@ -1 +1 @@
Subproject commit 517be45510ffde54ccb928788d700f93cfba3b65 Subproject commit e052a8bff00c24d19c12e61b0adeb5fdf18770f0