1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09: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 /// Remove a friend membership from the list
void removeFriend(int friendID) => remove(firstWhere( void removeFriend(int friendID) => remove(firstWhere(
(f) => f.type == MembershipType.FRIEND && f.friend.id == friendID)); (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/memberships_list.dart';
import 'package:comunic/lists/users_list.dart'; import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/friend.dart'; import 'package:comunic/models/friend.dart';
import 'package:comunic/models/group.dart';
import 'package:comunic/models/membership.dart'; import 'package:comunic/models/membership.dart';
import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart';
import 'package:comunic/ui/routes/main_route/page_info.dart'; import 'package:comunic/ui/routes/main_route/page_info.dart';
@ -159,8 +160,26 @@ class _MembershipsPanelState extends SafeState<MembershipsPanel> {
Widget _buildGroupMembership(Membership membership) { Widget _buildGroupMembership(Membership membership) {
final group = _groupsList.getGroup(membership.groupID); 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) { if (!group.isAtLeastMember) {
subtitle = GroupMembershipWidget( subtitle = GroupMembershipWidget(
group: group, group: group,
@ -169,28 +188,25 @@ class _MembershipsPanelState extends SafeState<MembershipsPanel> {
); );
} else { } else {
subtitle = Text(diffTimeFromNowToStr(membership.lastActive)); subtitle = Text(diffTimeFromNowToStr(membership.lastActive));
} } // Main group information
return Container( return ListTile(
color: widget.currentPage.type == PageType.GROUP_PAGE && leading: GroupIcon(
widget.currentPage.id == group.id group: group,
? Colors.grey.shade800 width: _MembershipIconsWidth,
: null,
child: ListTile(
leading: GroupIcon(
group: group,
width: _MembershipIconsWidth,
),
title: Text(group.displayName),
subtitle: subtitle,
onTap: () => MainController.of(context).openGroup(group.id),
), ),
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; final conversation = membership.conversation;
if (conversation.isGroupConversation && !allowGroup) return Container();
Color color; Color color;
if (conversation.isHavingCall) if (conversation.isHavingCall)
color = Color(0xFF815d1d); color = Color(0xFF815d1d);
@ -222,8 +238,7 @@ class _MembershipsPanelState extends SafeState<MembershipsPanel> {
), ),
subtitle: Text(diffTimeFromNowToStr(membership.lastActive) + subtitle: Text(diffTimeFromNowToStr(membership.lastActive) +
(conversation.isHavingCall ? "\n" + tr("Ongoing call") : "")), (conversation.isHavingCall ? "\n" + tr("Ongoing call") : "")),
onTap: () => MainController.of(context) onTap: () => MainController.of(context).openConversation(conversation),
.openConversationById(conversation.id, fullScreen: true),
trailing: conversation.isHavingCall trailing: conversation.isHavingCall
? FloatingActionButton( ? FloatingActionButton(
heroTag: null, heroTag: null,