From 642820127c7b4cfbfe54c88281de86149675baab Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 9 May 2020 19:45:07 +0200 Subject: [PATCH] Ready to implement call system --- lib/ui/routes/main_route/tablet_route.dart | 9 ++++--- .../widgets/tablet_mode/calls/calls_area.dart | 26 +++++++++++++++++++ .../conversations/conversation_window.dart | 14 +++++++++- 3 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 lib/ui/widgets/tablet_mode/calls/calls_area.dart diff --git a/lib/ui/routes/main_route/tablet_route.dart b/lib/ui/routes/main_route/tablet_route.dart index 05ef9f8..586eb56 100644 --- a/lib/ui/routes/main_route/tablet_route.dart +++ b/lib/ui/routes/main_route/tablet_route.dart @@ -1,5 +1,6 @@ import 'package:comunic/ui/dialogs/screen_dialog.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart'; +import 'package:comunic/ui/widgets/tablet_mode/calls/calls_area.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'; @@ -20,6 +21,7 @@ class TabletRoute extends StatefulWidget implements MainRoute { class _TabletRouteState extends MainController { final _conversationsKey = GlobalKey(); + final _callsKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -38,7 +40,8 @@ class _TabletRouteState extends MainController { right: 0, bottom: 0, child: ConversationsAreaWidget(key: _conversationsKey), - ) + ), + CallsArea(key: _callsKey), ], ); @@ -101,9 +104,7 @@ class _TabletRouteState extends MainController { } @override - void startCall(int convID) { - // TODO: implement startCall - } + void startCall(int convID) => _callsKey.currentState.openCall(convID); @override void doPopPage() { diff --git a/lib/ui/widgets/tablet_mode/calls/calls_area.dart b/lib/ui/widgets/tablet_mode/calls/calls_area.dart new file mode 100644 index 0000000..134382a --- /dev/null +++ b/lib/ui/widgets/tablet_mode/calls/calls_area.dart @@ -0,0 +1,26 @@ +import 'package:comunic/utils/intl_utils.dart'; +import 'package:comunic/utils/ui_utils.dart'; +import 'package:flutter/material.dart'; + +/// Tablets mode calls area +/// +/// @author Pierre Hubert + +class CallsArea extends StatefulWidget { + const CallsArea({Key key}) : super(key: key); + + @override + CallsAreaState createState() => CallsAreaState(); +} + +class CallsAreaState extends State { + @override + Widget build(BuildContext context) { + return Stack(); + } + + /// Open a new call + void openCall(int convID) { + showSimpleSnack(context, tr("Open call $convID")); + } +} diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart index cf16a6c..d1efbf1 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart @@ -2,6 +2,7 @@ import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/helpers/events_helper.dart'; import 'package:comunic/models/conversation.dart'; import 'package:comunic/ui/dialogs/screen_dialog.dart'; +import 'package:comunic/ui/routes/main_route/main_route.dart'; import 'package:comunic/ui/routes/update_conversation_route.dart'; import 'package:comunic/ui/screens/conversation_members_screen.dart'; import 'package:comunic/ui/screens/conversation_screen.dart'; @@ -16,7 +17,7 @@ import 'package:flutter/material.dart'; /// /// @author Pierre Hubert -enum _Actions { OPEN_MEMBERS, OPEN_SETTINGS } +enum _Actions { START_CALL, OPEN_MEMBERS, OPEN_SETTINGS } class ConversationWindow extends StatefulWidget { final int convID; @@ -127,6 +128,13 @@ class _ConversationWindowState extends SafeState { action: [ PopupMenuButton<_Actions>( itemBuilder: (c) => [ + // Start a new call + PopupMenuItem( + child: Text(tr("Start call")), + value: _Actions.START_CALL, + enabled: _conversation.callCapabilities != CallCapabilities.NONE, + ), + // Show the list of members PopupMenuItem( child: Text(tr("Members")), @@ -151,6 +159,10 @@ class _ConversationWindowState extends SafeState { void _menuCallback(_Actions value) { switch (value) { + case _Actions.START_CALL: + MainController.of(context).startCall(_convID); + break; + case _Actions.OPEN_MEMBERS: _openMembersList(); break;