Added loading label to boosts info.

This commit is contained in:
23rd 2023-11-03 12:53:44 +03:00 committed by John Preston
parent 72c8999e50
commit 764b0d3dcd
3 changed files with 56 additions and 44 deletions

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/boosts/info_boosts_widget.h"
#include "info/info_controller.h"
#include "info/profile/info_profile_icon.h"
#include "info/statistics/info_statistics_inner_widget.h" // FillLoading.
#include "info/statistics/info_statistics_list_controllers.h"
#include "lang/lang_keys.h"
#include "settings/settings_common.h"
@ -229,12 +230,18 @@ InnerWidget::InnerWidget(
void InnerWidget::load() {
const auto api = lifetime().make_state<Api::Boosts>(_peer);
Info::Statistics::FillLoading(
this,
_loaded.events_starting_with(false) | rpl::map(!rpl::mappers::_1),
_showFinished.events());
_showFinished.events(
) | rpl::take(1) | rpl::start_with_next([=] {
api->request(
) | rpl::start_with_error_done([](const QString &error) {
}, [=] {
_state = api->boostStatus();
_loaded.fire(true);
fill();
}, lifetime());
}, lifetime());

View File

@ -247,50 +247,6 @@ void FillStatistic(
}
}
void FillLoading(
not_null<Ui::VerticalLayout*> container,
rpl::producer<bool> toggleOn,
rpl::producer<> showFinished) {
const auto emptyWrap = container->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
container,
object_ptr<Ui::VerticalLayout>(container)));
emptyWrap->toggleOn(std::move(toggleOn), anim::type::instant);
const auto content = emptyWrap->entity();
auto icon = ::Settings::CreateLottieIcon(
content,
{ .name = u"stats"_q, .sizeOverride = Size(st::changePhoneIconSize) },
st::settingsBlockedListIconPadding);
(
std::move(showFinished) | rpl::take(1)
) | rpl::start_with_next([animate = std::move(icon.animate)] {
animate(anim::repeat::loop);
}, icon.widget->lifetime());
content->add(std::move(icon.widget));
content->add(
object_ptr<Ui::CenterWrap<>>(
content,
object_ptr<Ui::FlatLabel>(
content,
tr::lng_stats_loading(),
st::changePhoneTitle)),
st::changePhoneTitlePadding + st::boxRowPadding);
content->add(
object_ptr<Ui::CenterWrap<>>(
content,
object_ptr<Ui::FlatLabel>(
content,
tr::lng_stats_loading_subtext(),
st::statisticsLoadingSubtext)),
st::changePhoneDescriptionPadding + st::boxRowPadding);
::Settings::AddSkip(content, st::settingsBlockedListIconPadding.top());
}
void AddHeader(
not_null<Ui::VerticalLayout*> content,
tr::phrase<> text,
@ -507,6 +463,50 @@ void FillOverview(
} // namespace
void FillLoading(
not_null<Ui::VerticalLayout*> container,
rpl::producer<bool> toggleOn,
rpl::producer<> showFinished) {
const auto emptyWrap = container->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
container,
object_ptr<Ui::VerticalLayout>(container)));
emptyWrap->toggleOn(std::move(toggleOn), anim::type::instant);
const auto content = emptyWrap->entity();
auto icon = ::Settings::CreateLottieIcon(
content,
{ .name = u"stats"_q, .sizeOverride = Size(st::changePhoneIconSize) },
st::settingsBlockedListIconPadding);
(
std::move(showFinished) | rpl::take(1)
) | rpl::start_with_next([animate = std::move(icon.animate)] {
animate(anim::repeat::loop);
}, icon.widget->lifetime());
content->add(std::move(icon.widget));
content->add(
object_ptr<Ui::CenterWrap<>>(
content,
object_ptr<Ui::FlatLabel>(
content,
tr::lng_stats_loading(),
st::changePhoneTitle)),
st::changePhoneTitlePadding + st::boxRowPadding);
content->add(
object_ptr<Ui::CenterWrap<>>(
content,
object_ptr<Ui::FlatLabel>(
content,
tr::lng_stats_loading_subtext(),
st::statisticsLoadingSubtext)),
st::changePhoneDescriptionPadding + st::boxRowPadding);
::Settings::AddSkip(content, st::settingsBlockedListIconPadding.top());
}
InnerWidget::InnerWidget(
QWidget *parent,
not_null<Controller*> controller,

View File

@ -21,6 +21,11 @@ namespace Info::Statistics {
class Memento;
class MessagePreview;
void FillLoading(
not_null<Ui::VerticalLayout*> container,
rpl::producer<bool> toggleOn,
rpl::producer<> showFinished);
class InnerWidget final : public Ui::VerticalLayout {
public:
struct ShowRequest final {