1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-02 01:36:27 +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> { class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
final _openConversations = Set<int>(); final _openConversations = Map<int, UniqueKey>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Row( return Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: _openConversations.map(_conversationWindow).toList() children: _openConversations.map(_conversationWindow).values.toList()
..add(_buildOpenButton()), ..add(_buildOpenButton()),
); );
} }
@ -32,11 +32,17 @@ class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
/// Open a new conversation /// Open a new conversation
void openConversations(int convID) { void openConversations(int convID) {
setState(() => _openConversations.add(convID)); if (!_openConversations.containsKey(convID))
setState(() => _openConversations[convID] = UniqueKey());
} }
Widget _conversationWindow(int convID) => ConversationWindow( MapEntry<int, Widget> _conversationWindow(int convID, UniqueKey key) =>
MapEntry(
convID,
ConversationWindow(
key: key,
convID: convID, convID: convID,
onClose: () => setState(() => _openConversations.remove(convID)), onClose: () => setState(() => _openConversations.remove(convID)),
),
); );
} }