mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Jump to giveaway link from gift code box.
This commit is contained in:
parent
981babf302
commit
714dae054a
6 changed files with 38 additions and 13 deletions
|
@ -2130,6 +2130,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_gift_link_gift_premium" = "Telegram Premium {duration}";
|
"lng_gift_link_gift_premium" = "Telegram Premium {duration}";
|
||||||
"lng_gift_link_label_reason" = "Reason";
|
"lng_gift_link_label_reason" = "Reason";
|
||||||
"lng_gift_link_reason_giveaway" = "Giveaway";
|
"lng_gift_link_reason_giveaway" = "Giveaway";
|
||||||
|
"lng_gift_link_reason_chosen" = "You were selected by the channel";
|
||||||
"lng_gift_link_label_date" = "Date";
|
"lng_gift_link_label_date" = "Date";
|
||||||
"lng_gift_link_also_send" = "You can also {link} to a friend as a gift.";
|
"lng_gift_link_also_send" = "You can also {link} to a friend as a gift.";
|
||||||
"lng_gift_link_also_send_link" = "send this link";
|
"lng_gift_link_also_send_link" = "send this link";
|
||||||
|
|
|
@ -23,9 +23,11 @@ namespace {
|
||||||
return {
|
return {
|
||||||
.from = peerFromMTP(data.vfrom_id()),
|
.from = peerFromMTP(data.vfrom_id()),
|
||||||
.to = data.vto_id() ? peerFromUser(*data.vto_id()) : PeerId(),
|
.to = data.vto_id() ? peerFromUser(*data.vto_id()) : PeerId(),
|
||||||
|
.giveawayId = data.vgiveaway_msg_id().value_or_empty(),
|
||||||
.date = data.vdate().v,
|
.date = data.vdate().v,
|
||||||
.used = data.vused_date().value_or_empty(),
|
.used = data.vused_date().value_or_empty(),
|
||||||
.months = data.vmonths().v,
|
.months = data.vmonths().v,
|
||||||
|
.giveaway = data.is_via_giveaway(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,11 @@ namespace Api {
|
||||||
struct GiftCode {
|
struct GiftCode {
|
||||||
PeerId from = 0;
|
PeerId from = 0;
|
||||||
PeerId to = 0;
|
PeerId to = 0;
|
||||||
|
MsgId giveawayId = 0;
|
||||||
TimeId date = 0;
|
TimeId date = 0;
|
||||||
TimeId used = 0; // 0 if not used.
|
TimeId used = 0; // 0 if not used.
|
||||||
int months = 0;
|
int months = 0;
|
||||||
|
bool giveaway = false;
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
return months != 0;
|
return months != 0;
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.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/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
#include "ui/effects/premium_stars_colored.h"
|
#include "ui/effects/premium_stars_colored.h"
|
||||||
|
@ -371,18 +372,21 @@ void AddTableRow(
|
||||||
valueMargins);
|
valueMargins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTableRow(
|
not_null<Ui::FlatLabel*> AddTableRow(
|
||||||
not_null<Ui::TableLayout*> table,
|
not_null<Ui::TableLayout*> table,
|
||||||
rpl::producer<QString> label,
|
rpl::producer<QString> label,
|
||||||
rpl::producer<QString> value) {
|
rpl::producer<TextWithEntities> value) {
|
||||||
|
auto widget = object_ptr<Ui::FlatLabel>(
|
||||||
|
table,
|
||||||
|
std::move(value),
|
||||||
|
st::giveawayGiftCodeValue);
|
||||||
|
const auto result = widget.data();
|
||||||
AddTableRow(
|
AddTableRow(
|
||||||
table,
|
table,
|
||||||
std::move(label),
|
std::move(label),
|
||||||
object_ptr<Ui::FlatLabel>(
|
std::move(widget),
|
||||||
table,
|
|
||||||
std::move(value),
|
|
||||||
st::giveawayGiftCodeValue),
|
|
||||||
st::giveawayGiftCodeValueMargin);
|
st::giveawayGiftCodeValueMargin);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTableRow(
|
void AddTableRow(
|
||||||
|
@ -524,16 +528,31 @@ void GiftCodeBox(
|
||||||
tr::lng_gift_link_label_gift(),
|
tr::lng_gift_link_label_gift(),
|
||||||
tr::lng_gift_link_gift_premium(
|
tr::lng_gift_link_gift_premium(
|
||||||
lt_duration,
|
lt_duration,
|
||||||
GiftDurationValue(current.months)));
|
GiftDurationValue(current.months) | Ui::Text::ToWithEntities(),
|
||||||
AddTableRow(
|
Ui::Text::WithEntities));
|
||||||
|
const auto reason = AddTableRow(
|
||||||
table,
|
table,
|
||||||
tr::lng_gift_link_label_reason(),
|
tr::lng_gift_link_label_reason(),
|
||||||
tr::lng_gift_link_reason_giveaway());
|
(current.giveawayId
|
||||||
|
? (tr::lng_gift_link_reason_giveaway() | Ui::Text::ToLink())
|
||||||
|
: current.giveaway
|
||||||
|
? (tr::lng_gift_link_reason_giveaway(
|
||||||
|
Ui::Text::WithEntities
|
||||||
|
) | rpl::type_erased())
|
||||||
|
: tr::lng_gift_link_reason_chosen(Ui::Text::WithEntities)));
|
||||||
|
reason->setClickHandlerFilter([=](const auto &...) {
|
||||||
|
controller->showPeerHistory(
|
||||||
|
current.from,
|
||||||
|
Window::SectionShow::Way::Forward,
|
||||||
|
current.giveawayId);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
if (current.date) {
|
if (current.date) {
|
||||||
AddTableRow(
|
AddTableRow(
|
||||||
table,
|
table,
|
||||||
tr::lng_gift_link_label_date(),
|
tr::lng_gift_link_label_date(),
|
||||||
rpl::single(langDateTime(base::unixtime::parse(current.date))));
|
rpl::single(Ui::Text::WithEntities(
|
||||||
|
langDateTime(base::unixtime::parse(current.date)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto shareLink = tr::lng_gift_link_also_send_link(
|
auto shareLink = tr::lng_gift_link_also_send_link(
|
||||||
|
@ -590,6 +609,8 @@ void GiftCodeBox(
|
||||||
auto copy = state->data.current();
|
auto copy = state->data.current();
|
||||||
copy.used = base::unixtime::now();
|
copy.used = base::unixtime::now();
|
||||||
state->data = std::move(copy);
|
state->data = std::move(copy);
|
||||||
|
|
||||||
|
Ui::StartFireworks(box->parentWidget());
|
||||||
} else {
|
} else {
|
||||||
box->uiShow()->showToast(error);
|
box->uiShow()->showToast(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_premium.h"
|
#include "styles/style_premium.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
|
||||||
|
|
||||||
void StartFireworks(not_null<QWidget*> parent) {
|
void StartFireworks(not_null<QWidget*> parent) {
|
||||||
const auto result = Ui::CreateChild<RpWidget>(parent.get());
|
const auto result = Ui::CreateChild<RpWidget>(parent.get());
|
||||||
|
@ -37,8 +36,6 @@ void StartFireworks(not_null<QWidget*> parent) {
|
||||||
}, lifetime);
|
}, lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void BoostBox(
|
void BoostBox(
|
||||||
not_null<GenericBox*> box,
|
not_null<GenericBox*> box,
|
||||||
BoostBoxData data,
|
BoostBoxData data,
|
||||||
|
|
|
@ -9,6 +9,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
|
void StartFireworks(not_null<QWidget*> parent);
|
||||||
|
|
||||||
class GenericBox;
|
class GenericBox;
|
||||||
class VerticalLayout;
|
class VerticalLayout;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue