1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Update navbar

This commit is contained in:
Pierre HUBERT 2021-04-07 16:28:59 +02:00
parent 7497fc5c65
commit 662c4ab3eb
2 changed files with 38 additions and 18 deletions

View File

@ -34,4 +34,9 @@ class MembershipList extends AbstractList<Membership> {
/// 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<Membership> getGroupConversations(int groupID) => where((element) =>
element.type == MembershipType.CONVERSATION &&
element.conversation.groupID == groupID).toSet();
}

View File

@ -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<MembershipsPanel> {
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<MembershipsPanel> {
);
} 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<MembershipsPanel> {
),
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,