mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +00:00
Can update a conversation from the list of conversations
This commit is contained in:
parent
db02a41b75
commit
8d1de2aac8
@ -5,6 +5,7 @@ import 'package:comunic/lists/conversations_list.dart';
|
|||||||
import 'package:comunic/models/conversation.dart';
|
import 'package:comunic/models/conversation.dart';
|
||||||
import 'package:comunic/ui/routes/conversation_route.dart';
|
import 'package:comunic/ui/routes/conversation_route.dart';
|
||||||
import 'package:comunic/ui/routes/create_conversation_route.dart';
|
import 'package:comunic/ui/routes/create_conversation_route.dart';
|
||||||
|
import 'package:comunic/ui/routes/update_conversation_route.dart';
|
||||||
import 'package:comunic/ui/tiles/conversation_tile.dart';
|
import 'package:comunic/ui/tiles/conversation_tile.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
@ -106,7 +107,18 @@ class _ConversationScreenState extends State<ConversationsListScreen> {
|
|||||||
.push(MaterialPageRoute(builder: (c) => CreateConversationRoute()));
|
.push(MaterialPageRoute(builder: (c) => CreateConversationRoute()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles conversation deletion request
|
/// Handle conversations updated requests
|
||||||
|
void _updateConversation(Conversation conversation) {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (c) => UpdateConversationRoute(
|
||||||
|
conversationID: conversation.id,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Handle conversation deletion request
|
||||||
Future<void> _requestDeleteConversation(Conversation conversation) async {
|
Future<void> _requestDeleteConversation(Conversation conversation) async {
|
||||||
final result = await showDialog<bool>(
|
final result = await showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
@ -166,6 +178,7 @@ class _ConversationScreenState extends State<ConversationsListScreen> {
|
|||||||
onOpen: (c) {
|
onOpen: (c) {
|
||||||
_openConversation(context, c.id);
|
_openConversation(context, c.id);
|
||||||
},
|
},
|
||||||
|
onRequestUpdate: _updateConversation,
|
||||||
onRequestDelete: _requestDeleteConversation,
|
onRequestDelete: _requestDeleteConversation,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -11,24 +11,28 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
typedef OpenConversationCallback = void Function(Conversation);
|
typedef OpenConversationCallback = void Function(Conversation);
|
||||||
typedef RequestDeleteConversationCallback = void Function(Conversation);
|
typedef RequestDeleteConversationCallback = void Function(Conversation);
|
||||||
|
typedef RequestUpdateConversationCallback = void Function(Conversation);
|
||||||
|
|
||||||
enum _PopupMenuChoices { DELETE }
|
enum _PopupMenuChoices { UPDATE, DELETE }
|
||||||
|
|
||||||
class ConversationTile extends StatelessWidget {
|
class ConversationTile extends StatelessWidget {
|
||||||
final Conversation conversation;
|
final Conversation conversation;
|
||||||
final UsersList usersList;
|
final UsersList usersList;
|
||||||
final OpenConversationCallback onOpen;
|
final OpenConversationCallback onOpen;
|
||||||
|
final RequestUpdateConversationCallback onRequestUpdate;
|
||||||
final RequestDeleteConversationCallback onRequestDelete;
|
final RequestDeleteConversationCallback onRequestDelete;
|
||||||
|
|
||||||
const ConversationTile(
|
const ConversationTile({
|
||||||
{Key key,
|
Key key,
|
||||||
@required this.conversation,
|
@required this.conversation,
|
||||||
@required this.usersList,
|
@required this.usersList,
|
||||||
@required this.onOpen,
|
@required this.onOpen,
|
||||||
@required this.onRequestDelete})
|
@required this.onRequestUpdate,
|
||||||
: assert(conversation != null),
|
@required this.onRequestDelete,
|
||||||
|
}) : assert(conversation != null),
|
||||||
assert(usersList != null),
|
assert(usersList != null),
|
||||||
assert(onOpen != null),
|
assert(onOpen != null),
|
||||||
|
assert(onRequestUpdate != null),
|
||||||
assert(onRequestDelete != null),
|
assert(onRequestDelete != null),
|
||||||
super(key: key);
|
super(key: key);
|
||||||
|
|
||||||
@ -90,6 +94,10 @@ class ConversationTile extends StatelessWidget {
|
|||||||
// Trailing information
|
// Trailing information
|
||||||
trailing: PopupMenuButton<_PopupMenuChoices>(
|
trailing: PopupMenuButton<_PopupMenuChoices>(
|
||||||
itemBuilder: (b) => <PopupMenuEntry<_PopupMenuChoices>>[
|
itemBuilder: (b) => <PopupMenuEntry<_PopupMenuChoices>>[
|
||||||
|
PopupMenuItem(
|
||||||
|
child: Text(tr("Update")),
|
||||||
|
value: _PopupMenuChoices.UPDATE,
|
||||||
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(tr("Delete")),
|
child: Text(tr("Delete")),
|
||||||
value: _PopupMenuChoices.DELETE,
|
value: _PopupMenuChoices.DELETE,
|
||||||
@ -103,6 +111,10 @@ class ConversationTile extends StatelessWidget {
|
|||||||
/// Method called each time an option of the menu is selected
|
/// Method called each time an option of the menu is selected
|
||||||
void _conversationMenuCallback(_PopupMenuChoices c) {
|
void _conversationMenuCallback(_PopupMenuChoices c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case _PopupMenuChoices.UPDATE:
|
||||||
|
onRequestUpdate(conversation);
|
||||||
|
break;
|
||||||
|
|
||||||
case _PopupMenuChoices.DELETE:
|
case _PopupMenuChoices.DELETE:
|
||||||
onRequestDelete(conversation);
|
onRequestDelete(conversation);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user