mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Improve video appearance
This commit is contained in:
parent
ce908d1b51
commit
44f417a0f2
@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:comunic/helpers/calls_helper.dart';
|
||||
import 'package:comunic/helpers/conversations_helper.dart';
|
||||
@ -478,7 +479,7 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
_canHideMenuBar ? Container() : _buildMembersArea(),
|
||||
_buildVideosArea()
|
||||
Expanded(child: LayoutBuilder(builder: _buildVideosArea))
|
||||
],
|
||||
);
|
||||
}
|
||||
@ -503,18 +504,41 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
}
|
||||
|
||||
/// Videos area
|
||||
Widget _buildVideosArea() {
|
||||
return Expanded(
|
||||
child: Stack(
|
||||
Widget _buildVideosArea(BuildContext context, BoxConstraints constraints) {
|
||||
final availableVideos = _membersList.readyPeers
|
||||
.where((f) => f.hasVideoStream && _renderers.containsKey(f.userID))
|
||||
.toList();
|
||||
|
||||
final rows = List<Row>();
|
||||
|
||||
var numberRows = sqrt(availableVideos.length).ceil();
|
||||
var numberCols = numberRows;
|
||||
|
||||
if (availableVideos.length == 2) numberRows = 1;
|
||||
|
||||
final videoWidth = constraints.maxWidth / numberCols;
|
||||
final videoHeight = constraints.maxHeight / numberRows;
|
||||
|
||||
for (int i = 0; i < numberRows; i++) {
|
||||
rows.add(Row(
|
||||
children: availableVideos
|
||||
.getRange(i * numberRows,
|
||||
min(availableVideos.length, i * numberRows + numberCols))
|
||||
.map((f) => Container(
|
||||
width: videoWidth,
|
||||
height: videoHeight,
|
||||
child: _buildMemberVideo(f.userID),
|
||||
))
|
||||
.toList(),
|
||||
));
|
||||
}
|
||||
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
// Remove peers videos
|
||||
Column(
|
||||
children: _membersList.readyPeers
|
||||
.where(
|
||||
(f) => f.hasVideoStream && _renderers.containsKey(f.userID))
|
||||
.map((f) => _buildMemberVideo(f.userID))
|
||||
.toList(),
|
||||
children: rows,
|
||||
),
|
||||
|
||||
// Local peer video
|
||||
@ -525,12 +549,11 @@ class _CallScreenState extends SafeState<CallScreen> {
|
||||
// Buttons bar
|
||||
_canHideMenuBar ? Container() : _buildFooterArea()
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMemberVideo(int peerID) {
|
||||
return Expanded(child: RTCVideoView(_renderers[peerID]));
|
||||
return RTCVideoView(_renderers[peerID]);
|
||||
}
|
||||
|
||||
Widget _buildLocalVideo() {
|
||||
|
Loading…
Reference in New Issue
Block a user