fluffychat/lib/widgets/list_items/participant_list_item.dart

67 lines
2.1 KiB
Dart
Raw Normal View History

2020-01-01 19:10:13 +01:00
import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-01-01 19:10:13 +01:00
import '../avatar.dart';
2021-05-22 08:53:52 +02:00
import '../../views/user_bottom_sheet.dart';
2020-01-01 19:10:13 +01:00
class ParticipantListItem extends StatelessWidget {
final User user;
const ParticipantListItem(this.user);
@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(
padding: EdgeInsets.all(4),
margin: EdgeInsets.symmetric(horizontal: 8),
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(
padding: EdgeInsets.all(4),
margin: EdgeInsets.symmetric(horizontal: 8),
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
);
}
}