diff --git a/lib/components/list_items/participant_list_item.dart b/lib/components/list_items/participant_list_item.dart index de3675a5..e27d1a02 100644 --- a/lib/components/list_items/participant_list_item.dart +++ b/lib/components/list_items/participant_list_item.dart @@ -1,4 +1,5 @@ import 'package:famedlysdk/famedlysdk.dart'; +import 'package:fluffychat/components/dialogs/simple_dialogs.dart'; import 'package:fluffychat/i18n/i18n.dart'; import 'package:fluffychat/utils/app_route.dart'; import 'package:fluffychat/views/chat.dart'; @@ -16,19 +17,34 @@ class ParticipantListItem extends StatelessWidget { final MatrixState matrix = Matrix.of(context); switch (action) { case "ban": - await matrix.tryRequestWithLoadingDialog(user.ban()); + if (await SimpleDialogs(context).askConfirmation()) { + await matrix.tryRequestWithLoadingDialog(user.ban()); + } break; case "unban": - await matrix.tryRequestWithLoadingDialog(user.unban()); + if (await SimpleDialogs(context).askConfirmation()) { + await matrix.tryRequestWithLoadingDialog(user.unban()); + } break; case "kick": - await matrix.tryRequestWithLoadingDialog(user.kick()); + if (await SimpleDialogs(context).askConfirmation()) { + await matrix.tryRequestWithLoadingDialog(user.kick()); + } break; case "admin": - await matrix.tryRequestWithLoadingDialog(user.setPower(100)); + if (await SimpleDialogs(context).askConfirmation()) { + await matrix.tryRequestWithLoadingDialog(user.setPower(100)); + } + break; + case "moderator": + if (await SimpleDialogs(context).askConfirmation()) { + await matrix.tryRequestWithLoadingDialog(user.setPower(50)); + } break; case "user": - await matrix.tryRequestWithLoadingDialog(user.setPower(0)); + if (await SimpleDialogs(context).askConfirmation()) { + await matrix.tryRequestWithLoadingDialog(user.setPower(0)); + } break; case "message": final String roomId = await user.startDirectChat(); @@ -54,6 +70,13 @@ class ParticipantListItem extends StatelessWidget { ? I18n.of(context).admin : user.powerLevel >= 50 ? I18n.of(context).moderator : ""; List> items = >[]; + + if (user.id != Matrix.of(context).client.userID) { + items.add( + PopupMenuItem( + child: Text(I18n.of(context).sendAMessage), value: "message"), + ); + } if (user.canChangePowerLevel && user.room.ownPowerLevel == 100 && user.powerLevel != 100) { @@ -62,6 +85,14 @@ class ParticipantListItem extends StatelessWidget { child: Text(I18n.of(context).makeAnAdmin), value: "admin"), ); } + if (user.canChangePowerLevel && + user.room.ownPowerLevel >= 50 && + user.powerLevel != 50) { + items.add( + PopupMenuItem( + child: Text(I18n.of(context).makeAModerator), value: "moderator"), + ); + } if (user.canChangePowerLevel && user.powerLevel != 0) { items.add( PopupMenuItem( @@ -84,12 +115,6 @@ class ParticipantListItem extends StatelessWidget { child: Text(I18n.of(context).removeExile), value: "unban"), ); } - if (user.id != Matrix.of(context).client.userID) { - items.add( - PopupMenuItem( - child: Text(I18n.of(context).sendAMessage), value: "message"), - ); - } return PopupMenuButton( onSelected: (action) => participantAction(context, action), itemBuilder: (c) => items, diff --git a/lib/i18n/i18n.dart b/lib/i18n/i18n.dart index 95c9aae6..60fb7c62 100644 --- a/lib/i18n/i18n.dart +++ b/lib/i18n/i18n.dart @@ -394,6 +394,8 @@ class I18n { String get login => Intl.message("Login"); + String get makeAModerator => Intl.message("Make a moderator"); + String get makeAnAdmin => Intl.message("Make an admin"); String get makeSureTheIdentifierIsValid =>