mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Display the list of members of the call
This commit is contained in:
parent
08c2ac32aa
commit
9154fe47e1
@ -5,4 +5,10 @@ import 'package:comunic/models/call_member.dart';
|
|||||||
///
|
///
|
||||||
/// @author Pierre Hubert
|
/// @author Pierre Hubert
|
||||||
|
|
||||||
class CallMembersList extends AbstractList<CallMember> {}
|
class CallMembersList extends AbstractList<CallMember> {
|
||||||
|
/// Get the IDs of the users in this list
|
||||||
|
Set<int> get usersID => this.map((f) => f.id).toSet();
|
||||||
|
|
||||||
|
/// Remove a specific member from this list
|
||||||
|
void removeUser(int userID) => this.removeWhere((f) => f.id == userID);
|
||||||
|
}
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
import 'package:comunic/helpers/calls_helper.dart';
|
import 'package:comunic/helpers/calls_helper.dart';
|
||||||
import 'package:comunic/helpers/conversations_helper.dart';
|
import 'package:comunic/helpers/conversations_helper.dart';
|
||||||
|
import 'package:comunic/helpers/users_helper.dart';
|
||||||
import 'package:comunic/lists/call_members_list.dart';
|
import 'package:comunic/lists/call_members_list.dart';
|
||||||
|
import 'package:comunic/lists/users_list.dart';
|
||||||
import 'package:comunic/models/call_config.dart';
|
import 'package:comunic/models/call_config.dart';
|
||||||
|
import 'package:comunic/models/call_member.dart';
|
||||||
import 'package:comunic/models/conversation.dart';
|
import 'package:comunic/models/conversation.dart';
|
||||||
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||||
|
import 'package:comunic/utils/account_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -35,6 +39,7 @@ class _CallScreenState extends SafeState<CallScreen> {
|
|||||||
CallConfig _conf;
|
CallConfig _conf;
|
||||||
var _error = false;
|
var _error = false;
|
||||||
CallMembersList _membersList;
|
CallMembersList _membersList;
|
||||||
|
UsersList _usersList;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -67,7 +72,12 @@ class _CallScreenState extends SafeState<CallScreen> {
|
|||||||
_conf = await CallsHelper.getConfig();
|
_conf = await CallsHelper.getConfig();
|
||||||
|
|
||||||
// Get current members of the call
|
// Get current members of the call
|
||||||
_membersList = await CallsHelper.getMembers(convID);
|
final membersList = await CallsHelper.getMembers(convID);
|
||||||
|
membersList.removeUser(userID());
|
||||||
|
_usersList = await UsersHelper().getListWithThrow(membersList.usersID);
|
||||||
|
_membersList = membersList;
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
print("Could not initialize call! $e\n$stack");
|
print("Could not initialize call! $e\n$stack");
|
||||||
setState(() => _error = true);
|
setState(() => _error = true);
|
||||||
@ -105,5 +115,31 @@ class _CallScreenState extends SafeState<CallScreen> {
|
|||||||
child: Text(tr("Try again").toUpperCase()),
|
child: Text(tr("Try again").toUpperCase()),
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Check if are not ready to show call UI
|
||||||
|
if (_membersList == null) return buildCenteredProgressBar();
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
children: <Widget>[_buildMembersArea()],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Build members area
|
||||||
|
Widget _buildMembersArea() {
|
||||||
|
return Center(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
children: _membersList
|
||||||
|
.map((f) => TextSpan(
|
||||||
|
text: _usersList.getUser(f.id).displayName + " ",
|
||||||
|
style: TextStyle(
|
||||||
|
color: f.status == MemberStatus.JOINED
|
||||||
|
? null
|
||||||
|
: Colors.green)))
|
||||||
|
.toList())),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user