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

@ -162,13 +162,17 @@ void Blocked::setupContent() {
{
const auto content = emptyWrap->entity();
auto icon = CreateLottieIcon(content, {
.name = u"blocked_peers_empty"_q,
.sizeOverride = {
st::changePhoneIconSize,
st::changePhoneIconSize,
auto icon = CreateLottieIcon(
content,
{
.name = u"blocked_peers_empty"_q,
.sizeOverride = {
st::changePhoneIconSize,
st::changePhoneIconSize,
},
},
}, st::blockedUsersListIconPadding);
st::blockedUsersListIconPadding,
true);
content->add(std::move(icon.widget));
_showFinished.events(

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(

View File

@ -185,7 +185,8 @@ struct LottieIcon {
[[nodiscard]] LottieIcon CreateLottieIcon(
not_null<QWidget*> parent,
Lottie::IconDescriptor &&descriptor,
style::margins padding = {});
style::margins padding = {},
bool playOnce = false);
void FillMenu(
not_null<Window::SessionController*> controller,

View File

@ -604,13 +604,17 @@ QPointer<Ui::RpWidget> Folders::createPinnedToTop(not_null<QWidget*> parent) {
const auto divider = Ui::CreateChild<Ui::BoxContentDivider>(parent.get());
const auto verticalLayout = Ui::CreateChild<Ui::VerticalLayout>(divider);
auto icon = CreateLottieIcon(this, {
.name = u"filters"_q,
.sizeOverride = {
st::settingsFilterIconSize,
st::settingsFilterIconSize,
auto icon = CreateLottieIcon(
this,
{
.name = u"filters"_q,
.sizeOverride = {
st::settingsFilterIconSize,
st::settingsFilterIconSize,
},
},
}, st::settingsFilterIconPadding);
st::settingsFilterIconPadding,
true);
_showFinished.events(
) | rpl::start_with_next([animate = std::move(icon.animate)] {
animate();