mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-12-25 12:28:50 +00:00
Identify conversation windows with keys
This commit is contained in:
parent
6cbe34379e
commit
150529a740
@ -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)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user