From fe17f81a40416ff25bb535c90c26e587c43a260c Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 9 May 2020 07:07:14 +0200 Subject: [PATCH] Display the list of conversation to open one --- lib/ui/routes/main_route/tablet_route.dart | 2 +- .../conversations_area_widget.dart | 9 +--- .../open_conversation_button_widget.dart | 43 +++++++++++++++++++ 3 files changed, 46 insertions(+), 8 deletions(-) rename lib/ui/widgets/tablet_mode/{ => conversations}/conversations_area_widget.dart (73%) create mode 100644 lib/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart diff --git a/lib/ui/routes/main_route/tablet_route.dart b/lib/ui/routes/main_route/tablet_route.dart index 1eb02d7..59f1dbf 100644 --- a/lib/ui/routes/main_route/tablet_route.dart +++ b/lib/ui/routes/main_route/tablet_route.dart @@ -1,5 +1,5 @@ import 'package:comunic/ui/routes/main_route/main_route.dart'; -import 'package:comunic/ui/widgets/tablet_mode/conversations_area_widget.dart'; +import 'package:comunic/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart'; import 'package:comunic/ui/widgets/tablet_mode/current_user_panel.dart'; import 'package:comunic/ui/widgets/tablet_mode/global_search_field.dart'; import 'package:comunic/ui/widgets/tablet_mode/memberships_panel.dart'; diff --git a/lib/ui/widgets/tablet_mode/conversations_area_widget.dart b/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart similarity index 73% rename from lib/ui/widgets/tablet_mode/conversations_area_widget.dart rename to lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart index 32e7766..730252d 100644 --- a/lib/ui/widgets/tablet_mode/conversations_area_widget.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart @@ -1,3 +1,4 @@ +import 'package:comunic/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart'; import 'package:flutter/material.dart'; /// Conversations area widget @@ -21,11 +22,5 @@ class _ConversationsAreaWidgetState extends State { } /// Add a button to open new conversations - Widget _buildOpenButton() => Padding( - padding: const EdgeInsets.all(15.0), - child: FloatingActionButton( - onPressed: () {}, - child: Icon(Icons.message), - ), - ); + Widget _buildOpenButton() => OpenConversationButton(); } diff --git a/lib/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart b/lib/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart new file mode 100644 index 0000000..809864f --- /dev/null +++ b/lib/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart @@ -0,0 +1,43 @@ +import 'package:comunic/ui/screens/conversations_list_screen.dart'; +import 'package:flutter/material.dart'; + +/// This buttons open a menu +/// to choose a conversation to open +/// +/// @author Pierre Hubert + +class OpenConversationButton extends StatefulWidget { + @override + _OpenConversationButtonState createState() => _OpenConversationButtonState(); +} + +class _OpenConversationButtonState extends State { + bool _showConversationsList = false; + + void _setShowConversationsList(bool s) => + setState(() => _showConversationsList = s); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + _showConversationsList ? _buildConversationsList() : Container(), + FloatingActionButton( + onPressed: () => _setShowConversationsList(!_showConversationsList), + child: Icon(_showConversationsList ? Icons.close : Icons.message), + ) + ], + ), + ); + } + + Widget _buildConversationsList() => Container( + width: 300, + height: 500, + child: Card( + child: ConversationsListScreen(), + )); +}