diff --git a/Telegram/Resources/animations/stats.tgs b/Telegram/Resources/animations/stats.tgs new file mode 100644 index 0000000000..4966041cef Binary files /dev/null and b/Telegram/Resources/animations/stats.tgs differ diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 6019915b4c..91c1b8c23d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4068,6 +4068,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_stats_title" = "Statistics"; "lng_stats_zoom_out" = "Zoom Out"; +"lng_stats_loading" = "Loading stats..."; +"lng_stats_loading_subtext" = "Please wait a few moments while we generate your stats."; + "lng_chart_title_member_count" = "Growth"; "lng_chart_title_join" = "Followers"; "lng_chart_title_mute" = "Notifications"; diff --git a/Telegram/Resources/qrc/telegram/animations.qrc b/Telegram/Resources/qrc/telegram/animations.qrc index 28b0c58cc6..705b508a24 100644 --- a/Telegram/Resources/qrc/telegram/animations.qrc +++ b/Telegram/Resources/qrc/telegram/animations.qrc @@ -10,5 +10,6 @@ ../../animations/cloud_password/email.tgs ../../animations/ttl.tgs ../../animations/discussion.tgs + ../../animations/stats.tgs diff --git a/Telegram/SourceFiles/statistics/statistics.style b/Telegram/SourceFiles/statistics/statistics.style index e56f0d337c..5d21c2b27f 100644 --- a/Telegram/SourceFiles/statistics/statistics.style +++ b/Telegram/SourceFiles/statistics/statistics.style @@ -63,3 +63,7 @@ statisticsHeaderButton: RoundButton(defaultLightButton) { textTop: 2px; font: font(11px semibold); } + +statisticsLoadingSubtext: FlatLabel(changePhoneDescription) { + minWidth: 256px; +} diff --git a/Telegram/SourceFiles/statistics/statistics_box.cpp b/Telegram/SourceFiles/statistics/statistics_box.cpp index 144ffb9f44..0efa57f812 100644 --- a/Telegram/SourceFiles/statistics/statistics_box.cpp +++ b/Telegram/SourceFiles/statistics/statistics_box.cpp @@ -10,16 +10,71 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_statistics.h" #include "data/data_peer.h" #include "lang/lang_keys.h" +#include "lottie/lottie_icon.h" #include "main/main_session.h" +#include "settings/settings_common.h" #include "statistics/chart_widget.h" #include "statistics/statistics_common.h" -#include "ui/toast/toast.h" #include "ui/layers/generic_box.h" +#include "ui/rect.h" +#include "ui/toast/toast.h" +#include "ui/wrap/slide_wrap.h" +#include "styles/style_boxes.h" +#include "styles/style_settings.h" +#include "styles/style_statistics.h" namespace { + +void FillLoading( + not_null box, + rpl::producer toggleOn) { + const auto emptyWrap = box->verticalLayout()->add( + object_ptr>( + box->verticalLayout(), + object_ptr(box->verticalLayout()))); + 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); + content->add(std::move(icon.widget)); + + box->setShowFinishedCallback([animate = std::move(icon.animate)] { + animate(anim::repeat::loop); + }); + + content->add( + object_ptr>( + content, + object_ptr( + content, + tr::lng_stats_loading(), + st::changePhoneTitle)), + st::changePhoneTitlePadding + st::boxRowPadding); + + content->add( + object_ptr>( + content, + object_ptr( + content, + tr::lng_stats_loading_subtext(), + st::statisticsLoadingSubtext)), + st::changePhoneDescriptionPadding + st::boxRowPadding); + + Settings::AddSkip(content, st::settingsBlockedListIconPadding.top()); +} + } // namespace void StatisticsBox(not_null box, not_null peer) { + + const auto loaded = box->lifetime().make_state>(); + FillLoading( + box, + loaded->events_starting_with(false) | rpl::map(!rpl::mappers::_1)); + const auto chartWidget = box->addRow( object_ptr(box)); const auto chartWidget2 = box->addRow( @@ -98,6 +153,7 @@ void StatisticsBox(not_null box, not_null peer) { if (!stats) { return; } + loaded->fire(true); using Type = Statistic::ChartViewType; processChart( chartWidget,