diff --git a/lib/lists/call_members_list.dart b/lib/lists/call_members_list.dart index 2692d48..b9d5250 100644 --- a/lib/lists/call_members_list.dart +++ b/lib/lists/call_members_list.dart @@ -5,4 +5,10 @@ import 'package:comunic/models/call_member.dart'; /// /// @author Pierre Hubert -class CallMembersList extends AbstractList {} \ No newline at end of file +class CallMembersList extends AbstractList { + /// Get the IDs of the users in this list + Set 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); +} diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index f83ba16..22aa7e7 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -1,10 +1,14 @@ import 'package:comunic/helpers/calls_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/users_list.dart'; import 'package:comunic/models/call_config.dart'; +import 'package:comunic/models/call_member.dart'; import 'package:comunic/models/conversation.dart'; import 'package:comunic/ui/widgets/comunic_back_button_widget.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/ui_utils.dart'; import 'package:flutter/material.dart'; @@ -35,6 +39,7 @@ class _CallScreenState extends SafeState { CallConfig _conf; var _error = false; CallMembersList _membersList; + UsersList _usersList; @override void initState() { @@ -67,7 +72,12 @@ class _CallScreenState extends SafeState { _conf = await CallsHelper.getConfig(); // 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) { print("Could not initialize call! $e\n$stack"); setState(() => _error = true); @@ -105,5 +115,31 @@ class _CallScreenState extends SafeState { child: Text(tr("Try again").toUpperCase()), ) ]); + + // Check if are not ready to show call UI + if (_membersList == null) return buildCenteredProgressBar(); + + return Column( + children: [_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())), + ), + ); } }