1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-25 06:19:22 +00:00

Can start private conversation from directory pane

This commit is contained in:
Pierre HUBERT 2021-04-25 17:15:27 +02:00
parent c04f85c40b
commit 38d3f4de8d

View File

@ -7,6 +7,8 @@ import 'package:comunic/models/group_membership.dart';
import 'package:comunic/models/user.dart'; import 'package:comunic/models/user.dart';
import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart';
import 'package:comunic/ui/widgets/async_screen_widget.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart';
import 'package:comunic/utils/account_utils.dart';
import 'package:comunic/utils/conversations_utils.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -14,6 +16,8 @@ import 'package:flutter/material.dart';
/// ///
/// @author Pierre Hubert /// @author Pierre Hubert
enum _PopupMenuActions { PRIVATE_CONVERSATION }
class ForezDirectoryScreen extends StatefulWidget { class ForezDirectoryScreen extends StatefulWidget {
@override @override
_ForezDirectoryScreenState createState() => _ForezDirectoryScreenState(); _ForezDirectoryScreenState createState() => _ForezDirectoryScreenState();
@ -39,14 +43,52 @@ class _ForezDirectoryScreenState extends State<ForezDirectoryScreen> {
); );
Widget onBuild() => ListView.builder( Widget onBuild() => ListView.builder(
itemBuilder: (c, i) => itemBuilder: (c, i) => _ForezMemberTile(
_buildMember(_members[i], _users.getUser(_members[i].userID)), member: _members[i],
user: _users.getUser(_members[i].userID),
selectedAction: _doPopupMenuAction,
),
itemCount: _members.length, itemCount: _members.length,
); );
Widget _buildMember(GroupMembership membership, User user) => ListTile( void _doPopupMenuAction(_PopupMenuActions action, User user) async {
switch (action) {
case _PopupMenuActions.PRIVATE_CONVERSATION:
openPrivateConversation(context, user.id);
break;
}
}
}
class _ForezMemberTile extends StatelessWidget {
final User user;
final GroupMembership member;
final Function(_PopupMenuActions, User) selectedAction;
const _ForezMemberTile({
Key key,
@required this.user,
@required this.member,
@required this.selectedAction,
}) : super(key: key);
@override
Widget build(BuildContext context) => ListTile(
leading: AccountImageWidget(user: user), leading: AccountImageWidget(user: user),
title: Text(user.fullName), title: Text(user.fullName),
subtitle: Text(membership.membershipText), subtitle: Text(member.membershipText),
trailing: user.id == userID()
? null
: PopupMenuButton(
itemBuilder: (c) => popupMenuItems,
onSelected: (a) => selectedAction(a, user),
),
); );
List<PopupMenuItem<_PopupMenuActions>> get popupMenuItems => [
PopupMenuItem(
child: Text(tr("Private conversation")),
value: _PopupMenuActions.PRIVATE_CONVERSATION,
),
];
} }