mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added overview info to statistic of channels.
This commit is contained in:
parent
df53ddf837
commit
6f27aeef10
3 changed files with 141 additions and 4 deletions
|
@ -4068,6 +4068,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_stats_title" = "Statistics";
|
"lng_stats_title" = "Statistics";
|
||||||
"lng_stats_zoom_out" = "Zoom Out";
|
"lng_stats_zoom_out" = "Zoom Out";
|
||||||
|
|
||||||
|
"lng_stats_overview_title" = "Overview";
|
||||||
|
"lng_stats_overview_member_count" = "Followers";
|
||||||
|
"lng_stats_overview_mean_view_count" = "Views Per Post";
|
||||||
|
"lng_stats_overview_mean_share_count" = "Shared Per Post";
|
||||||
|
"lng_stats_overview_enabled_notifications" = "Enabled Notifications";
|
||||||
|
|
||||||
"lng_stats_loading" = "Loading stats...";
|
"lng_stats_loading" = "Loading stats...";
|
||||||
"lng_stats_loading_subtext" = "Please wait a few moments while we generate your stats.";
|
"lng_stats_loading_subtext" = "Please wait a few moments while we generate your stats.";
|
||||||
|
|
||||||
|
|
|
@ -71,3 +71,20 @@ statisticsHeaderButton: RoundButton(defaultLightButton) {
|
||||||
statisticsLoadingSubtext: FlatLabel(changePhoneDescription) {
|
statisticsLoadingSubtext: FlatLabel(changePhoneDescription) {
|
||||||
minWidth: 256px;
|
minWidth: 256px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statisticsOverviewValue: FlatLabel(boxLabel) {
|
||||||
|
minWidth: 0px;
|
||||||
|
maxHeight: 60px;
|
||||||
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(12px semibold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statisticsOverviewSecondValueSkip: 2px;
|
||||||
|
statisticsOverviewSecondValue: FlatLabel(boxLabel) {
|
||||||
|
minWidth: 152px;
|
||||||
|
maxHeight: 32px;
|
||||||
|
textFg: windowSubTextFg;
|
||||||
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(10px semibold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lottie/lottie_icon.h"
|
#include "lottie/lottie_icon.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
|
#include "statistics/chart_header_widget.h"
|
||||||
#include "statistics/chart_widget.h"
|
#include "statistics/chart_widget.h"
|
||||||
#include "statistics/statistics_common.h"
|
#include "statistics/statistics_common.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
|
@ -99,7 +100,7 @@ void FillChannelStatistic(
|
||||||
Settings::AddDivider(box->verticalLayout());
|
Settings::AddDivider(box->verticalLayout());
|
||||||
Settings::AddSkip(box->verticalLayout(), padding.top());
|
Settings::AddSkip(box->verticalLayout(), padding.top());
|
||||||
};
|
};
|
||||||
Settings::AddSkip(box->verticalLayout(), padding.top());
|
addSkip();
|
||||||
ProcessChart(
|
ProcessChart(
|
||||||
descriptor,
|
descriptor,
|
||||||
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
|
box->addRow(object_ptr<Statistic::ChartWidget>(box)),
|
||||||
|
@ -163,9 +164,6 @@ void FillChannelStatistic(
|
||||||
tr::lng_chart_title_instant_view_interaction(),
|
tr::lng_chart_title_instant_view_interaction(),
|
||||||
Type::DoubleLinear);
|
Type::DoubleLinear);
|
||||||
addSkip();
|
addSkip();
|
||||||
|
|
||||||
box->verticalLayout()->resizeToWidth(box->width());
|
|
||||||
box->showChildren();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillLoading(
|
void FillLoading(
|
||||||
|
@ -209,6 +207,119 @@ void FillLoading(
|
||||||
Settings::AddSkip(content, st::settingsBlockedListIconPadding.top());
|
Settings::AddSkip(content, st::settingsBlockedListIconPadding.top());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FillChannelOverview(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
const Descriptor &descriptor,
|
||||||
|
const Data::ChannelStatistics &stats) {
|
||||||
|
using Value = Data::StatisticalValue;
|
||||||
|
|
||||||
|
Settings::AddSkip(box->verticalLayout());
|
||||||
|
{
|
||||||
|
const auto header = box->addRow(object_ptr<Statistic::Header>(box));
|
||||||
|
header->resize(header->width(), st::statisticsChartHeaderHeight);
|
||||||
|
header->setTitle(tr::lng_stats_overview_title(tr::now));
|
||||||
|
const auto formatter = u"MMM d"_q;
|
||||||
|
const auto from = QDateTime::fromSecsSinceEpoch(stats.startDate);
|
||||||
|
const auto to = QDateTime::fromSecsSinceEpoch(stats.endDate);
|
||||||
|
header->setRightInfo(QLocale().toString(from.date(), formatter)
|
||||||
|
+ ' '
|
||||||
|
+ QChar(8212)
|
||||||
|
+ ' '
|
||||||
|
+ QLocale().toString(to.date(), formatter));
|
||||||
|
}
|
||||||
|
Settings::AddSkip(box->verticalLayout());
|
||||||
|
|
||||||
|
struct Second final {
|
||||||
|
QColor color;
|
||||||
|
QString text;
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto parseSecond = [&](const Value &v) -> Second {
|
||||||
|
const auto diff = v.value - v.previousValue;
|
||||||
|
if (!diff) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
(diff < 0 ? st::menuIconAttentionColor : st::settingsIconBg2)->c,
|
||||||
|
QString("%1%2 (%3%)")
|
||||||
|
.arg((diff < 0) ? QChar(0x2212) : QChar(0x002B))
|
||||||
|
.arg(Lang::FormatCountToShort(std::abs(diff)).string)
|
||||||
|
.arg(std::abs(std::round(v.growthRatePercentage * 10.) / 10.))
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto container = box->addRow(object_ptr<Ui::RpWidget>(box));
|
||||||
|
|
||||||
|
const auto addPrimary = [&](const Value &v) {
|
||||||
|
return Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
container,
|
||||||
|
Lang::FormatCountToShort(v.value).string,
|
||||||
|
st::statisticsOverviewValue);
|
||||||
|
};
|
||||||
|
const auto addSub = [&](
|
||||||
|
not_null<Ui::RpWidget*> primary,
|
||||||
|
const Value &v,
|
||||||
|
tr::phrase<> text) {
|
||||||
|
const auto data = parseSecond(v);
|
||||||
|
const auto second = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
container,
|
||||||
|
data.text,
|
||||||
|
st::statisticsOverviewSecondValue);
|
||||||
|
second->setTextColorOverride(data.color);
|
||||||
|
const auto sub = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
container,
|
||||||
|
text(),
|
||||||
|
st::statisticsOverviewSecondValue);
|
||||||
|
|
||||||
|
primary->geometryValue(
|
||||||
|
) | rpl::start_with_next([=](const QRect &g) {
|
||||||
|
second->moveToLeft(
|
||||||
|
rect::right(g) + st::statisticsOverviewSecondValueSkip,
|
||||||
|
g.y() + st::statisticsOverviewSecondValueSkip);
|
||||||
|
sub->moveToLeft(
|
||||||
|
g.x(),
|
||||||
|
rect::bottom(g));
|
||||||
|
}, primary->lifetime());
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto memberCount = addPrimary(stats.memberCount);
|
||||||
|
const auto enabledNotifications = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
container,
|
||||||
|
QString("%1%").arg(
|
||||||
|
std::round(stats.enabledNotificationsPercentage * 100.) / 100.),
|
||||||
|
st::statisticsOverviewValue);
|
||||||
|
const auto meanViewCount = addPrimary(stats.meanViewCount);
|
||||||
|
const auto meanShareCount = addPrimary(stats.meanShareCount);
|
||||||
|
|
||||||
|
addSub(
|
||||||
|
memberCount,
|
||||||
|
stats.memberCount,
|
||||||
|
tr::lng_stats_overview_member_count);
|
||||||
|
addSub(
|
||||||
|
enabledNotifications,
|
||||||
|
{},
|
||||||
|
tr::lng_stats_overview_enabled_notifications);
|
||||||
|
addSub(
|
||||||
|
meanViewCount,
|
||||||
|
stats.meanViewCount,
|
||||||
|
tr::lng_stats_overview_mean_view_count);
|
||||||
|
addSub(
|
||||||
|
meanShareCount,
|
||||||
|
stats.meanShareCount,
|
||||||
|
tr::lng_stats_overview_mean_share_count);
|
||||||
|
|
||||||
|
container->sizeValue(
|
||||||
|
) | rpl::start_with_next([=](const QSize &s) {
|
||||||
|
const auto halfWidth = s.width() / 2;
|
||||||
|
enabledNotifications->moveToLeft(halfWidth, 0);
|
||||||
|
meanViewCount->moveToLeft(0, meanViewCount->height() * 3);
|
||||||
|
meanShareCount->moveToLeft(halfWidth, meanViewCount->y());
|
||||||
|
}, container->lifetime());
|
||||||
|
|
||||||
|
container->showChildren();
|
||||||
|
container->resize(container->width(), meanViewCount->height() * 5);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void StatisticsBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
void StatisticsBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
||||||
|
@ -231,7 +342,10 @@ void StatisticsBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
||||||
if (!stats) {
|
if (!stats) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
FillChannelOverview(box, descriptor, stats);
|
||||||
FillChannelStatistic(box, descriptor, stats);
|
FillChannelStatistic(box, descriptor, stats);
|
||||||
loaded->fire(true);
|
loaded->fire(true);
|
||||||
|
box->verticalLayout()->resizeToWidth(box->width());
|
||||||
|
box->showChildren();
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue