diff --git a/lib/lists/memberships_list.dart b/lib/lists/memberships_list.dart index dcfa001..eae92bc 100644 --- a/lib/lists/memberships_list.dart +++ b/lib/lists/memberships_list.dart @@ -34,4 +34,9 @@ class MembershipList extends AbstractList { /// Remove a friend membership from the list void removeFriend(int friendID) => remove(firstWhere( (f) => f.type == MembershipType.FRIEND && f.friend.id == friendID)); + + /// Get the list of conversations of a group + Set getGroupConversations(int groupID) => where((element) => + element.type == MembershipType.CONVERSATION && + element.conversation.groupID == groupID).toSet(); } diff --git a/lib/ui/widgets/tablet_mode/memberships_panel.dart b/lib/ui/widgets/tablet_mode/memberships_panel.dart index bd22818..32edff6 100644 --- a/lib/ui/widgets/tablet_mode/memberships_panel.dart +++ b/lib/ui/widgets/tablet_mode/memberships_panel.dart @@ -7,6 +7,7 @@ import 'package:comunic/lists/groups_list.dart'; import 'package:comunic/lists/memberships_list.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/models/friend.dart'; +import 'package:comunic/models/group.dart'; import 'package:comunic/models/membership.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/routes/main_route/page_info.dart'; @@ -159,8 +160,26 @@ class _MembershipsPanelState extends SafeState { Widget _buildGroupMembership(Membership membership) { final group = _groupsList.getGroup(membership.groupID); - Widget subtitle; + return Container( + color: widget.currentPage.type == PageType.GROUP_PAGE && + widget.currentPage.id == group.id + ? Colors.grey.shade800 + : null, + child: Column( + children: [_buildMainGroupInformationTile(membership, group)] + ..addAll(_membershipList + .getGroupConversations(group.id) + .map((e) => Padding( + padding: const EdgeInsets.only(left: 30.0), + child: _buildConversationMembership(e, true), + )) + .toList()), + ), + ); + } + Widget _buildMainGroupInformationTile(Membership membership, Group group) { + Widget subtitle; if (!group.isAtLeastMember) { subtitle = GroupMembershipWidget( group: group, @@ -169,28 +188,25 @@ class _MembershipsPanelState extends SafeState { ); } else { subtitle = Text(diffTimeFromNowToStr(membership.lastActive)); - } + } // Main group information - return Container( - color: widget.currentPage.type == PageType.GROUP_PAGE && - widget.currentPage.id == group.id - ? Colors.grey.shade800 - : null, - child: ListTile( - leading: GroupIcon( - group: group, - width: _MembershipIconsWidth, - ), - title: Text(group.displayName), - subtitle: subtitle, - onTap: () => MainController.of(context).openGroup(group.id), + return ListTile( + leading: GroupIcon( + group: group, + width: _MembershipIconsWidth, ), + title: Text(group.displayName), + subtitle: subtitle, + onTap: () => MainController.of(context).openGroup(group.id), ); } - Widget _buildConversationMembership(Membership membership) { + Widget _buildConversationMembership(Membership membership, + [bool allowGroup = false]) { final conversation = membership.conversation; + if (conversation.isGroupConversation && !allowGroup) return Container(); + Color color; if (conversation.isHavingCall) color = Color(0xFF815d1d); @@ -222,8 +238,7 @@ class _MembershipsPanelState extends SafeState { ), subtitle: Text(diffTimeFromNowToStr(membership.lastActive) + (conversation.isHavingCall ? "\n" + tr("Ongoing call") : "")), - onTap: () => MainController.of(context) - .openConversationById(conversation.id, fullScreen: true), + onTap: () => MainController.of(context).openConversation(conversation), trailing: conversation.isHavingCall ? FloatingActionButton( heroTag: null,