fluffychat/lib/pages/chat_details/participant_list_item.dart

73 lines
2.4 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
return Opacity(
opacity: user.membership == Membership.join ? 1 : 0.5,
child: ListTile(
onTap: () => showModalBottomSheet(
context: context,
builder: (c) => UserBottomSheet(
user: user,
outerContext: context,
),
2020-10-28 07:23:50 +01:00
),
title: Row(
children: <Widget>[
Text(user.calcDisplayname()),
permissionBatch.isEmpty
? Container()
: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor,
borderRadius: BorderRadius.circular(8),
),
child: Center(child: Text(permissionBatch)),
2020-01-01 19:10:13 +01:00
),
membershipBatch[user.membership].isEmpty
? Container()
: Container(
padding: const EdgeInsets.all(4),
margin: const EdgeInsets.symmetric(horizontal: 8),
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor,
borderRadius: BorderRadius.circular(8),
),
child:
Center(child: Text(membershipBatch[user.membership])),
2020-01-01 19:10:13 +01:00
),
],
),
subtitle: Text(user.id),
leading:
Avatar(mxContent: user.avatarUrl, name: user.calcDisplayname()),
2020-01-01 19:10:13 +01:00
),
);
}
}