fluffychat/lib/pages/chat_details/participant_list_item.dart

68 lines
2.2 KiB
Dart
Raw Normal View History

2020-01-01 19:10:13 +01:00
import 'package:flutter/material.dart';
2021-10-26 18:50:34 +02:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
2021-10-26 18:50:34 +02:00
import 'package:matrix/matrix.dart';
2020-01-01 19:10:13 +01:00
2021-11-09 21:32:16 +01:00
import '../../widgets/avatar.dart';
import '../user_bottom_sheet/user_bottom_sheet.dart';
2020-01-01 19:10:13 +01:00
class ParticipantListItem extends StatelessWidget {
final User user;
2021-10-14 18:09:30 +02:00
const ParticipantListItem(this.user, {Key key}) : super(key: key);
2020-01-01 19:10:13 +01:00
@override
Widget build(BuildContext context) {
2021-04-14 10:37:15 +02:00
final membershipBatch = <Membership, String>{
2020-05-13 15:58:59 +02:00
Membership.join: '',
2020-05-07 07:52:40 +02:00
Membership.ban: L10n.of(context).banned,
Membership.invite: L10n.of(context).invited,
Membership.leave: L10n.of(context).leftTheChat,
2020-01-01 19:10:13 +01:00
};
2020-05-13 15:58:59 +02:00
final permissionBatch = user.powerLevel == 100
2020-05-07 07:52:40 +02:00
? L10n.of(context).admin
2020-10-02 08:56:28 +02:00
: user.powerLevel >= 50
? L10n.of(context).moderator
: '';
2020-02-16 11:41:08 +01:00
2020-10-28 07:23:50 +01:00
return ListTile(
onTap: () => showModalBottomSheet(
context: context,
2021-01-19 15:48:50 +01:00
builder: (c) => UserBottomSheet(
2020-10-28 07:23:50 +01:00
user: user,
2021-05-01 10:04:44 +02:00
outerContext: context,
2020-10-28 07:23:50 +01:00
),
),
title: Row(
children: <Widget>[
Text(user.calcDisplayname()),
permissionBatch.isEmpty
? Container()
: Container(
2021-10-14 18:09:30 +02:00
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.symmetric(horizontal: 8),
2020-10-28 07:23:50 +01:00
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor,
borderRadius: BorderRadius.circular(8),
2020-01-01 19:10:13 +01:00
),
2020-10-28 07:23:50 +01:00
child: Center(child: Text(permissionBatch)),
),
membershipBatch[user.membership].isEmpty
? Container()
: Container(
2021-10-14 18:09:30 +02:00
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.symmetric(horizontal: 8),
2020-10-28 07:23:50 +01:00
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor,
borderRadius: BorderRadius.circular(8),
2020-01-01 19:10:13 +01:00
),
2020-10-28 07:23:50 +01:00
child: Center(child: Text(membershipBatch[user.membership])),
),
],
2020-01-01 19:10:13 +01:00
),
2020-10-28 07:23:50 +01:00
subtitle: Text(user.id),
leading: Avatar(user.avatarUrl, user.calcDisplayname()),
2020-01-01 19:10:13 +01:00
);
}
}