mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Use "Display on my Page" big button.
This commit is contained in:
parent
006ecf9a56
commit
d2be10cd4e
8 changed files with 104 additions and 106 deletions
|
@ -3279,16 +3279,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_gift_view_unpack" = "Unpack";
|
||||
"lng_gift_anonymous_hint" = "Only you can see the sender's name.";
|
||||
"lng_gift_hidden_hint" = "This gift is hidden. Only you can see it.";
|
||||
"lng_gift_visible_hint" = "This gift is visible to visitors of your page.";
|
||||
"lng_gift_visible_hint" = "This gift is visible on your page.";
|
||||
"lng_gift_hidden_hint_channel" = "This gift is hidden from visitors of your channel.";
|
||||
"lng_gift_visible_hint_channel" = "This gift is visible in your channel's Gifts.";
|
||||
"lng_gift_visible_hide" = "Hide >";
|
||||
"lng_gift_show_on_page" = "Display on my Page";
|
||||
"lng_gift_availability" = "Availability";
|
||||
"lng_gift_from_hidden" = "Hidden User";
|
||||
"lng_gift_visibility" = "Visibility";
|
||||
"lng_gift_visibility_shown" = "Visible on your page";
|
||||
"lng_gift_visibility_hidden" = "Not visible on your page";
|
||||
"lng_gift_visibility_show" = "show";
|
||||
"lng_gift_visibility_hide" = "hide";
|
||||
"lng_gift_self_status" = "buy yourself a gift";
|
||||
"lng_gift_self_title" = "Buy a Gift";
|
||||
"lng_gift_self_about" = "Buy yourself a gift to display on your page or reserve for later.\n\nLimited-edition gifts upgraded to collectibles can be gifted to others later.";
|
||||
|
|
|
@ -183,7 +183,7 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000);
|
|||
|
||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
label->setTextColorOverride(st::windowActiveTextFg->c);
|
||||
label->setTextColorOverride(table->st().defaultValue.palette.linkFg->c);
|
||||
|
||||
raw->setClickedCallback([=] {
|
||||
show->showBox(PrepareShortInfoBox(peer, show));
|
||||
|
@ -258,7 +258,7 @@ constexpr auto kRarityTooltipDuration = 3 * crl::time(1000);
|
|||
|
||||
userpic->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
label->setTextColorOverride(st::windowActiveTextFg->c);
|
||||
label->setTextColorOverride(table->st().defaultValue.palette.linkFg->c);
|
||||
|
||||
raw->setClickedCallback([=] {
|
||||
show->showBox(PrepareShortInfoBox(peer, show));
|
||||
|
@ -436,59 +436,6 @@ void AddTableRow(
|
|||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> MakeVisibilityTableValue(
|
||||
not_null<Ui::TableLayout*> table,
|
||||
bool savedToProfile,
|
||||
Fn<void(bool)> toggleVisibility) {
|
||||
auto result = object_ptr<Ui::RpWidget>(table);
|
||||
const auto raw = result.data();
|
||||
|
||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||
raw,
|
||||
(savedToProfile
|
||||
? tr::lng_gift_visibility_shown()
|
||||
: tr::lng_gift_visibility_hidden()),
|
||||
table->st().defaultValue,
|
||||
st::defaultPopupMenu);
|
||||
|
||||
const auto toggle = Ui::CreateChild<Ui::RoundButton>(
|
||||
raw,
|
||||
(savedToProfile
|
||||
? tr::lng_gift_visibility_hide()
|
||||
: tr::lng_gift_visibility_show()),
|
||||
table->st().smallButton);
|
||||
toggle->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
||||
toggle->setClickedCallback([=] {
|
||||
toggleVisibility(!savedToProfile);
|
||||
});
|
||||
|
||||
rpl::combine(
|
||||
raw->widthValue(),
|
||||
toggle->widthValue()
|
||||
) | rpl::start_with_next([=](int width, int toggleWidth) {
|
||||
const auto toggleSkip = toggleWidth
|
||||
? (st::normalFont->spacew + toggleWidth)
|
||||
: 0;
|
||||
label->resizeToNaturalWidth(width - toggleSkip);
|
||||
label->moveToLeft(0, 0, width);
|
||||
toggle->moveToLeft(
|
||||
label->width() + st::normalFont->spacew,
|
||||
(table->st().defaultValue.style.font->ascent
|
||||
- table->st().smallButton.style.font->ascent),
|
||||
width);
|
||||
}, label->lifetime());
|
||||
|
||||
label->heightValue() | rpl::start_with_next([=](int height) {
|
||||
raw->resize(
|
||||
raw->width(),
|
||||
height + st::giveawayGiftCodeValueMargin.bottom());
|
||||
}, raw->lifetime());
|
||||
|
||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::RpWidget> MakeNonUniqueStatusTableValue(
|
||||
not_null<Ui::TableLayout*> table,
|
||||
Fn<void()> startUpgrade) {
|
||||
|
@ -1273,7 +1220,6 @@ void AddStarGiftTable(
|
|||
not_null<Ui::VerticalLayout*> container,
|
||||
Settings::CreditsEntryBoxStyleOverrides st,
|
||||
const Data::CreditsHistoryEntry &entry,
|
||||
Fn<void(bool)> toggleVisibility,
|
||||
Fn<void()> convertToStars,
|
||||
Fn<void()> startUpgrade) {
|
||||
auto table = container->add(
|
||||
|
@ -1464,16 +1410,6 @@ void AddStarGiftTable(
|
|||
std::move(convertToStars)),
|
||||
marginWithButton);
|
||||
}
|
||||
if (toggleVisibility) {
|
||||
AddTableRow(
|
||||
table,
|
||||
tr::lng_gift_visibility(),
|
||||
MakeVisibilityTableValue(
|
||||
table,
|
||||
entry.savedToProfile,
|
||||
std::move(toggleVisibility)),
|
||||
marginWithButton);
|
||||
}
|
||||
if (entry.limitedCount > 0 && !entry.giftRefunded) {
|
||||
auto amount = rpl::single(TextWithEntities{
|
||||
Lang::FormatCountDecimal(entry.limitedCount)
|
||||
|
|
|
@ -67,7 +67,6 @@ void AddStarGiftTable(
|
|||
not_null<Ui::VerticalLayout*> container,
|
||||
Settings::CreditsEntryBoxStyleOverrides st,
|
||||
const Data::CreditsHistoryEntry &entry,
|
||||
Fn<void(bool)> toggleVisibility,
|
||||
Fn<void()> convertToStars,
|
||||
Fn<void()> startUpgrade);
|
||||
void AddCreditsHistoryEntryTable(
|
||||
|
|
|
@ -2227,10 +2227,12 @@ void AddWearGiftCover(
|
|||
void ShowUniqueGiftWearBox(
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
const Data::UniqueGift &gift,
|
||||
Settings::CreditsEntryBoxStyleOverrides st) {
|
||||
Settings::GiftWearBoxStyleOverride st) {
|
||||
show->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
box->setNoContentMargin(true);
|
||||
|
||||
box->setStyle(st.box ? *st.box : st::upgradeGiftBox);
|
||||
|
||||
const auto content = box->verticalLayout();
|
||||
AddWearGiftCover(content, gift, show->session().user());
|
||||
|
||||
|
@ -2246,13 +2248,13 @@ void ShowUniqueGiftWearBox(
|
|||
object_ptr<Ui::FlatLabel>(
|
||||
raw,
|
||||
std::move(title) | Ui::Text::ToBold(),
|
||||
st::defaultFlatLabel),
|
||||
st.infoTitle ? *st.infoTitle : st::defaultFlatLabel),
|
||||
st::settingsPremiumRowTitlePadding);
|
||||
raw->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
raw,
|
||||
std::move(text),
|
||||
st::boxDividerLabel),
|
||||
st.infoAbout ? *st.infoAbout : st::boxDividerLabel),
|
||||
st::settingsPremiumRowAboutPadding);
|
||||
object_ptr<Info::Profile::FloatingIcon>(
|
||||
raw,
|
||||
|
@ -2266,28 +2268,26 @@ void ShowUniqueGiftWearBox(
|
|||
tr::lng_gift_wear_title(
|
||||
lt_name,
|
||||
rpl::single(UniqueGiftName(gift))),
|
||||
st::uniqueGiftTitle),
|
||||
st.title ? *st.title : st::uniqueGiftTitle),
|
||||
st::settingsPremiumRowTitlePadding);
|
||||
content->add(
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
content,
|
||||
tr::lng_gift_wear_about(),
|
||||
st::uniqueGiftSubtitle),
|
||||
st.subtitle ? *st.subtitle : st::uniqueGiftSubtitle),
|
||||
st::settingsPremiumRowAboutPadding);
|
||||
infoRow(
|
||||
tr::lng_gift_wear_badge_title(),
|
||||
tr::lng_gift_wear_badge_about(),
|
||||
&st::menuIconUnique);
|
||||
st.radiantIcon ? st.radiantIcon : &st::menuIconUnique);
|
||||
//infoRow(
|
||||
// tr::lng_gift_wear_design_title(),
|
||||
// tr::lng_gift_wear_design_about(),
|
||||
// &st::menuIconUniqueProfile);
|
||||
infoRow(
|
||||
tr::lng_gift_wear_proof_title(),
|
||||
tr::lng_gift_wear_proof_about(),
|
||||
&st::menuIconTradable); // todo collectibles
|
||||
|
||||
box->setStyle(st::upgradeGiftBox);
|
||||
tr::lng_gift_wear_proof_about(), // todo collectibles
|
||||
st.proofIcon ? st.proofIcon : &st::menuIconTradable);
|
||||
|
||||
const auto button = box->addButton(tr::lng_gift_wear_start(), [=] {
|
||||
const auto session = &show->session();
|
||||
|
@ -2312,7 +2312,7 @@ void ShowUniqueGiftWearBox(
|
|||
}
|
||||
}, box->lifetime());
|
||||
|
||||
AddUniqueCloseButton(box, st);
|
||||
AddUniqueCloseButton(box, {});
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ enum class CheckoutResult;
|
|||
} // namespace Payments
|
||||
|
||||
namespace Settings {
|
||||
struct GiftWearBoxStyleOverride;
|
||||
struct CreditsEntryBoxStyleOverrides;
|
||||
} // namespace Settings
|
||||
|
||||
|
@ -58,7 +59,7 @@ void AddWearGiftCover(
|
|||
void ShowUniqueGiftWearBox(
|
||||
std::shared_ptr<ChatHelpers::Show> show,
|
||||
const Data::UniqueGift &gift,
|
||||
Settings::CreditsEntryBoxStyleOverrides st);
|
||||
Settings::GiftWearBoxStyleOverride st);
|
||||
|
||||
struct PatternPoint {
|
||||
QPointF position;
|
||||
|
|
|
@ -874,12 +874,26 @@ void FillUniqueGiftMenu(
|
|||
}, st.transfer ? st.transfer : &st::menuIconReplace);
|
||||
} else {
|
||||
menu->addAction(tr::lng_gift_transfer_wear(tr::now), [=] {
|
||||
ShowUniqueGiftWearBox(show, *unique, st);
|
||||
ShowUniqueGiftWearBox(show, *unique, st.giftWearBox
|
||||
? *st.giftWearBox
|
||||
: GiftWearBoxStyleOverride());
|
||||
}, st.transfer ? st.transfer : &st::menuIconReplace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GiftWearBoxStyleOverride DarkGiftWearBoxStyle() {
|
||||
return {
|
||||
.box = &st::darkUpgradeGiftBox,
|
||||
.title = &st::darkUpgradeGiftTitle,
|
||||
.subtitle = &st::darkUpgradeGiftSubtitle,
|
||||
.radiantIcon = &st::darkUpgradeGiftRadiant,
|
||||
.proofIcon = &st::darkUpgradeGiftProof,
|
||||
.infoTitle = &st::darkUpgradeGiftInfoTitle,
|
||||
.infoAbout = &st::darkUpgradeGiftInfoAbout,
|
||||
};
|
||||
}
|
||||
|
||||
CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle() {
|
||||
return {
|
||||
.box = &st::darkGiftCodeBox,
|
||||
|
@ -892,6 +906,8 @@ CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle() {
|
|||
.transfer = &st::darkGiftTransfer,
|
||||
.shareBox = std::make_shared<ShareBoxStyleOverrides>(
|
||||
DarkShareBoxStyle()),
|
||||
.giftWearBox = std::make_shared<GiftWearBoxStyleOverride>(
|
||||
DarkGiftWearBoxStyle()),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1351,6 +1367,9 @@ void GenericCreditsEntryBox(
|
|||
};
|
||||
const auto state = box->lifetime().make_state<State>();
|
||||
|
||||
const auto canToggle = (canConvert || couldConvert || nonConvertible)
|
||||
&& !e.giftTransferred
|
||||
&& !e.giftRefunded;
|
||||
const auto toggleVisibility = [=, weak = Ui::MakeWeak(box)](bool save) {
|
||||
const auto showSection = !e.fromGiftsList;
|
||||
const auto itemId = MsgId(e.bareMsgId);
|
||||
|
@ -1456,16 +1475,11 @@ void GenericCreditsEntryBox(
|
|||
}
|
||||
});
|
||||
};
|
||||
const auto canToggle = (canConvert || couldConvert || nonConvertible)
|
||||
&& !e.giftTransferred
|
||||
&& !e.giftRefunded;
|
||||
|
||||
AddStarGiftTable(
|
||||
show,
|
||||
content,
|
||||
st,
|
||||
e,
|
||||
canToggle ? toggleVisibility : Fn<void(bool)>(),
|
||||
canConvert ? convert : Fn<void()>(),
|
||||
canUpgrade ? upgrade : Fn<void()>());
|
||||
} else {
|
||||
|
@ -1487,22 +1501,38 @@ void GenericCreditsEntryBox(
|
|||
tr::lng_credits_box_out_about_link(tr::now)),
|
||||
Ui::Text::WithEntities),
|
||||
st::creditsBoxAboutDivider)));
|
||||
} else if (gotStarGift && e.fromGiftsList) {
|
||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||
box,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
} else if (gotStarGift) {
|
||||
auto withHide = rpl::combine(
|
||||
tr::lng_gift_visible_hint(),
|
||||
tr::lng_gift_visible_hide()
|
||||
) | rpl::map([](QString &&hint, QString &&hide) {
|
||||
return TextWithEntities{ std::move(hint) }.append(' ').append(
|
||||
Ui::Text::Link(std::move(hide)));
|
||||
});
|
||||
auto text = !e.savedToProfile // todo channel gifts
|
||||
? tr::lng_gift_hidden_hint(Ui::Text::WithEntities)
|
||||
: canToggle
|
||||
? std::move(withHide)
|
||||
: tr::lng_gift_visible_hint(Ui::Text::WithEntities);
|
||||
if (e.anonymous && e.barePeerId) {
|
||||
text = rpl::combine(
|
||||
std::move(text),
|
||||
tr::lng_gift_anonymous_hint()
|
||||
) | rpl::map([](TextWithEntities &&a, QString &&b) {
|
||||
return a.append("\n\n").append(b);
|
||||
});
|
||||
}
|
||||
const auto label = box->addRow(
|
||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
||||
box,
|
||||
(e.savedToProfile
|
||||
? tr::lng_gift_visible_hint()
|
||||
: tr::lng_gift_hidden_hint()), // todo channel gifts
|
||||
st::creditsBoxAboutDivider)));
|
||||
} else if (gotStarGift && e.anonymous) {
|
||||
box->addRow(object_ptr<Ui::CenterWrap<>>(
|
||||
box,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_gift_anonymous_hint(),
|
||||
st::creditsBoxAboutDivider)));
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
std::move(text),
|
||||
st::creditsBoxAboutDivider)))->entity();
|
||||
label->setClickHandlerFilter([=](const auto &...) {
|
||||
toggleVisibility(!e.savedToProfile);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (s) {
|
||||
const auto user = peer ? peer->asUser() : nullptr;
|
||||
|
@ -1579,6 +1609,8 @@ void GenericCreditsEntryBox(
|
|||
? tr::lng_credits_subscription_off_rejoin_button()
|
||||
: canUpgradeFree
|
||||
? tr::lng_gift_upgrade_free()
|
||||
: (canToggle && !e.savedToProfile)
|
||||
? tr::lng_gift_show_on_page()
|
||||
: tr::lng_box_ok()));
|
||||
const auto send = [=, weak = Ui::MakeWeak(box)] {
|
||||
if (toRejoin) {
|
||||
|
@ -1635,6 +1667,8 @@ void GenericCreditsEntryBox(
|
|||
send();
|
||||
} else if (canUpgradeFree) {
|
||||
upgrade();
|
||||
} else if (canToggle && !e.savedToProfile) {
|
||||
toggleVisibility(true);
|
||||
} else {
|
||||
box->closeBox();
|
||||
}
|
||||
|
|
|
@ -90,6 +90,17 @@ void AddWithdrawalWidget(
|
|||
bool withdrawalEnabled,
|
||||
rpl::producer<QString> usdValue);
|
||||
|
||||
struct GiftWearBoxStyleOverride {
|
||||
const style::Box *box = nullptr;
|
||||
const style::FlatLabel *title = nullptr;
|
||||
const style::FlatLabel *subtitle = nullptr;
|
||||
const style::icon *radiantIcon = nullptr;
|
||||
const style::icon *proofIcon = nullptr;
|
||||
const style::FlatLabel *infoTitle = nullptr;
|
||||
const style::FlatLabel *infoAbout = nullptr;
|
||||
};
|
||||
[[nodiscard]] GiftWearBoxStyleOverride DarkGiftWearBoxStyle();
|
||||
|
||||
struct CreditsEntryBoxStyleOverrides {
|
||||
const style::Box *box = nullptr;
|
||||
const style::PopupMenu *menu = nullptr;
|
||||
|
@ -100,6 +111,7 @@ struct CreditsEntryBoxStyleOverrides {
|
|||
const style::icon *share = nullptr;
|
||||
const style::icon *transfer = nullptr;
|
||||
std::shared_ptr<ShareBoxStyleOverrides> shareBox;
|
||||
std::shared_ptr<GiftWearBoxStyleOverride> giftWearBox;
|
||||
};
|
||||
[[nodiscard]] CreditsEntryBoxStyleOverrides DarkCreditsEntryBoxStyle();
|
||||
|
||||
|
|
|
@ -211,3 +211,22 @@ uniqueMenuButton: IconButton(uniqueCloseButton) {
|
|||
upgradeGiftBox: Box(giftBox) {
|
||||
buttonPadding: margins(22px, 3px, 22px, 22px);
|
||||
}
|
||||
darkUpgradeGiftTitle: FlatLabel(uniqueGiftTitle) {
|
||||
textFg: groupCallMembersFg;
|
||||
}
|
||||
darkUpgradeGiftSubtitle: FlatLabel(uniqueGiftSubtitle) {
|
||||
textFg: groupCallMembersFg;
|
||||
}
|
||||
darkUpgradeGiftBox: Box(upgradeGiftBox) {
|
||||
bg: groupCallMembersBg;
|
||||
title: darkUpgradeGiftTitle;
|
||||
titleAdditionalFg: groupCallMemberNotJoinedStatus;
|
||||
}
|
||||
darkUpgradeGiftRadiant: icon{{ "menu/unique", groupCallMembersFg }};
|
||||
darkUpgradeGiftProof: icon{{ "menu/tradable", groupCallMembersFg }};
|
||||
darkUpgradeGiftInfoTitle: FlatLabel(defaultFlatLabel) {
|
||||
textFg: groupCallMembersFg;
|
||||
}
|
||||
darkUpgradeGiftInfoAbout: FlatLabel(boxDividerLabel) {
|
||||
textFg: groupCallMemberNotJoinedStatus;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue