From e5ccedd1802a76e021e40d6e44990f13cfde8a3f Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 21 Apr 2020 18:14:10 +0200 Subject: [PATCH] Can toggle local stream visibility --- lib/ui/screens/call_screen.dart | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index 90fbd6d..a19a894 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -46,6 +46,7 @@ class _CallScreenState extends SafeState { final _peersConnections = Map(); final _renderers = Map(); MediaStream _localStream; + var _isLocalStreamVisible = true; bool get _canMakeVideoCall => _conversation.callCapabilities == CallCapabilities.VIDEO; @@ -337,6 +338,13 @@ class _CallScreenState extends SafeState { setState(() {}); } + /// Toggle local stream visibility + void _toggleLocalStreamVisibility() { + setState(() { + _isLocalStreamVisible = !_isLocalStreamVisible; + }); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -409,7 +417,9 @@ class _CallScreenState extends SafeState { ), // Local peer video - isStreamingVideo ? _buildLocalVideo() : Container(), + isStreamingVideo && _isLocalStreamVisible + ? _buildLocalVideo() + : Container(), ], )); } @@ -435,6 +445,14 @@ class _CallScreenState extends SafeState { child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + // Show / hide user video button + _FooterButton( + icon: Icon(_isLocalStreamVisible + ? Icons.visibility + : Icons.visibility_off), + onPressed: () => _toggleLocalStreamVisibility(), + ), + // Toggle audio button _FooterButton( onPressed: () => _toggleStreaming(false), @@ -467,8 +485,8 @@ class _FooterButton extends StatelessWidget { const _FooterButton({ Key key, - @required this.onPressed, @required this.icon, + @required this.onPressed, }) : assert(onPressed != null), assert(icon != null), super(key: key);