1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Can toggle local stream visibility

This commit is contained in:
Pierre HUBERT 2020-04-21 18:14:10 +02:00
parent 6a9e0e36c1
commit e5ccedd180

View File

@ -46,6 +46,7 @@ class _CallScreenState extends SafeState<CallScreen> {
final _peersConnections = Map<int, RTCPeerConnection>(); final _peersConnections = Map<int, RTCPeerConnection>();
final _renderers = Map<int, RTCVideoRenderer>(); final _renderers = Map<int, RTCVideoRenderer>();
MediaStream _localStream; MediaStream _localStream;
var _isLocalStreamVisible = true;
bool get _canMakeVideoCall => bool get _canMakeVideoCall =>
_conversation.callCapabilities == CallCapabilities.VIDEO; _conversation.callCapabilities == CallCapabilities.VIDEO;
@ -337,6 +338,13 @@ class _CallScreenState extends SafeState<CallScreen> {
setState(() {}); setState(() {});
} }
/// Toggle local stream visibility
void _toggleLocalStreamVisibility() {
setState(() {
_isLocalStreamVisible = !_isLocalStreamVisible;
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -409,7 +417,9 @@ class _CallScreenState extends SafeState<CallScreen> {
), ),
// Local peer video // Local peer video
isStreamingVideo ? _buildLocalVideo() : Container(), isStreamingVideo && _isLocalStreamVisible
? _buildLocalVideo()
: Container(),
], ],
)); ));
} }
@ -435,6 +445,14 @@ class _CallScreenState extends SafeState<CallScreen> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
// Show / hide user video button
_FooterButton(
icon: Icon(_isLocalStreamVisible
? Icons.visibility
: Icons.visibility_off),
onPressed: () => _toggleLocalStreamVisibility(),
),
// Toggle audio button // Toggle audio button
_FooterButton( _FooterButton(
onPressed: () => _toggleStreaming(false), onPressed: () => _toggleStreaming(false),
@ -467,8 +485,8 @@ class _FooterButton extends StatelessWidget {
const _FooterButton({ const _FooterButton({
Key key, Key key,
@required this.onPressed,
@required this.icon, @required this.icon,
@required this.onPressed,
}) : assert(onPressed != null), }) : assert(onPressed != null),
assert(icon != null), assert(icon != null),
super(key: key); super(key: key);