FurryChat/lib/components/list_items/participant_list_item.dart

66 lines
2.1 KiB
Dart
Raw Normal View History

2020-01-01 18:10:13 +00:00
import 'package:famedlysdk/famedlysdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
2020-01-01 18:10:13 +00:00
import '../avatar.dart';
2020-10-28 06:23:50 +00:00
import '../user_bottom_sheet.dart';
2020-01-01 18:10:13 +00:00
class ParticipantListItem extends StatelessWidget {
final User user;
const ParticipantListItem(this.user);
@override
Widget build(BuildContext context) {
2020-05-13 13:58:59 +00:00
var membershipBatch = <Membership, String>{
Membership.join: '',
2020-05-07 05:52:40 +00:00
Membership.ban: L10n.of(context).banned,
Membership.invite: L10n.of(context).invited,
Membership.leave: L10n.of(context).leftTheChat,
2020-01-01 18:10:13 +00:00
};
2020-05-13 13:58:59 +00:00
final permissionBatch = user.powerLevel == 100
2020-05-07 05:52:40 +00:00
? L10n.of(context).admin
2020-10-02 06:56:28 +00:00
: user.powerLevel >= 50
? L10n.of(context).moderator
: '';
2020-02-16 10:41:08 +00:00
2020-10-28 06:23:50 +00:00
return ListTile(
onTap: () => showModalBottomSheet(
context: context,
builder: (context) => UserBottomSheet(
user: user,
),
),
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 18:10:13 +00:00
),
2020-10-28 06:23:50 +00: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 18:10:13 +00:00
),
2020-10-28 06:23:50 +00:00
child: Center(child: Text(membershipBatch[user.membership])),
),
],
2020-01-01 18:10:13 +00:00
),
2020-10-28 06:23:50 +00:00
subtitle: Text(user.id),
leading: Avatar(user.avatarUrl, user.calcDisplayname()),
2020-01-01 18:10:13 +00:00
);
}
}