1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Get and show the name of conversation members

This commit is contained in:
2019-04-23 17:29:58 +02:00
parent c94a294252
commit 7fc03ba15c
9 changed files with 199 additions and 13 deletions

View File

@ -0,0 +1,33 @@
import 'dart:collection';
import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/conversation.dart';
/// Conversations list
///
/// @author Pierre HUBERT
class ConversationsList extends ListBase<Conversation> {
final List<Conversation> _list = List();
UsersList users;
set length(l) => _list.length = l;
int get length => _list.length;
@override
Conversation operator [](int index) => _list[index];
@override
void operator []=(int index, Conversation value) => _list[index] = value;
/// Get the entire lists of users ID in this list
List<int> get allUsersID {
final List<int> list = List();
forEach((c) => c.members.forEach((id){
if(!list.contains(id))
list.add(id);
}));
return list;
}
}

34
lib/lists/users_list.dart Normal file
View File

@ -0,0 +1,34 @@
import 'dart:collection';
import 'package:comunic/models/user.dart';
/// Users list
///
/// @author Pierre HUBERT
class UsersList extends ListBase<User> {
List<User> _list = List();
int get length => _list.length;
set length(l) => _list.length = l;
@override
User operator [](int index) {
return _list[index];
}
@override
void operator []=(int index, User value) {
_list[index] = value;
}
/// Find a user with a specific ID
User getUser(int userID){
for(int i = 0; i < this.length; i++)
if(this[i].id == userID)
return this[i];
throw "User not found in the list!";
}
}