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

View file

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

View file

@ -1020,7 +1020,7 @@ void Controller::rowClicked(not_null<PeerListRow*> row) {
Ui::AddSkip(content);
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);

View file

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

View file

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

View file

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

View file

@ -17,6 +17,10 @@ namespace Payments {
enum class CheckoutResult;
} // namespace Payments
namespace Settings {
struct CreditsEntryBoxStyleOverrides;
} // namespace Settings
namespace Window {
class SessionController;
} // namespace Window
@ -76,6 +80,7 @@ void ShowStarGiftUpgradeBox(StarGiftUpgradeArgs &&args);
void AddUniqueCloseButton(
not_null<GenericBox*> box,
Settings::CreditsEntryBoxStyleOverrides st,
Fn<void(not_null<PopupMenu*>)> fillMenu = nullptr);
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_device_resolver.h"
#include "settings/settings_calls.h"
#include "settings/settings_credits_graphics.h"
#include "main/main_session.h"
#include "apiwrap.h"
#include "api/api_invite_links.h"
@ -183,22 +184,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
return Data::CanSend(thread, ChatRestriction::SendOther);
};
const auto scheduleStyle = [&] {
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;
};
const auto st = ::Settings::DarkCreditsEntryBoxStyle();
auto result = Box<ShareBox>(ShareBox::Descriptor{
.session = &peer->session(),
.copyCallback = std::move(copyCallback),
@ -211,11 +197,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
: rpl::single(false)),
tr::lng_group_call_copy_speaker_link(),
tr::lng_group_call_copy_listener_link()),
.stMultiSelect = &st::groupCallMultiSelect,
.stComment = &st::groupCallShareBoxComment,
.st = &st::groupCallShareBoxList,
.stLabel = &st::groupCallField,
.scheduleBoxStyle = scheduleStyle(),
.st = st.shareBox ? *st.shareBox : ShareBoxStyleOverrides(),
.premiumRequiredError = SharePremiumRequiredError(),
});
*box = result.data();

View file

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

View file

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

View file

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

View file

