diff --git a/lib/ui/routes/main_route/tablet_route.dart b/lib/ui/routes/main_route/tablet_route.dart index 59f1dbf..d0549e0 100644 --- a/lib/ui/routes/main_route/tablet_route.dart +++ b/lib/ui/routes/main_route/tablet_route.dart @@ -15,7 +15,9 @@ class TabletRoute extends StatefulWidget implements MainRoute { _TabletRouteState createState() => _TabletRouteState(); } -class _TabletRouteState extends State { +class _TabletRouteState extends State implements MainController { + final _conversationsKey = GlobalKey(); + @override Widget build(BuildContext context) { return Scaffold( @@ -29,7 +31,11 @@ class _TabletRouteState extends State { Widget _buildBody() => Stack( children: [ Row(children: [_buildLeftPane(), _buildRightPane()]), - Positioned(right: 0, bottom: 0, child: ConversationsAreaWidget()) + Positioned( + right: 0, + bottom: 0, + child: ConversationsAreaWidget(key: _conversationsKey), + ) ], ); @@ -54,4 +60,44 @@ class _TabletRouteState extends State { ); Widget _buildRightPane() => Container(); + + @override + void openConversation(int convID, {fullScreen = false}) { + _conversationsKey.currentState.openConversations(convID); + } + + @override + void openGroup(int groupID) { + // TODO: implement openGroup + } + + @override + void openUserAccessDeniedPage(int userID) { + // TODO: implement openUserAccessDeniedPage + } + + @override + void openUserFriendsList(int userID) { + // TODO: implement openUserFriendsList + } + + @override + void openUserPage(int userID) { + // TODO: implement openUserPage + } + + @override + void popPage() { + // TODO: implement popPage + } + + @override + void push(Widget w, {bool hideNavBar}) { + // TODO: implement push + } + + @override + void startCall(int convID) { + // TODO: implement startCall + } } diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart new file mode 100644 index 0000000..8af78bc --- /dev/null +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart @@ -0,0 +1,25 @@ +import 'package:flutter/material.dart'; + +/// Single conversation window +/// +/// @author Pierre Hubert + +class ConversationWindow extends StatefulWidget { + final int convID; + + const ConversationWindow({ + Key key, + @required this.convID, + }) : assert(convID != null), + super(key: key); + + @override + _ConversationWindowState createState() => _ConversationWindowState(); +} + +class _ConversationWindowState extends State { + @override + Widget build(BuildContext context) { + return Card();//TODO : continue here + } +} diff --git a/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart b/lib/ui/widgets/tablet_mode/conversations/conversations_area_widget.dart index 730252d..2b43c74 100644 --- a/lib/ui/widgets/tablet_mode/conversations/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/conversation_window.dart'; import 'package:comunic/ui/widgets/tablet_mode/conversations/open_conversation_button_widget.dart'; import 'package:flutter/material.dart'; @@ -8,19 +9,30 @@ import 'package:flutter/material.dart'; /// @author Pierre class ConversationsAreaWidget extends StatefulWidget { + const ConversationsAreaWidget({Key key}) : super(key: key); + @override - _ConversationsAreaWidgetState createState() => - _ConversationsAreaWidgetState(); + ConversationsAreaWidgetState createState() => ConversationsAreaWidgetState(); } -class _ConversationsAreaWidgetState extends State { +class ConversationsAreaWidgetState extends State { + final _openConversations = Set(); + @override Widget build(BuildContext context) { return Row( - children: [_buildOpenButton()], + 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); } diff --git a/lib/ui/widgets/tablet_mode/memberships_panel.dart b/lib/ui/widgets/tablet_mode/memberships_panel.dart index 2ef5794..9108156 100644 --- a/lib/ui/widgets/tablet_mode/memberships_panel.dart +++ b/lib/ui/widgets/tablet_mode/memberships_panel.dart @@ -8,6 +8,7 @@ import 'package:comunic/lists/memberships_list.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/models/friend.dart'; import 'package:comunic/models/membership.dart'; +import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/group_icon_widget.dart'; import 'package:comunic/ui/widgets/group_membership_widget.dart'; @@ -169,6 +170,7 @@ class _MembershipsPanelState extends SafeState { ConversationsHelper.getConversationName(conversation, _usersList)), subtitle: Text(diffTimeFromNowToStr(membership.lastActive) + (conversation.isHavingCall ? "\n" + tr("Ongoing call") : "")), + onTap: () => MainController.of(context).openConversation(conversation.id), ), ); }