mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-10 14:09:27 +01:00
chore: Minor design changes in user viewer
This commit is contained in:
parent
500fbbf8c6
commit
b4fb28380f
@ -36,35 +36,41 @@ class UserBottomSheet extends StatelessWidget {
|
||||
case 'ban':
|
||||
if (await _askConfirmation()) {
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(user.ban());
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
break;
|
||||
case 'unban':
|
||||
if (await _askConfirmation()) {
|
||||
await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(user.unban());
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
break;
|
||||
case 'kick':
|
||||
if (await _askConfirmation()) {
|
||||
await SimpleDialogs(context).tryRequestWithLoadingDialog(user.kick());
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
break;
|
||||
case 'admin':
|
||||
if (await _askConfirmation()) {
|
||||
await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(user.setPower(100));
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
break;
|
||||
case 'moderator':
|
||||
if (await _askConfirmation()) {
|
||||
await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(user.setPower(50));
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
if (await _askConfirmation()) {
|
||||
await SimpleDialogs(context)
|
||||
.tryRequestWithLoadingDialog(user.setPower(0));
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
break;
|
||||
case 'message':
|
||||
@ -99,13 +105,23 @@ class UserBottomSheet extends StatelessWidget {
|
||||
|
||||
if (onMention != null) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text(L10n.of(context).mention), value: 'mention'),
|
||||
PopupMenuItem(
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).mention,
|
||||
Icons.alternate_email_outlined,
|
||||
),
|
||||
value: 'mention'),
|
||||
);
|
||||
}
|
||||
if (user.id != Matrix.of(context).client.userID) {
|
||||
if (user.id != Matrix.of(context).client.userID &&
|
||||
!user.room.isDirectChat) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
child: Text(L10n.of(context).sendAMessage), value: 'message'),
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).sendAMessage,
|
||||
Icons.send,
|
||||
),
|
||||
value: 'message'),
|
||||
);
|
||||
}
|
||||
if (user.canChangePowerLevel &&
|
||||
@ -113,7 +129,11 @@ class UserBottomSheet extends StatelessWidget {
|
||||
user.powerLevel != 100) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
child: Text(L10n.of(context).makeAnAdmin), value: 'admin'),
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).makeAnAdmin,
|
||||
Icons.arrow_upward,
|
||||
),
|
||||
value: 'admin'),
|
||||
);
|
||||
}
|
||||
if (user.canChangePowerLevel &&
|
||||
@ -121,29 +141,50 @@ class UserBottomSheet extends StatelessWidget {
|
||||
user.powerLevel != 50) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
child: Text(L10n.of(context).makeAModerator), value: 'moderator'),
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).makeAModerator,
|
||||
Icons.arrow_upward_outlined,
|
||||
),
|
||||
value: 'moderator'),
|
||||
);
|
||||
}
|
||||
if (user.canChangePowerLevel && user.powerLevel != 0) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
child: Text(L10n.of(context).revokeAllPermissions), value: 'user'),
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).revokeAllPermissions,
|
||||
Icons.arrow_downward_outlined,
|
||||
),
|
||||
value: 'user'),
|
||||
);
|
||||
}
|
||||
if (user.canKick) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
child: Text(L10n.of(context).kickFromChat), value: 'kick'),
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).kickFromChat,
|
||||
Icons.exit_to_app_outlined,
|
||||
),
|
||||
value: 'kick'),
|
||||
);
|
||||
}
|
||||
if (user.canBan && user.membership != Membership.ban) {
|
||||
items.add(
|
||||
PopupMenuItem(child: Text(L10n.of(context).banFromChat), value: 'ban'),
|
||||
PopupMenuItem(
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).banFromChat,
|
||||
Icons.warning_sharp,
|
||||
),
|
||||
value: 'ban'),
|
||||
);
|
||||
} else if (user.canBan && user.membership == Membership.ban) {
|
||||
} else if (user.room.canBan &&
|
||||
user.powerLevel < user.room.ownPowerLevel &&
|
||||
user.membership == Membership.ban) {
|
||||
items.add(
|
||||
PopupMenuItem(
|
||||
child: Text(L10n.of(context).removeExile), value: 'unban'),
|
||||
child: _TextWithIcon(
|
||||
L10n.of(context).removeExile, Icons.warning_outlined),
|
||||
value: 'unban'),
|
||||
);
|
||||
}
|
||||
return Center(
|
||||
@ -221,3 +262,26 @@ class UserBottomSheet extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TextWithIcon extends StatelessWidget {
|
||||
final String text;
|
||||
final IconData iconData;
|
||||
|
||||
const _TextWithIcon(
|
||||
this.text,
|
||||
this.iconData, {
|
||||
Key key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(iconData),
|
||||
SizedBox(width: 16),
|
||||
Text(text),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user