1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-30 00:36:28 +00:00
comunicmobile/lib/ui/screens/conversation_members_screen.dart

66 lines
1.9 KiB
Dart
Raw Normal View History

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);
2021-03-10 16:54:41 +00:00
_members = await UsersHelper().getListWithThrow(_conversation.membersID);
}
@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) {
2021-03-10 16:54:41 +00:00
final member = _conversation.members[index];
final user = _members.getUser(member.userID);
return ListTile(
leading: AccountImageWidget(user: user),
title: Text(user.displayName),
2021-03-10 16:54:41 +00:00
subtitle: Text(member.isAdmin ? tr("Admin") : tr("Member")),
);
}
}