mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 00:05:16 +00:00
Open private conversation from friends list
This commit is contained in:
@ -9,16 +9,18 @@ import 'package:flutter/material.dart';
|
||||
///
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
enum _FriendMenuChoices { REMOVE, TOGGLE_FOLLOWING }
|
||||
enum _FriendMenuChoices { REMOVE, TOGGLE_FOLLOWING, PRIVATE_CONVERSATION }
|
||||
|
||||
typedef OnRequestDeleteFriend = void Function(Friend);
|
||||
typedef OnSetFollowing = void Function(Friend, bool);
|
||||
typedef OnOpenPrivateConversation = void Function(Friend);
|
||||
|
||||
class AcceptedFriendTile extends StatelessWidget {
|
||||
final Friend friend;
|
||||
final User user;
|
||||
final OnRequestDeleteFriend onRequestDelete;
|
||||
final OnSetFollowing onSetFollowing;
|
||||
final OnOpenPrivateConversation onOpenPrivateConversation;
|
||||
|
||||
const AcceptedFriendTile({
|
||||
Key key,
|
||||
@ -26,10 +28,12 @@ class AcceptedFriendTile extends StatelessWidget {
|
||||
@required this.user,
|
||||
@required this.onRequestDelete,
|
||||
@required this.onSetFollowing,
|
||||
@required this.onOpenPrivateConversation,
|
||||
}) : assert(friend != null),
|
||||
assert(user != null),
|
||||
assert(onRequestDelete != null),
|
||||
assert(onSetFollowing != null),
|
||||
assert(onOpenPrivateConversation != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
@ -49,6 +53,13 @@ class AcceptedFriendTile extends StatelessWidget {
|
||||
),
|
||||
trailing: PopupMenuButton<_FriendMenuChoices>(
|
||||
itemBuilder: (c) => [
|
||||
//Open a private conversation
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Private conversation")),
|
||||
value: _FriendMenuChoices.PRIVATE_CONVERSATION,
|
||||
),
|
||||
|
||||
// Update following status
|
||||
PopupMenuItem(
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
@ -61,6 +72,8 @@ class AcceptedFriendTile extends StatelessWidget {
|
||||
),
|
||||
value: _FriendMenuChoices.TOGGLE_FOLLOWING,
|
||||
),
|
||||
|
||||
// Remove the friend from the list
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Remove")),
|
||||
value: _FriendMenuChoices.REMOVE,
|
||||
@ -75,6 +88,11 @@ class AcceptedFriendTile extends StatelessWidget {
|
||||
if (value == null) return;
|
||||
|
||||
switch (value) {
|
||||
// Open private conversation
|
||||
case _FriendMenuChoices.PRIVATE_CONVERSATION:
|
||||
onOpenPrivateConversation(friend);
|
||||
break;
|
||||
|
||||
//Toggle following status
|
||||
case _FriendMenuChoices.TOGGLE_FOLLOWING:
|
||||
onSetFollowing(friend, !friend.following);
|
||||
|
Reference in New Issue
Block a user