You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.2 KiB
Dart
68 lines
2.2 KiB
Dart
6 years ago
|
import 'package:flutter/material.dart';
|
||
4 years ago
|
|
||
5 years ago
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||
4 years ago
|
import 'package:matrix/matrix.dart';
|
||
6 years ago
|
|
||
4 years ago
|
import '../../widgets/avatar.dart';
|
||
|
import '../user_bottom_sheet/user_bottom_sheet.dart';
|
||
6 years ago
|
|
||
|
class ParticipantListItem extends StatelessWidget {
|
||
|
final User user;
|
||
|
|
||
4 years ago
|
const ParticipantListItem(this.user, {Key key}) : super(key: key);
|
||
6 years ago
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
4 years ago
|
final membershipBatch = <Membership, String>{
|
||
5 years ago
|
Membership.join: '',
|
||
5 years ago
|
Membership.ban: L10n.of(context).banned,
|
||
|
Membership.invite: L10n.of(context).invited,
|
||
|
Membership.leave: L10n.of(context).leftTheChat,
|
||
6 years ago
|
};
|
||
5 years ago
|
final permissionBatch = user.powerLevel == 100
|
||
5 years ago
|
? L10n.of(context).admin
|
||
5 years ago
|
: user.powerLevel >= 50
|
||
|
? L10n.of(context).moderator
|
||
|
: '';
|
||
6 years ago
|
|
||
5 years ago
|
return ListTile(
|
||
|
onTap: () => showModalBottomSheet(
|
||
|
context: context,
|
||
5 years ago
|
builder: (c) => UserBottomSheet(
|
||
5 years ago
|
user: user,
|
||
4 years ago
|
outerContext: context,
|
||
5 years ago
|
),
|
||
|
),
|
||
|
title: Row(
|
||
|
children: <Widget>[
|
||
|
Text(user.calcDisplayname()),
|
||
|
permissionBatch.isEmpty
|
||
|
? Container()
|
||
|
: Container(
|
||
4 years ago
|
padding: const EdgeInsets.all(4),
|
||
|
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||
5 years ago
|
decoration: BoxDecoration(
|
||
|
color: Theme.of(context).secondaryHeaderColor,
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
6 years ago
|
),
|
||
5 years ago
|
child: Center(child: Text(permissionBatch)),
|
||
|
),
|
||
|
membershipBatch[user.membership].isEmpty
|
||
|
? Container()
|
||
|
: Container(
|
||
4 years ago
|
padding: const EdgeInsets.all(4),
|
||
|
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||
5 years ago
|
decoration: BoxDecoration(
|
||
|
color: Theme.of(context).secondaryHeaderColor,
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
6 years ago
|
),
|
||
5 years ago
|
child: Center(child: Text(membershipBatch[user.membership])),
|
||
|
),
|
||
|
],
|
||
6 years ago
|
),
|
||
5 years ago
|
subtitle: Text(user.id),
|
||
|
leading: Avatar(user.avatarUrl, user.calcDisplayname()),
|
||
6 years ago
|
);
|
||
|
}
|
||
|
}
|