1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-23 05:19:22 +00:00
comunicmobile/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart

49 lines
1.5 KiB
Dart
Raw Normal View History

2020-05-09 06:17:52 +00:00
import 'package:comunic/ui/widgets/tablet_mode/conversations/conversation_window.dart';
import 'package:comunic/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart';
2020-05-09 04:49:05 +00:00
import 'package:flutter/material.dart';
/// Conversations area widget
///
/// This widget allow floating conversations in tablet mode
///
/// @author Pierre
class ConversationsAreaWidget extends StatefulWidget {
2020-05-09 06:17:52 +00:00
const ConversationsAreaWidget({Key key}) : super(key: key);
2020-05-09 04:49:05 +00:00
@override
2020-05-09 06:17:52 +00:00
ConversationsAreaWidgetState createState() => ConversationsAreaWidgetState();
2020-05-09 04:49:05 +00:00
}
2020-05-09 06:17:52 +00:00
class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
final _openConversations = Map<int, UniqueKey>();
2020-05-09 06:17:52 +00:00
2020-05-09 04:49:05 +00:00
@override
Widget build(BuildContext context) {
return Row(
2020-05-09 07:32:10 +00:00
crossAxisAlignment: CrossAxisAlignment.end,
children: _openConversations.map(_conversationWindow).values.toList()
2020-05-09 06:17:52 +00:00
..add(_buildOpenButton()),
2020-05-09 04:49:05 +00:00
);
}
/// Add a button to open new conversations
Widget _buildOpenButton() => OpenConversationButton();
2020-05-09 06:17:52 +00:00
/// Open a new conversation
void openConversations(int convID) {
if (!_openConversations.containsKey(convID))
setState(() => _openConversations[convID] = UniqueKey());
2020-05-09 06:17:52 +00:00
}
MapEntry<int, Widget> _conversationWindow(int convID, UniqueKey key) =>
MapEntry(
convID,
ConversationWindow(
key: key,
convID: convID,
onClose: () => setState(() => _openConversations.remove(convID)),
),
2020-05-09 07:30:46 +00:00
);
2020-05-09 04:49:05 +00:00
}