mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added initial tabbed selector for different boosts lists in boosts info.
This commit is contained in:
parent
79b5f7eda9
commit
72c8999e50
3 changed files with 66 additions and 15 deletions
|
@ -4331,6 +4331,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_boosts_list_unclaimed" = "Unclaimed";
|
"lng_boosts_list_unclaimed" = "Unclaimed";
|
||||||
"lng_boosts_list_pending" = "To be distributed";
|
"lng_boosts_list_pending" = "To be distributed";
|
||||||
"lng_boosts_list_pending_about" = "The recipient will be selected when the giveaway ends.";
|
"lng_boosts_list_pending_about" = "The recipient will be selected when the giveaway ends.";
|
||||||
|
"lng_boosts_list_tab_gifts#one" = "{count} Gifts";
|
||||||
|
"lng_boosts_list_tab_gifts#other" = "{count} Gifts";
|
||||||
|
|
||||||
// Wnd specific
|
// Wnd specific
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/controls/invite_link_label.h"
|
#include "ui/controls/invite_link_label.h"
|
||||||
#include "ui/rect.h"
|
#include "ui/rect.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
#include "ui/widgets/discrete_sliders.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_statistics.h"
|
#include "styles/style_statistics.h"
|
||||||
|
|
||||||
|
@ -271,7 +273,9 @@ void InnerWidget::fill() {
|
||||||
::Settings::AddDivider(inner);
|
::Settings::AddDivider(inner);
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
|
|
||||||
if (status.firstSliceBoosts.multipliedTotal > 0) {
|
const auto hasBoosts = (status.firstSliceBoosts.multipliedTotal > 0);
|
||||||
|
const auto hasGifts = (status.firstSliceGifts.multipliedTotal > 0);
|
||||||
|
if (hasBoosts || hasGifts) {
|
||||||
auto boostClicked = [=](const Data::Boost &boost) {
|
auto boostClicked = [=](const Data::Boost &boost) {
|
||||||
if (!boost.giftCodeLink.slug.isEmpty()) {
|
if (!boost.giftCodeLink.slug.isEmpty()) {
|
||||||
ResolveGiftCode(_controller, boost.giftCodeLink.slug);
|
ResolveGiftCode(_controller, boost.giftCodeLink.slug);
|
||||||
|
@ -285,28 +289,73 @@ void InnerWidget::fill() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
::Settings::AddSkip(inner);
|
#ifdef _DEBUG
|
||||||
const auto header = inner->add(
|
const auto hasOneTab = false;
|
||||||
object_ptr<Statistic::Header>(inner),
|
#else
|
||||||
st::statisticsLayerMargins
|
const auto hasOneTab = (hasBoosts != hasGifts);
|
||||||
+ st::boostsChartHeaderPadding);
|
#endif
|
||||||
header->resizeToWidth(header->width());
|
const auto boostsTabText = tr::lng_boosts_list_title(
|
||||||
header->setTitle(tr::lng_boosts_list_title(
|
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_count,
|
lt_count,
|
||||||
status.firstSliceBoosts.total));
|
status.firstSliceBoosts.multipliedTotal);
|
||||||
header->setSubTitle({});
|
const auto giftsTabText = tr::lng_boosts_list_tab_gifts(
|
||||||
|
tr::now,
|
||||||
|
lt_count,
|
||||||
|
status.firstSliceGifts.multipliedTotal);
|
||||||
|
if (hasOneTab) {
|
||||||
|
::Settings::AddSkip(inner);
|
||||||
|
const auto header = inner->add(
|
||||||
|
object_ptr<Statistic::Header>(inner),
|
||||||
|
st::statisticsLayerMargins
|
||||||
|
+ st::boostsChartHeaderPadding);
|
||||||
|
header->resizeToWidth(header->width());
|
||||||
|
header->setTitle(hasBoosts ? boostsTabText : giftsTabText);
|
||||||
|
header->setSubTitle({});
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto slider = inner->add(
|
||||||
|
object_ptr<Ui::SlideWrap<Ui::SettingsSlider>>(
|
||||||
|
inner,
|
||||||
|
object_ptr<Ui::SettingsSlider>(
|
||||||
|
inner,
|
||||||
|
st::defaultTabsSlider)));
|
||||||
|
slider->toggle(!hasOneTab, anim::type::instant);
|
||||||
|
slider->entity()->addSection(boostsTabText);
|
||||||
|
slider->entity()->addSection(giftsTabText);
|
||||||
|
|
||||||
|
const auto boostsWrap = inner->add(
|
||||||
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
inner,
|
||||||
|
object_ptr<Ui::VerticalLayout>(inner)));
|
||||||
|
const auto giftsWrap = inner->add(
|
||||||
|
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
inner,
|
||||||
|
object_ptr<Ui::VerticalLayout>(inner)));
|
||||||
|
boostsWrap->toggle(hasOneTab ? true : hasBoosts, anim::type::instant);
|
||||||
|
giftsWrap->toggle(hasOneTab ? false : hasGifts, anim::type::instant);
|
||||||
|
|
||||||
|
slider->entity()->sectionActivated(
|
||||||
|
) | rpl::start_with_next([=](int index) {
|
||||||
|
boostsWrap->toggle(!index, anim::type::instant);
|
||||||
|
giftsWrap->toggle(index, anim::type::instant);
|
||||||
|
}, inner->lifetime());
|
||||||
|
|
||||||
Statistics::AddBoostsList(
|
Statistics::AddBoostsList(
|
||||||
status.firstSliceBoosts,
|
status.firstSliceBoosts,
|
||||||
inner,
|
boostsWrap->entity(),
|
||||||
|
boostClicked,
|
||||||
|
_peer,
|
||||||
|
tr::lng_boosts_title());
|
||||||
|
Statistics::AddBoostsList(
|
||||||
|
status.firstSliceGifts,
|
||||||
|
giftsWrap->entity(),
|
||||||
std::move(boostClicked),
|
std::move(boostClicked),
|
||||||
_peer,
|
_peer,
|
||||||
tr::lng_boosts_title());
|
tr::lng_boosts_title());
|
||||||
|
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
::Settings::AddDividerText(
|
|
||||||
inner,
|
|
||||||
tr::lng_boosts_list_subtext());
|
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
|
::Settings::AddDividerText(inner, tr::lng_boosts_list_subtext());
|
||||||
}
|
}
|
||||||
|
|
||||||
::Settings::AddSkip(inner);
|
::Settings::AddSkip(inner);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public:
|
||||||
void setActiveSectionFast(int index);
|
void setActiveSectionFast(int index);
|
||||||
void finishAnimating();
|
void finishAnimating();
|
||||||
|
|
||||||
auto sectionActivated() const {
|
[[nodiscard]] rpl::producer<int> sectionActivated() const {
|
||||||
return _sectionActivated.events();
|
return _sectionActivated.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue