1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 04:49:21 +00:00

Ready to implement page show

This commit is contained in:
Pierre HUBERT 2021-04-25 17:49:55 +02:00
parent 8e8a3c711d
commit 8802a52816
2 changed files with 20 additions and 3 deletions

View File

@ -67,6 +67,7 @@ class _ForezDirectoryScreenState extends State<ForezDirectoryScreen> {
itemBuilder: (c, i) => _ForezMemberTile( itemBuilder: (c, i) => _ForezMemberTile(
member: _members[i], member: _members[i],
user: _users.getUser(_members[i].userID), user: _users.getUser(_members[i].userID),
onTap: (user) => _openUserProfile(user),
selectedAction: _doPopupMenuAction, selectedAction: _doPopupMenuAction,
), ),
itemCount: _members.length, itemCount: _members.length,
@ -101,9 +102,17 @@ class _ForezDirectoryScreenState extends State<ForezDirectoryScreen> {
} }
void _doSearch() async { void _doSearch() async {
final user = await searchUser(context, UsersList()..addAll(_users)); final user = await searchUser(
print("found ${user?.fullName}"); context,
//if (user != null) _openUserProfile(user); UsersList()
..addAll(_users.where((u) =>
_members.where((m) => m.userID == u.id).first.isAtLeastMember)));
if (user != null) _openUserProfile(user);
}
void _openUserProfile(User user) {
print("Open user profile ${user.fullName}");
} }
} }
@ -111,12 +120,14 @@ class _ForezMemberTile extends StatelessWidget {
final User user; final User user;
final GroupMembership member; final GroupMembership member;
final Function(_PopupMenuActions, User) selectedAction; final Function(_PopupMenuActions, User) selectedAction;
final Function(User) onTap;
const _ForezMemberTile({ const _ForezMemberTile({
Key key, Key key,
@required this.user, @required this.user,
@required this.member, @required this.member,
@required this.selectedAction, @required this.selectedAction,
@required this.onTap,
}) : super(key: key); }) : super(key: key);
@override @override
@ -127,6 +138,7 @@ class _ForezMemberTile extends StatelessWidget {
trailing: member.level == GroupMembershipLevel.PENDING trailing: member.level == GroupMembershipLevel.PENDING
? _buildRequestedButton() ? _buildRequestedButton()
: _buildPopupMenuButton(), : _buildPopupMenuButton(),
onTap: member.isAtLeastMember ? () => onTap(user) : null,
); );
Widget _buildPopupMenuButton() => user.id == userID() Widget _buildPopupMenuButton() => user.id == userID()

View File

@ -22,4 +22,9 @@ class GroupMembership {
assert(level != null); assert(level != null);
String get membershipText => membershipToText(level); String get membershipText => membershipToText(level);
bool get isAtLeastMember =>
level == GroupMembershipLevel.ADMINISTRATOR ||
level == GroupMembershipLevel.MODERATOR ||
level == GroupMembershipLevel.MEMBER;
} }