Added chart widgets for statistic of supergroups.

This commit is contained in:
23rd 2023-09-28 23:21:11 +03:00 committed by John Preston
parent cf82e12bf4
commit 17fdef7d9e
2 changed files with 85 additions and 4 deletions

View File

@ -4087,6 +4087,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_chart_title_message_interaction" = "Interactions";
"lng_chart_title_instant_view_interaction" = "IV Interactions";
"lng_chart_title_group_join" = "Group members";
"lng_chart_title_group_join_by_source" = "New members by source";
"lng_chart_title_group_language" = "Members's primary language";
"lng_chart_title_group_message_content" = "Messages";
"lng_chart_title_group_action" = "Actions";
"lng_chart_title_group_day" = "Views by hours";
"lng_chart_title_group_week" = "Top days of week";
// Wnd specific
"lng_wnd_choose_program_menu" = "Choose Default Program...";

View File

@ -166,6 +166,76 @@ void FillChannelStatistic(
addSkip();
}
void FillSupergroupStatistic(
not_null<Ui::GenericBox*> box,
const Descriptor &descriptor,
const Data::SupergroupStatistics &stats) {
using Type = Statistic::ChartViewType;
const auto &padding = st::statisticsChartEntryPadding;
const auto addSkip = [&] {
Settings::AddSkip(box->verticalLayout(), padding.bottom());
Settings::AddDivider(box->verticalLayout());
Settings::AddSkip(box->verticalLayout(), padding.top());
};
addSkip();
ProcessChart(
descriptor,
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
stats.memberCountGraph,
tr::lng_chart_title_member_count(),
Type::Linear);
addSkip();
ProcessChart(
descriptor,
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
stats.joinGraph,
tr::lng_chart_title_group_join(),
Type::Linear);
addSkip();
ProcessChart(
descriptor,
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
stats.joinBySourceGraph,
tr::lng_chart_title_group_join_by_source(),
Type::Stack);
addSkip();
ProcessChart(
descriptor,
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
stats.languageGraph,
tr::lng_chart_title_group_language(),
Type::StackLinear);
addSkip();
ProcessChart(
descriptor,
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
stats.messageContentGraph,
tr::lng_chart_title_group_message_content(),
Type::Stack);
addSkip();
ProcessChart(
descriptor,
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
stats.actionGraph,
tr::lng_chart_title_group_action(),
Type::DoubleLinear);
addSkip();
ProcessChart(
descriptor,
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
stats.dayGraph,
tr::lng_chart_title_group_day(),
Type::Linear);
addSkip();
// ProcessChart(
// descriptor,
// box->addRow(object_ptr<Statistic::ChartWidget>(box)),
// stats.weekGraph,
// tr::lng_chart_title_group_week(),
// Type::StackLinear);
// addSkip();
}
void FillLoading(
not_null<Ui::GenericBox*> box,
rpl::producer<bool> toggleOn) {
@ -338,12 +408,15 @@ void StatisticsBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
descriptor.api->request(
descriptor.peer
) | rpl::start_with_done([=] {
const auto stats = descriptor.api->channelStats();
if (!stats) {
if (const auto stats = descriptor.api->supergroupStats(); stats) {
// FillSupergroupOverview(box, descriptor, stats);
FillSupergroupStatistic(box, descriptor, stats);
} else if (const auto stats = descriptor.api->channelStats(); stats) {
FillChannelOverview(box, descriptor, stats);
FillChannelStatistic(box, descriptor, stats);
} else {
return;
}
FillChannelOverview(box, descriptor, stats);
FillChannelStatistic(box, descriptor, stats);
loaded->fire(true);
box->verticalLayout()->resizeToWidth(box->width());
box->showChildren();