mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Moved out creation of button for paging of stats lists to single place.
This commit is contained in:
parent
c82b86cea3
commit
1840da1d68
2 changed files with 38 additions and 36 deletions
|
@ -1141,13 +1141,9 @@ void AddMembersList(
|
|||
object_ptr<PeerListContent>(container, &state->controller)));
|
||||
state->controller.setDelegate(&state->delegate);
|
||||
|
||||
const auto wrap = container->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||
container,
|
||||
object_ptr<Ui::SettingsButton>(
|
||||
container,
|
||||
tr::lng_stories_show_more())),
|
||||
{ 0, -st::settingsButton.padding.top(), 0, 0 });
|
||||
const auto wrap = AddShowMoreButton(
|
||||
container,
|
||||
tr::lng_stories_show_more());
|
||||
|
||||
const auto showMore = [=] {
|
||||
state->limit = std::min(int(max), state->limit + kPerPage);
|
||||
|
@ -1181,23 +1177,14 @@ void AddBoostsList(
|
|||
object_ptr<PeerListContent>(container, &state->controller)));
|
||||
state->controller.setDelegate(&state->delegate);
|
||||
|
||||
const auto wrap = container->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||
container,
|
||||
object_ptr<Ui::SettingsButton>(
|
||||
container,
|
||||
(firstSlice.token.gifts
|
||||
? tr::lng_boosts_show_more_gifts
|
||||
: tr::lng_boosts_show_more_boosts)(
|
||||
lt_count,
|
||||
state->controller.totalBoostsValue(
|
||||
) | rpl::map(
|
||||
max - rpl::mappers::_1
|
||||
) | tr::to_count()),
|
||||
st::statisticsShowMoreButton)),
|
||||
{ 0, -st::settingsButton.padding.top(), 0, 0 });
|
||||
const auto button = wrap->entity();
|
||||
AddArrow(button);
|
||||
const auto wrap = AddShowMoreButton(
|
||||
container,
|
||||
(firstSlice.token.gifts
|
||||
? tr::lng_boosts_show_more_gifts
|
||||
: tr::lng_boosts_show_more_boosts)(
|
||||
lt_count,
|
||||
state->controller.totalBoostsValue(
|
||||
) | rpl::map(max - rpl::mappers::_1) | tr::to_count()));
|
||||
|
||||
const auto showMore = [=] {
|
||||
if (!state->controller.skipRequest()) {
|
||||
|
@ -1209,7 +1196,7 @@ void AddBoostsList(
|
|||
state->controller.totalBoostsValue(
|
||||
) | rpl::map(rpl::mappers::_1 > 0 && rpl::mappers::_1 < max),
|
||||
anim::type::instant);
|
||||
button->setClickedCallback(showMore);
|
||||
wrap->entity()->setClickedCallback(showMore);
|
||||
}
|
||||
|
||||
void AddCreditsHistoryList(
|
||||
|
@ -1239,16 +1226,9 @@ void AddCreditsHistoryList(
|
|||
object_ptr<PeerListContent>(container, &state->controller)));
|
||||
state->controller.setDelegate(&state->delegate);
|
||||
|
||||
const auto wrap = container->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||
container,
|
||||
object_ptr<Ui::SettingsButton>(
|
||||
container,
|
||||
tr::lng_stories_show_more(),
|
||||
st::statisticsShowMoreButton)),
|
||||
{ 0, -st::settingsButton.padding.top(), 0, 0 });
|
||||
const auto button = wrap->entity();
|
||||
AddArrow(button);
|
||||
const auto wrap = AddShowMoreButton(
|
||||
container,
|
||||
tr::lng_stories_show_more());
|
||||
|
||||
const auto showMore = [=] {
|
||||
if (!state->controller.skipRequest()) {
|
||||
|
@ -1259,7 +1239,22 @@ void AddCreditsHistoryList(
|
|||
wrap->toggleOn(
|
||||
state->controller.allLoadedValue() | rpl::map(!rpl::mappers::_1),
|
||||
anim::type::instant);
|
||||
button->setClickedCallback(showMore);
|
||||
wrap->entity()->setClickedCallback(showMore);
|
||||
}
|
||||
|
||||
not_null<Ui::SlideWrap<Ui::SettingsButton>*> AddShowMoreButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> title) {
|
||||
const auto wrap = container->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||
container,
|
||||
object_ptr<Ui::SettingsButton>(
|
||||
container,
|
||||
std::move(title),
|
||||
st::statisticsShowMoreButton)),
|
||||
{ 0, -st::settingsButton.padding.top(), 0, 0 });
|
||||
AddArrow(wrap->entity());
|
||||
return wrap;
|
||||
}
|
||||
|
||||
} // namespace Info::Statistics
|
||||
|
|
|
@ -10,6 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
class PeerData;
|
||||
|
||||
namespace Ui {
|
||||
class SettingsButton;
|
||||
template <typename Widget>
|
||||
class SlideWrap;
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
|
@ -64,4 +67,8 @@ void AddCreditsHistoryList(
|
|||
bool out,
|
||||
bool subscription = false);
|
||||
|
||||
[[nodiscard]] not_null<Ui::SlideWrap<Ui::SettingsButton>*> AddShowMoreButton(
|
||||
not_null<Ui::VerticalLayout*> container,
|
||||
rpl::producer<QString> title);
|
||||
|
||||
} // namespace Info::Statistics
|
||||
|
|
Loading…
Add table
Reference in a new issue