1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00

Identify conversation windows with keys

This commit is contained in:
Pierre HUBERT 2020-05-09 09:59:05 +02:00
parent 6cbe34379e
commit 150529a740

View File

@ -16,13 +16,13 @@ class ConversationsAreaWidget extends StatefulWidget {
}
class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
final _openConversations = Set<int>();
final _openConversations = Map<int, UniqueKey>();
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: _openConversations.map(_conversationWindow).toList()
children: _openConversations.map(_conversationWindow).values.toList()
..add(_buildOpenButton()),
);
}
@ -32,11 +32,17 @@ class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
/// Open a new conversation
void openConversations(int convID) {
setState(() => _openConversations.add(convID));
if (!_openConversations.containsKey(convID))
setState(() => _openConversations[convID] = UniqueKey());
}
Widget _conversationWindow(int convID) => ConversationWindow(
convID: convID,
onClose: () => setState(() => _openConversations.remove(convID)),
MapEntry<int, Widget> _conversationWindow(int convID, UniqueKey key) =>
MapEntry(
convID,
ConversationWindow(
key: key,
convID: convID,
onClose: () => setState(() => _openConversations.remove(convID)),
),
);
}