mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Improve layout of resale gift counters.
This commit is contained in:
parent
bdf802e64a
commit
5d1251f6d8
2 changed files with 50 additions and 12 deletions
|
@ -3623,6 +3623,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_gift_resale_price" = "Price";
|
"lng_gift_resale_price" = "Price";
|
||||||
"lng_gift_resale_number" = "Number";
|
"lng_gift_resale_number" = "Number";
|
||||||
"lng_gift_resale_date" = "Date";
|
"lng_gift_resale_date" = "Date";
|
||||||
|
"lng_gift_resale_count#one" = "{count} gift in resale";
|
||||||
|
"lng_gift_resale_count#other" = "{count} gifts in resale";
|
||||||
"lng_gift_resale_sort_price" = "Sort by Price";
|
"lng_gift_resale_sort_price" = "Sort by Price";
|
||||||
"lng_gift_resale_sort_date" = "Sort by Date";
|
"lng_gift_resale_sort_date" = "Sort by Date";
|
||||||
"lng_gift_resale_sort_number" = "Sort by Number";
|
"lng_gift_resale_sort_number" = "Sort by Number";
|
||||||
|
|
|
@ -1199,14 +1199,14 @@ struct ResaleTabs {
|
||||||
: original(data, context);
|
: original(data, context);
|
||||||
};
|
};
|
||||||
const auto actionWithEmoji = [=](
|
const auto actionWithEmoji = [=](
|
||||||
QString text,
|
TextWithEntities text,
|
||||||
Fn<void()> callback,
|
Fn<void()> callback,
|
||||||
QString data,
|
QString data,
|
||||||
bool checked) {
|
bool checked) {
|
||||||
auto action = base::make_unique_q<Ui::GiftResaleFilterAction>(
|
auto action = base::make_unique_q<Ui::GiftResaleFilterAction>(
|
||||||
menu,
|
menu,
|
||||||
menu->st().menu,
|
menu->st().menu,
|
||||||
TextWithEntities{ text },
|
std::move(text),
|
||||||
context,
|
context,
|
||||||
data,
|
data,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
@ -1215,7 +1215,7 @@ struct ResaleTabs {
|
||||||
menu->addAction(std::move(action));
|
menu->addAction(std::move(action));
|
||||||
};
|
};
|
||||||
const auto actionWithDocument = [=](
|
const auto actionWithDocument = [=](
|
||||||
QString text,
|
TextWithEntities text,
|
||||||
Fn<void()> callback,
|
Fn<void()> callback,
|
||||||
DocumentId id,
|
DocumentId id,
|
||||||
bool checked) {
|
bool checked) {
|
||||||
|
@ -1226,7 +1226,7 @@ struct ResaleTabs {
|
||||||
checked);
|
checked);
|
||||||
};
|
};
|
||||||
const auto actionWithColor = [=](
|
const auto actionWithColor = [=](
|
||||||
QString text,
|
TextWithEntities text,
|
||||||
Fn<void()> callback,
|
Fn<void()> callback,
|
||||||
const QColor &color,
|
const QColor &color,
|
||||||
bool checked) {
|
bool checked) {
|
||||||
|
@ -1288,8 +1288,11 @@ struct ResaleTabs {
|
||||||
if (type == AttributeIdType::Model) {
|
if (type == AttributeIdType::Model) {
|
||||||
for (auto &entry : state->lists.models) {
|
for (auto &entry : state->lists.models) {
|
||||||
const auto id = IdFor(entry.model);
|
const auto id = IdFor(entry.model);
|
||||||
const auto text = entry.model.name
|
const auto text = TextWithEntities{
|
||||||
+ u" (%1)"_q.arg(entry.count);
|
entry.model.name
|
||||||
|
}.append(' ').append(Ui::Text::Bold(
|
||||||
|
Lang::FormatCountDecimal(entry.count)
|
||||||
|
));
|
||||||
actionWithDocument(text, [=] {
|
actionWithDocument(text, [=] {
|
||||||
toggle(id);
|
toggle(id);
|
||||||
}, id.value, checked(id));
|
}, id.value, checked(id));
|
||||||
|
@ -1297,8 +1300,11 @@ struct ResaleTabs {
|
||||||
} else if (type == AttributeIdType::Backdrop) {
|
} else if (type == AttributeIdType::Backdrop) {
|
||||||
for (auto &entry : state->lists.backdrops) {
|
for (auto &entry : state->lists.backdrops) {
|
||||||
const auto id = IdFor(entry.backdrop);
|
const auto id = IdFor(entry.backdrop);
|
||||||
const auto text = entry.backdrop.name
|
const auto text = TextWithEntities{
|
||||||
+ u" (%1)"_q.arg(entry.count);
|
entry.backdrop.name
|
||||||
|
}.append(' ').append(Ui::Text::Bold(
|
||||||
|
Lang::FormatCountDecimal(entry.count)
|
||||||
|
));
|
||||||
actionWithColor(text, [=] {
|
actionWithColor(text, [=] {
|
||||||
toggle(id);
|
toggle(id);
|
||||||
}, entry.backdrop.centerColor, checked(id));
|
}, entry.backdrop.centerColor, checked(id));
|
||||||
|
@ -1306,8 +1312,11 @@ struct ResaleTabs {
|
||||||
} else if (type == AttributeIdType::Pattern) {
|
} else if (type == AttributeIdType::Pattern) {
|
||||||
for (auto &entry : state->lists.patterns) {
|
for (auto &entry : state->lists.patterns) {
|
||||||
const auto id = IdFor(entry.pattern);
|
const auto id = IdFor(entry.pattern);
|
||||||
const auto text = entry.pattern.name
|
const auto text = TextWithEntities{
|
||||||
+ u" (%1)"_q.arg(entry.count);
|
entry.pattern.name
|
||||||
|
}.append(' ').append(Ui::Text::Bold(
|
||||||
|
Lang::FormatCountDecimal(entry.count)
|
||||||
|
));
|
||||||
actionWithDocument(text, [=] {
|
actionWithDocument(text, [=] {
|
||||||
toggle(id);
|
toggle(id);
|
||||||
}, id.value, checked(id));
|
}, id.value, checked(id));
|
||||||
|
@ -3029,8 +3038,35 @@ void GiftResaleBox(
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
box->addButton(tr::lng_create_group_back(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_create_group_back(), [=] { box->closeBox(); });
|
||||||
|
|
||||||
box->setTitle(rpl::single(descriptor.title
|
// Create a proper vertical layout for the title
|
||||||
+ u" (%1)"_q.arg(descriptor.count)));
|
const auto titleWrap = box->setPinnedToTopContent(
|
||||||
|
object_ptr<Ui::VerticalLayout>(box.get()));
|
||||||
|
|
||||||
|
// Add vertical spacing above the title
|
||||||
|
titleWrap->add(object_ptr<Ui::FixedHeightWidget>(
|
||||||
|
titleWrap,
|
||||||
|
st::defaultVerticalListSkip));
|
||||||
|
|
||||||
|
// Add the gift name with semibold style
|
||||||
|
titleWrap->add(
|
||||||
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
titleWrap,
|
||||||
|
rpl::single(descriptor.title),
|
||||||
|
st::boxTitle),
|
||||||
|
QMargins(st::boxRowPadding.left(), 0, st::boxRowPadding.right(), 0));
|
||||||
|
|
||||||
|
// Add the count text in gray below with proper translation
|
||||||
|
const auto countLabel = titleWrap->add(
|
||||||
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
titleWrap,
|
||||||
|
tr::lng_gift_resale_count(tr::now, lt_count, descriptor.count),
|
||||||
|
st::defaultFlatLabel),
|
||||||
|
QMargins(
|
||||||
|
st::boxRowPadding.left(),
|
||||||
|
0,
|
||||||
|
st::boxRowPadding.right(),
|
||||||
|
st::defaultVerticalListSkip));
|
||||||
|
countLabel->setTextColorOverride(st::windowSubTextFg->c);
|
||||||
|
|
||||||
const auto content = box->verticalLayout();
|
const auto content = box->verticalLayout();
|
||||||
content->paintRequest() | rpl::start_with_next([=](QRect clip) {
|
content->paintRequest() | rpl::start_with_next([=](QRect clip) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue