mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Can delete a conversation from the list of conversations
This commit is contained in:
@ -10,20 +10,26 @@ import 'package:flutter/material.dart';
|
||||
/// @author Pierre HUBERT
|
||||
|
||||
typedef OpenConversationCallback = void Function(Conversation);
|
||||
typedef RequestDeleteConversationCallback = void Function(Conversation);
|
||||
|
||||
enum _PopupMenuChoices { DELETE }
|
||||
|
||||
class ConversationTile extends StatelessWidget {
|
||||
final Conversation conversation;
|
||||
final UsersList usersList;
|
||||
final OpenConversationCallback onOpen;
|
||||
final RequestDeleteConversationCallback onRequestDelete;
|
||||
|
||||
const ConversationTile(
|
||||
{Key key,
|
||||
@required this.conversation,
|
||||
@required this.usersList,
|
||||
@required this.onOpen})
|
||||
@required this.onOpen,
|
||||
@required this.onRequestDelete})
|
||||
: assert(conversation != null),
|
||||
assert(usersList != null),
|
||||
assert(onOpen != null),
|
||||
assert(onRequestDelete != null),
|
||||
super(key: key);
|
||||
|
||||
_buildSubInformation(IconData icon, String content) {
|
||||
@ -80,6 +86,26 @@ class ConversationTile extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// Trailing information
|
||||
trailing: PopupMenuButton<_PopupMenuChoices>(
|
||||
itemBuilder: (b) => <PopupMenuEntry<_PopupMenuChoices>>[
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Delete")),
|
||||
value: _PopupMenuChoices.DELETE,
|
||||
)
|
||||
],
|
||||
onSelected: _conversationMenuCallback,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Method called each time an option of the menu is selected
|
||||
void _conversationMenuCallback(_PopupMenuChoices c) {
|
||||
switch (c) {
|
||||
case _PopupMenuChoices.DELETE:
|
||||
onRequestDelete(conversation);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user