Added label to box for statistic while loading.
This commit is contained in:
parent
24c0624704
commit
a3fd4f3fac
5 changed files with 65 additions and 1 deletions
BIN
Telegram/Resources/animations/stats.tgs
Normal file
BIN
Telegram/Resources/animations/stats.tgs
Normal file
Binary file not shown.
|
@ -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";
|
||||
|
|
|
@ -10,5 +10,6 @@
|
|||
<file alias="cloud_password/email.tgs">../../animations/cloud_password/email.tgs</file>
|
||||
<file alias="ttl.tgs">../../animations/ttl.tgs</file>
|
||||
<file alias="discussion.tgs">../../animations/discussion.tgs</file>
|
||||
<file alias="stats.tgs">../../animations/stats.tgs</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -63,3 +63,7 @@ statisticsHeaderButton: RoundButton(defaultLightButton) {
|
|||
textTop: 2px;
|
||||
font: font(11px semibold);
|
||||
}
|
||||
|
||||
statisticsLoadingSubtext: FlatLabel(changePhoneDescription) {
|
||||
minWidth: 256px;
|
||||
}
|
||||
|
|
|
@ -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<Ui::GenericBox*> box,
|
||||
rpl::producer<bool> toggleOn) {
|
||||
const auto emptyWrap = box->verticalLayout()->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
box->verticalLayout(),
|
||||
object_ptr<Ui::VerticalLayout>(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<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());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void StatisticsBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
||||
|
||||
const auto loaded = box->lifetime().make_state<rpl::event_stream<bool>>();
|
||||
FillLoading(
|
||||
box,
|
||||
loaded->events_starting_with(false) | rpl::map(!rpl::mappers::_1));
|
||||
|
||||
const auto chartWidget = box->addRow(
|
||||
object_ptr<Statistic::ChartWidget>(box));
|
||||
const auto chartWidget2 = box->addRow(
|
||||
|
@ -98,6 +153,7 @@ void StatisticsBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
|||
if (!stats) {
|
||||
return;
|
||||
}
|
||||
loaded->fire(true);
|
||||
using Type = Statistic::ChartViewType;
|
||||
processChart(
|
||||
chartWidget,
|
||||
|
|
Loading…
Reference in a new issue