1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-25 12:28:50 +00:00

Display the list of members of a conversation

This commit is contained in:
Pierre HUBERT 2020-05-09 12:37:06 +02:00
parent f45bcd691e
commit 67c217715a
2 changed files with 68 additions and 3 deletions

View File

@ -0,0 +1,66 @@
import 'package:comunic/helpers/conversations_helper.dart';
import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/conversation.dart';
import 'package:comunic/ui/widgets/account_image_widget.dart';
import 'package:comunic/ui/widgets/async_screen_widget.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart';
/// Conversation members screen
///
/// @author Pierre Hubert
class ConversationMembersScreen extends StatefulWidget {
final int convID;
const ConversationMembersScreen({
Key key,
@required this.convID,
}) : assert(convID != null),
super(key: key);
@override
_ConversationMembersScreenState createState() =>
_ConversationMembersScreenState();
}
class _ConversationMembersScreenState extends State<ConversationMembersScreen> {
Conversation _conversation;
UsersList _members;
Future<void> _refresh() async {
_conversation =
await ConversationsHelper().getSingle(widget.convID, force: true);
_members =
await UsersHelper().getListWithThrow(_conversation.members.toSet());
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(tr("Conversation members"))),
body: AsyncScreenWidget(
onReload: _refresh,
onBuild: _buildMembersList,
errorMessage:
tr("Could not load the list of members of this conversation!"),
),
);
}
Widget _buildMembersList() => ListView.builder(
itemBuilder: _buildItem,
itemCount: _conversation.members.length,
);
Widget _buildItem(BuildContext context, int index) {
final user = _members.getUser(_conversation.members[index]);
return ListTile(
leading: AccountImageWidget(user: user),
title: Text(user.displayName),
subtitle:
Text(_conversation.ownerID == user.id ? tr("Owner") : tr("Member")),
);
}
}

View File

@ -2,8 +2,8 @@ import 'package:comunic/helpers/conversations_helper.dart';
import 'package:comunic/helpers/events_helper.dart';
import 'package:comunic/models/conversation.dart';
import 'package:comunic/ui/dialogs/screen_dialog.dart';
import 'package:comunic/ui/screens/conversation_members_screen.dart';
import 'package:comunic/ui/screens/conversation_screen.dart';
import 'package:comunic/ui/screens/user_page_screen.dart';
import 'package:comunic/ui/widgets/safe_state.dart';
import 'package:comunic/ui/widgets/tablet_mode/conversations/conversation_window_container.dart';
import 'package:comunic/utils/account_utils.dart';
@ -151,7 +151,6 @@ class _ConversationWindowState extends SafeState<ConversationWindow> {
}
void _openMembersList() {
// dummy test
showScreenDialog(context, UserPageScreen(userID: 1));
showScreenDialog(context, ConversationMembersScreen(convID: _convID));
}
}