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

43 lines
1.3 KiB
Dart

import 'package:comunic/ui/widgets/tablet_mode/conversations/conversation_window.dart';
import 'package:comunic/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart';
import 'package:flutter/material.dart';
/// Conversations area widget
///
/// This widget allow floating conversations in tablet mode
///
/// @author Pierre
class ConversationsAreaWidget extends StatefulWidget {
const ConversationsAreaWidget({Key key}) : super(key: key);
@override
ConversationsAreaWidgetState createState() => ConversationsAreaWidgetState();
}
class ConversationsAreaWidgetState extends State<ConversationsAreaWidget> {
final _openConversations = Set<int>();
@override
Widget build(BuildContext context) {
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: _openConversations.map(_conversationWindow).toList()
..add(_buildOpenButton()),
);
}
/// Add a button to open new conversations
Widget _buildOpenButton() => OpenConversationButton();
/// Open a new conversation
void openConversations(int convID) {
setState(() => _openConversations.add(convID));
}
Widget _conversationWindow(int convID) => ConversationWindow(
convID: convID,
onClose: () => setState(() => _openConversations.remove(convID)),
);
}