From f179e7e1d5d2bccc7dec1269f3b02b1b351bc7d2 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 2 May 2020 11:28:28 +0200 Subject: [PATCH] Display members roles --- lib/ui/screens/group_members_screen.dart | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/ui/screens/group_members_screen.dart b/lib/ui/screens/group_members_screen.dart index b83bfc1..3028f3a 100644 --- a/lib/ui/screens/group_members_screen.dart +++ b/lib/ui/screens/group_members_screen.dart @@ -2,7 +2,9 @@ import 'package:comunic/helpers/groups_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/lists/group_members_list.dart'; import 'package:comunic/lists/users_list.dart'; +import 'package:comunic/models/group.dart'; import 'package:comunic/models/group_membership.dart'; +import 'package:comunic/ui/dialogs/multi_choices_dialog.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart'; import 'package:comunic/ui/widgets/comunic_back_button_widget.dart'; @@ -51,6 +53,7 @@ class _GroupMembersScreenState extends State { onReload: _refresh, onBuild: _buildBodyContent, errorMessage: tr("Could not load the list of members of this group!"), + showOldDataWhileUpdating: true, ); Widget _buildBodyContent() { @@ -59,6 +62,29 @@ class _GroupMembersScreenState extends State { ); } + List> get _membershipLevels => [ + MultiChoiceEntry( + id: GroupMembershipLevel.ADMINISTRATOR, + title: tr("Administrator"), + subtitle: + tr("Can change members privileges and change group settings")), + MultiChoiceEntry( + id: GroupMembershipLevel.MODERATOR, + title: tr("Moderator"), + subtitle: tr( + "Can always create posts, invite users and respond to membership request")), + MultiChoiceEntry( + id: GroupMembershipLevel.MEMBER, + title: tr("Member"), + subtitle: tr("Can access to all group posts")), + MultiChoiceEntry( + id: GroupMembershipLevel.PENDING, title: tr("Requested")), + MultiChoiceEntry( + id: GroupMembershipLevel.INVITED, title: tr("Invited")), + MultiChoiceEntry( + id: GroupMembershipLevel.VISITOR, title: tr("Visitor")), + ]; + ListTile _buildGroupMemberTile(GroupMembership membership) { final user = _users.getUser(membership.userID); @@ -67,6 +93,8 @@ class _GroupMembersScreenState extends State { user: user, ), title: Text(user.displayName), + subtitle: Text( + _membershipLevels.firstWhere((f) => f.id == membership.level).title), ); } }