diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index 98fe75e..a23bbc1 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -32,10 +32,15 @@ class CallScreen extends StatefulWidget { /// This settings should be always true except for the small call window... final bool floatingButtons; + /// Use custom application bar. This function takes as parameter a nullable + /// String which is the title of the conversation + final PreferredSizeWidget Function(String) buildCustomAppBar; + const CallScreen({ Key key, @required this.convID, this.floatingButtons = true, + this.buildCustomAppBar, }) : assert(convID != null), assert(convID > 0), assert(floatingButtons != null), @@ -453,22 +458,26 @@ class _CallScreenState extends SafeState { return GestureDetector( onDoubleTap: () => _toggleMenuBarsVisibility(), child: Scaffold( - appBar: _canHideMenuBar - ? null - : AppBar( - leading: IconButton( - icon: Icon(Icons.arrow_back), - onPressed: () => _leaveCall(), - ), - title: _convName == null - ? CircularProgressIndicator() - : Text(_convName), - ), + appBar: _canHideMenuBar ? null : _buildAppBar(), body: _buildBody(), ), ); } + /// Build application bar + PreferredSizeWidget _buildAppBar() { + if (widget.buildCustomAppBar != null) + return widget.buildCustomAppBar(_convName); + + return AppBar( + leading: IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () => _leaveCall(), + ), + title: _convName == null ? CircularProgressIndicator() : Text(_convName), + ); + } + /// Build widget body Widget _buildBody() { // Handle errors diff --git a/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart b/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart index d1e8865..f18cef3 100644 --- a/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart +++ b/lib/ui/widgets/tablet_mode/calls/call_window_widget.dart @@ -1,20 +1,25 @@ import 'package:comunic/ui/screens/call_screen.dart'; +import 'package:comunic/ui/widgets/custom_app_bar_size.dart'; import 'package:comunic/ui/widgets/tablet_mode/calls/calls_area.dart'; +import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; /// Call window widget /// /// @author Pierre HUBERT -const _WindowSize = Size(500, 200); +const _WindowSize = Size(450, 200); class CallWindowWidget extends StatefulWidget { final int convID; + final void Function() onClose; const CallWindowWidget({ Key key, - this.convID, + @required this.convID, + @required this.onClose, }) : assert(convID != null), + assert(onClose != null), super(key: key); @override @@ -43,6 +48,19 @@ class _CallWindowWidgetState extends State { child: Draggable( child: Card( child: CallScreen( + buildCustomAppBar: (convName) => AppBarWrapper( + height: 30, + appBar: AppBar( + backgroundColor: Colors.black, + title: Text(convName == null ? tr("Loading...") : convName), + actions: [ + IconButton( + iconSize: 16, + icon: Icon(Icons.close), + onPressed: widget.onClose, + ) + ], + )), convID: widget.convID, floatingButtons: false, ), diff --git a/lib/ui/widgets/tablet_mode/calls/calls_area.dart b/lib/ui/widgets/tablet_mode/calls/calls_area.dart index 27aa4b8..d86a5ea 100644 --- a/lib/ui/widgets/tablet_mode/calls/calls_area.dart +++ b/lib/ui/widgets/tablet_mode/calls/calls_area.dart @@ -19,8 +19,13 @@ class CallsAreaState extends State { Widget build(BuildContext context) { return Stack( children: _openCalls - .map((convID, key) => - MapEntry(convID, CallWindowWidget(key: key, convID: convID))) + .map((convID, key) => MapEntry( + convID, + CallWindowWidget( + key: key, + convID: convID, + onClose: () => closeCall(convID), + ))) .values .toList(), ); @@ -34,4 +39,10 @@ class CallsAreaState extends State { }); } } + + /// Close a call + void closeCall(int convID) { + if (_openCalls.containsKey(convID)) + setState(() => _openCalls.remove(convID)); + } }