diff --git a/lib/ui/screens/conversation_members_screen.dart b/lib/ui/screens/conversation_members_screen.dart new file mode 100644 index 0000000..94c1bdb --- /dev/null +++ b/lib/ui/screens/conversation_members_screen.dart @@ -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 { + Conversation _conversation; + UsersList _members; + + Future _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")), + ); + } +} diff --git a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart index 7269b22..b7ff768 100644 --- a/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart +++ b/lib/ui/widgets/tablet_mode/conversations/conversation_window.dart @@ -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 { } void _openMembersList() { - // dummy test - showScreenDialog(context, UserPageScreen(userID: 1)); + showScreenDialog(context, ConversationMembersScreen(convID: _convID)); } }