1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-26 06:49:22 +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 _renderers = Map<int, RTCVideoRenderer>();
MediaStream _localStream;
var _isLocalStreamVisible = true;
bool get _canMakeVideoCall =>
_conversation.callCapabilities == CallCapabilities.VIDEO;
@ -337,6 +338,13 @@ class _CallScreenState extends SafeState<CallScreen> {
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<CallScreen> {
),
// Local peer video
isStreamingVideo ? _buildLocalVideo() : Container(),
isStreamingVideo && _isLocalStreamVisible
? _buildLocalVideo()
: Container(),
],
));
}
@ -435,6 +445,14 @@ class _CallScreenState extends SafeState<CallScreen> {
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
// 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);