diff --git a/lib/models/group.dart b/lib/models/group.dart index aac3026..b28e3eb 100644 --- a/lib/models/group.dart +++ b/lib/models/group.dart @@ -61,6 +61,10 @@ class Group { bool get isAdmin => membershipLevel == GroupMembershipLevel.ADMINISTRATOR; + bool get isAtLeastModerator => + membershipLevel == GroupMembershipLevel.ADMINISTRATOR || + membershipLevel == GroupMembershipLevel.MODERATOR; + bool get canCreatePost => membershipLevel == GroupMembershipLevel.ADMINISTRATOR || membershipLevel == GroupMembershipLevel.MODERATOR || diff --git a/lib/ui/screens/authorized_group_page_screen.dart b/lib/ui/screens/authorized_group_page_screen.dart index 1497529..60342ed 100644 --- a/lib/ui/screens/authorized_group_page_screen.dart +++ b/lib/ui/screens/authorized_group_page_screen.dart @@ -2,6 +2,7 @@ import 'package:comunic/enums/post_target.dart'; import 'package:comunic/helpers/posts_helper.dart'; import 'package:comunic/models/advanced_group_info.dart'; import 'package:comunic/ui/routes/main_route.dart'; +import 'package:comunic/ui/screens/group_members_screen.dart'; import 'package:comunic/ui/screens/group_settings_screen.dart'; import 'package:comunic/ui/widgets/group_following_widget.dart'; import 'package:comunic/ui/widgets/group_icon_widget.dart'; @@ -19,7 +20,7 @@ import 'package:flutter/material.dart'; /// /// @author Pierre Hubert -enum _MenuItems { OPEN_SETTINGS } +enum _MenuItems { OPEN_MEMBERS, OPEN_SETTINGS } class AuthorizedGroupPageScreen extends StatefulWidget { final AdvancedGroupInfo advancedGroupInfo; @@ -107,11 +108,16 @@ class _AuthorizedGroupPageScreenState extends State { ), PopupMenuButton<_MenuItems>( itemBuilder: (c) => [ + PopupMenuItem( + child: Text(tr("Group members")), + value: _MenuItems.OPEN_MEMBERS, + enabled: _group.isAtLeastModerator, + ), PopupMenuItem( child: Text(tr("Group settings")), value: _MenuItems.OPEN_SETTINGS, enabled: _group.isAdmin, - ) + ), ], onSelected: _handleMenuSelection, ), @@ -146,6 +152,10 @@ class _AuthorizedGroupPageScreenState extends State { /// Handles menu selection void _handleMenuSelection(_MenuItems item) { switch (item) { + case _MenuItems.OPEN_MEMBERS: + MainController.of(context).push(GroupMembersScreen(groupID: _group.id)); + break; + case _MenuItems.OPEN_SETTINGS: MainController.of(context) .push(GroupSettingsScreen(groupID: _group.id)); diff --git a/lib/ui/screens/group_members_screen.dart b/lib/ui/screens/group_members_screen.dart new file mode 100644 index 0000000..89a7076 --- /dev/null +++ b/lib/ui/screens/group_members_screen.dart @@ -0,0 +1,30 @@ +import 'package:comunic/ui/widgets/comunic_back_button_widget.dart'; +import 'package:comunic/utils/intl_utils.dart'; +import 'package:flutter/material.dart'; + +/// Group members screen +/// +/// @author Pierre HUBERT + +class GroupMembersScreen extends StatefulWidget { + final int groupID; + + const GroupMembersScreen({Key key, this.groupID}) + : assert(groupID != null), + super(key: key); + + @override + _GroupMembersScreenState createState() => _GroupMembersScreenState(); +} + +class _GroupMembersScreenState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + leading: ComunicBackButton(), + title: Text(tr("Group members")), + ), + ); + } +}