@ -78,22 +78,8 @@ giveawayGiftCodeTable: Table(defaultTable) {
labelMinWidth: 91px;
}
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);
giveawayGiftCodeValue: FlatLabel(defaultFlatLabel) {
maxHeight: 24px;
style: TextStyle(defaultTextStyle) {
font: font(12px);
linkUnderline: kLinkUnderlineNever;
}
}
giveawayGiftCodeValueMultiline: FlatLabel(giveawayGiftCodeValue) {
giveawayGiftCodeValueMultiline: FlatLabel(defaultTableValue) {
minWidth: 128px;
maxHeight: 100px;
style: TextStyle(defaultTextStyle) {
@ -101,7 +87,7 @@ giveawayGiftCodeValueMultiline: FlatLabel(giveawayGiftCodeValue) {
linkUnderline: kLinkUnderlineNever;
}
}
giveawayGiftMessage: FlatLabel(giveawayGiftCodeValue) {
giveawayGiftMessage: FlatLabel(defaultTableValue) {
minWidth: 128px;
maxHeight: 0px;
}
@ -217,19 +203,53 @@ starConvertButtonLoading: InfiniteRadialAnimation(startGiveawayButtonLoading) {
thickness: 2px;
}
starGiftSmallButton: RoundButton(defaultActiveButton) {
textFg: windowActiveTextFg;
textFgOver: windowActiveTextFg;
textBg: lightButtonBgOver;
textBgOver: lightButtonBgOver;
width: -12px;
height: 18px;
radius: 9px;
textTop: 0px;
style: TextStyle(defaultTextStyle) {
font: font(12px);
starGiftSmallButton: defaultTableSmallButton;
darkGiftCodeBox: Box(giveawayGiftCodeBox) {
button: RoundButton(defaultActiveButton) {
height: 42px;
textTop: 12px;
style: semiboldTextStyle;
}
ripple: RippleAnimation(defaultRippleAnimation) {
color: lightButtonBgRipple;
bg: groupCallMembersBg;
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_view.h"
#include "media/audio/media_audio.h"
#include "settings/settings_credits_graphics.h"
#include "ui/boxes/confirm_box.h"
#include "ui/boxes/report_box_graphics.h"
#include "ui/text/text_utilities.h"
@ -1959,7 +1960,10 @@ ClickHandlerPtr MakeUrlAreaHandler(
const auto slug = raw.mid(
prefix.size()
).split('&').front().split('#').front();
Core::ResolveAndShowUniqueGift(strong->uiShow(), slug);
Core::ResolveAndShowUniqueGift(
strong->uiShow(),
slug,
::Settings::DarkCreditsEntryBoxStyle());
} else {
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 "lang/lang_keys.h"
#include "main/main_session.h"
#include "settings/settings_credits_graphics.h"
#include "ui/boxes/confirm_box.h"
#include "ui/text/text_utilities.h"
#include "styles/style_calls.h"
@ -167,35 +168,15 @@ namespace Media::Stories {
++state->requests;
}
};
const auto viewerScheduleStyle = [&] {
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;
};
const auto st = viewerStyle
? ::Settings::DarkCreditsEntryBoxStyle()
: ::Settings::CreditsEntryBoxStyleOverrides();
return Box<ShareBox>(ShareBox::Descriptor{
.session = session,
.copyCallback = std::move(copyLinkCallback),
.submitCallback = std::move(submitCallback),
.filterCallback = std::move(filterCallback),
.stMultiSelect = viewerStyle ? &st::groupCallMultiSelect : nullptr,
.stComment = viewerStyle ? &st::groupCallShareBoxComment : nullptr,
.st = viewerStyle ? &st::groupCallShareBoxList : nullptr,
.stLabel = viewerStyle ? &st::groupCallField : nullptr,
.scheduleBoxStyle = (viewerStyle
? viewerScheduleStyle()
: HistoryView::ScheduleBoxStyleArgs()),
.st = st.shareBox ? *st.shareBox : ShareBoxStyleOverrides(),
.premiumRequiredError = SharePremiumRequiredError(),
});
}

View file

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

View file

@ -11,6 +11,7 @@ template <typename Object>
class object_ptr;
class PeerData;
struct ShareBoxStyleOverrides;
namespace ChatHelpers {
class Show;
@ -26,6 +27,10 @@ struct UserStarGift;
struct StarGift;
} // namespace Data
namespace HistoryView {
struct ScheduleBoxStyleArgs;
} // namespace HistoryView
namespace Main {
class Session;
class SessionShow;
@ -36,6 +41,10 @@ class SessionController;
} // namespace Window
namespace style {
struct Box;
struct Table;
struct FlatLabel;
struct PopupMenu;
struct PeerListItem;
} // namespace style
@ -81,11 +90,25 @@ void AddWithdrawalWidget(
bool withdrawalEnabled,
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(
not_null<Ui::GenericBox*> box,
std::shared_ptr<ChatHelpers::Show> show,
const Data::CreditsHistoryEntry &e,
const Data::SubscriptionEntry &s);
const Data::SubscriptionEntry &s,
CreditsEntryBoxStyleOverrides st = {});
void ReceiptCreditsBox(
not_null<Ui::GenericBox*> box,
not_null<Window::SessionController*> controller,
@ -110,7 +133,8 @@ void CreditsPrizeBox(
void GlobalStarGiftBox(
not_null<Ui::GenericBox*> box,
std::shared_ptr<ChatHelpers::Show> show,
const Data::StarGift &data);
const Data::StarGift &data,
CreditsEntryBoxStyleOverrides st = {});
void UserStarGiftBox(
not_null<Ui::GenericBox*> box,
not_null<Window::SessionController*> controller,

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