mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve layout for the first star reaction.
This commit is contained in:
parent
fac20e436d
commit
3549349ffb
1 changed files with 21 additions and 10 deletions
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/continuous_sliders.h"
|
#include "ui/widgets/continuous_sliders.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/dynamic_image.h"
|
#include "ui/dynamic_image.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/vertical_list.h"
|
#include "ui/vertical_list.h"
|
||||||
|
@ -242,8 +243,11 @@ void FillTopReactors(
|
||||||
|
|
||||||
const auto height = st::paidReactTopNameSkip + st::normalFont->height;
|
const auto height = st::paidReactTopNameSkip + st::normalFont->height;
|
||||||
const auto wrap = container->add(
|
const auto wrap = container->add(
|
||||||
object_ptr<FixedHeightWidget>(container, height),
|
object_ptr<SlideWrap<FixedHeightWidget>>(
|
||||||
st::paidReactTopMargin);
|
container,
|
||||||
|
object_ptr<FixedHeightWidget>(container, height),
|
||||||
|
st::paidReactTopMargin));
|
||||||
|
const auto parent = wrap->entity();
|
||||||
struct State {
|
struct State {
|
||||||
std::vector<not_null<RpWidget*>> widgets;
|
std::vector<not_null<RpWidget*>> widgets;
|
||||||
rpl::event_stream<> updated;
|
rpl::event_stream<> updated;
|
||||||
|
@ -261,11 +265,6 @@ void FillTopReactors(
|
||||||
} else if (*state->initialChosen != chosen) {
|
} else if (*state->initialChosen != chosen) {
|
||||||
state->chosenChanged = true;
|
state->chosenChanged = true;
|
||||||
}
|
}
|
||||||
for (const auto &widget : state->widgets) {
|
|
||||||
delete widget;
|
|
||||||
}
|
|
||||||
state->widgets.clear();
|
|
||||||
|
|
||||||
auto list = std::vector<PaidReactionTop>();
|
auto list = std::vector<PaidReactionTop>();
|
||||||
list.reserve(kMaxTopPaidShown + 1);
|
list.reserve(kMaxTopPaidShown + 1);
|
||||||
for (const auto &entry : top) {
|
for (const auto &entry : top) {
|
||||||
|
@ -283,14 +282,26 @@ void FillTopReactors(
|
||||||
list,
|
list,
|
||||||
ranges::greater(),
|
ranges::greater(),
|
||||||
&PaidReactionTop::count);
|
&PaidReactionTop::count);
|
||||||
while (list.size() > kMaxTopPaidShown) {
|
while (list.size() > kMaxTopPaidShown
|
||||||
|
|| (!list.empty() && !list.back().count)) {
|
||||||
list.pop_back();
|
list.pop_back();
|
||||||
}
|
}
|
||||||
for (const auto &entry : list) {
|
if (list.empty()) {
|
||||||
state->widgets.push_back(MakeTopReactor(wrap, entry));
|
wrap->hide(anim::type::normal);
|
||||||
|
} else {
|
||||||
|
for (const auto &widget : state->widgets) {
|
||||||
|
delete widget;
|
||||||
|
}
|
||||||
|
state->widgets.clear();
|
||||||
|
for (const auto &entry : list) {
|
||||||
|
state->widgets.push_back(MakeTopReactor(parent, entry));
|
||||||
|
}
|
||||||
|
wrap->show(anim::type::normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
state->updated.fire({});
|
state->updated.fire({});
|
||||||
}, wrap->lifetime());
|
}, wrap->lifetime());
|
||||||
|
wrap->finishAnimating();
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
state->updated.events_starting_with({}),
|
state->updated.events_starting_with({}),
|
||||||
|
|
Loading…
Add table
Reference in a new issue