2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Removed repeated animation from some settings lottie icons.

This commit is contained in:
23rd
2022-05-04 00:02:52 +03:00
parent d16ccf0d9e
commit 3ff4bf77e7
4 changed files with 30 additions and 14 deletions

View File

@@ -249,7 +249,8 @@ not_null<Ui::FlatLabel*> AddSubsectionTitle(
LottieIcon CreateLottieIcon(
not_null<QWidget*> parent,
Lottie::IconDescriptor &&descriptor,
style::margins padding) {
style::margins padding,
bool playOnce) {
auto object = object_ptr<Ui::RpWidget>(parent);
const auto raw = object.data();
@@ -262,8 +263,14 @@ LottieIcon CreateLottieIcon(
const auto icon = owned.get();
raw->lifetime().add([kept = std::move(owned)]{});
const auto animationRequired = raw->lifetime().make_state<bool>(true);
const auto animate = [=] {
if (playOnce) {
if (!base::take(*animationRequired)) {
return;
}
}
icon->animate([=] { raw->update(); }, 0, icon->framesCount() - 1);
};
raw->paintRequest(