Display online counts
This commit is contained in:
parent
0ddf488602
commit
e0626925ab
|
@ -1,5 +1,9 @@
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Online users count is now correctly displayed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed a bug where replying to a comment would instead reply to the parent of that comment
|
- Fixed a bug where replying to a comment would instead reply to the parent of that comment
|
||||||
|
|
|
@ -167,8 +167,11 @@ class CommunityPage extends HookWidget {
|
||||||
IconButton(icon: Icon(moreIcon), onPressed: _openMoreMenu),
|
IconButton(icon: Icon(moreIcon), onPressed: _openMoreMenu),
|
||||||
],
|
],
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
background:
|
background: _CommunityOverview(
|
||||||
_CommunityOverview(community, instanceHost: instanceHost),
|
community: community,
|
||||||
|
instanceHost: instanceHost,
|
||||||
|
onlineUsers: fullCommunitySnap.data?.online,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SliverPersistentHeader(
|
SliverPersistentHeader(
|
||||||
|
@ -213,6 +216,7 @@ class CommunityPage extends HookWidget {
|
||||||
_AboutTab(
|
_AboutTab(
|
||||||
community: community,
|
community: community,
|
||||||
moderators: fullCommunitySnap.data?.moderators,
|
moderators: fullCommunitySnap.data?.moderators,
|
||||||
|
onlineUsers: fullCommunitySnap.data?.online,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -225,10 +229,12 @@ class CommunityPage extends HookWidget {
|
||||||
class _CommunityOverview extends StatelessWidget {
|
class _CommunityOverview extends StatelessWidget {
|
||||||
final CommunityView community;
|
final CommunityView community;
|
||||||
final String instanceHost;
|
final String instanceHost;
|
||||||
|
final int onlineUsers;
|
||||||
|
|
||||||
const _CommunityOverview(
|
const _CommunityOverview({
|
||||||
this.community, {
|
@required this.community,
|
||||||
@required this.instanceHost,
|
@required this.instanceHost,
|
||||||
|
@required this.onlineUsers,
|
||||||
}) : assert(instanceHost != null),
|
}) : assert(instanceHost != null),
|
||||||
assert(goToInstance != null);
|
assert(goToInstance != null);
|
||||||
|
|
||||||
|
@ -354,7 +360,9 @@ class _CommunityOverview extends StatelessWidget {
|
||||||
padding: EdgeInsets.only(right: 3),
|
padding: EdgeInsets.only(right: 3),
|
||||||
child: Icon(Icons.record_voice_over, size: 20),
|
child: Icon(Icons.record_voice_over, size: 20),
|
||||||
),
|
),
|
||||||
const Text('xx'), // TODO: display online users
|
Text(onlineUsers == null
|
||||||
|
? 'xx'
|
||||||
|
: compactNumber(onlineUsers)),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -394,11 +402,13 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
||||||
class _AboutTab extends StatelessWidget {
|
class _AboutTab extends StatelessWidget {
|
||||||
final CommunityView community;
|
final CommunityView community;
|
||||||
final List<CommunityModeratorView> moderators;
|
final List<CommunityModeratorView> moderators;
|
||||||
|
final int onlineUsers;
|
||||||
|
|
||||||
const _AboutTab({
|
const _AboutTab({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.community,
|
@required this.community,
|
||||||
@required this.moderators,
|
@required this.moderators,
|
||||||
|
@required this.onlineUsers,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
void goToModlog() {
|
void goToModlog() {
|
||||||
|
@ -430,9 +440,9 @@ class _AboutTab extends StatelessWidget {
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
children: [
|
children: [
|
||||||
// TODO: consider using Chips
|
// TODO: consider using Chips
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(left: 7),
|
padding: const EdgeInsets.only(left: 7),
|
||||||
child: _Badge('X users online'),
|
child: _Badge('${onlineUsers ?? 'X'} users online'),
|
||||||
),
|
),
|
||||||
_Badge(
|
_Badge(
|
||||||
'''${community.counts.subscribers} subscriber${pluralS(community.counts.subscribers)}'''),
|
'''${community.counts.subscribers} subscriber${pluralS(community.counts.subscribers)}'''),
|
||||||
|
|
|
@ -301,7 +301,7 @@ class _AboutTab extends HookWidget {
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(width: 7),
|
const SizedBox(width: 7),
|
||||||
const _Badge('X users online'),
|
_Badge('${site.online} users online'),
|
||||||
_Badge('${site.siteView.counts.users} users'),
|
_Badge('${site.siteView.counts.users} users'),
|
||||||
_Badge('${site.siteView.counts.communities} communities'),
|
_Badge('${site.siteView.counts.communities} communities'),
|
||||||
_Badge('${site.siteView.counts.posts} posts'),
|
_Badge('${site.siteView.counts.posts} posts'),
|
||||||
|
|
Loading…
Reference in New Issue