Skip to content

Commit

Permalink
More sidebar stats (#249)
Browse files Browse the repository at this point in the history
* Organizing imports.

* Adding more sidebar stats. Fixes #187
  • Loading branch information
dessalines authored Dec 18, 2022
1 parent 0b1e094 commit c820632
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
30 changes: 27 additions & 3 deletions app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,12 @@ fun Sidebar(
icon: String?,
content: String?,
published: String,
usersActiveMonth: Int,
postCount: Int,
commentCount: Int
commentCount: Int,
usersActiveDay: Int,
usersActiveWeek: Int,
usersActiveMonth: Int,
usersActiveHalfYear: Int
) {
val listState = rememberLazyListState()

Expand Down Expand Up @@ -405,7 +408,10 @@ fun Sidebar(
published = published
)
CommentsAndPosts(
usersActiveDay = usersActiveDay,
usersActiveWeek = usersActiveWeek,
usersActiveMonth = usersActiveMonth,
usersActiveHalfYear = usersActiveHalfYear,
postCount = postCount,
commentCount = commentCount
)
Expand All @@ -425,16 +431,34 @@ fun Sidebar(

@Composable
fun CommentsAndPosts(
usersActiveDay: Int,
usersActiveWeek: Int,
usersActiveMonth: Int,
usersActiveHalfYear: Int,
postCount: Int,
commentCount: Int
) {
Row {
FlowRow {
Text(
text = "${siFormat(usersActiveDay)} users / day",
color = MaterialTheme.colors.onBackground.muted
)
DotSpacer()
Text(
text = "${siFormat(usersActiveWeek)} users / week",
color = MaterialTheme.colors.onBackground.muted
)
DotSpacer()
Text(
text = "${siFormat(usersActiveMonth)} users / month",
color = MaterialTheme.colors.onBackground.muted
)
DotSpacer()
Text(
text = "${siFormat(usersActiveHalfYear)} users / 6 months",
color = MaterialTheme.colors.onBackground.muted
)
DotSpacer()
Text(
text = "${siFormat(postCount)} posts",
color = MaterialTheme.colors.onBackground.muted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ fun CommunitySidebar(communityView: CommunityView) {
banner = community.banner,
icon = community.icon,
published = community.published,
usersActiveDay = counts.users_active_day,
usersActiveWeek = counts.users_active_week,
usersActiveMonth = counts.users_active_month,
usersActiveHalfYear = counts.users_active_half_year,
postCount = counts.posts,
commentCount = counts.comments
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ fun SiteSidebar(siteView: SiteView) {
val counts = siteView.counts
Sidebar(
title = site.description,
content = site.sidebar,
banner = site.banner,
icon = site.icon,
content = site.sidebar,
published = site.published,
usersActiveDay = counts.users_active_day,
usersActiveWeek = counts.users_active_week,
usersActiveMonth = counts.users_active_month,
usersActiveHalfYear = counts.users_active_half_year,
postCount = counts.posts,
commentCount = counts.comments
)
Expand Down

0 comments on commit c820632

Please sign in to comment.