diff --git a/lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart b/lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart index 5848cf545..09e8d6ac6 100644 --- a/lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart +++ b/lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart @@ -85,7 +85,7 @@ class AdaptiveDialogAction extends StatelessWidget { class AdaptiveDialogInkWell extends StatelessWidget { final Widget child; - final VoidCallback onTap; + final VoidCallback? onTap; final EdgeInsets padding; const AdaptiveDialogInkWell({ @@ -125,7 +125,7 @@ class AdaptiveDialogInkWell extends StatelessWidget { class AdaptiveIconTextButton extends StatelessWidget { final String label; final IconData icon; - final VoidCallback onTap; + final VoidCallback? onTap; const AdaptiveIconTextButton({ super.key, required this.label, diff --git a/lib/widgets/adaptive_dialogs/user_dialog.dart b/lib/widgets/adaptive_dialogs/user_dialog.dart index 4be6ba9d6..674bd9c1f 100644 --- a/lib/widgets/adaptive_dialogs/user_dialog.dart +++ b/lib/widgets/adaptive_dialogs/user_dialog.dart @@ -195,35 +195,39 @@ class UserDialog extends StatelessWidget { AdaptiveIconTextButton( label: L10n.of(context).block, icon: Icons.block_outlined, - onTap: () { - final router = GoRouter.of(context); - Navigator.of(context).pop(); - router.go( - '/rooms/settings/security/ignorelist', - extra: profile.userId, - ); - }, + onTap: client.userID == profile.userId + ? null + : () { + final router = GoRouter.of(context); + Navigator.of(context).pop(); + router.go( + '/rooms/settings/security/ignorelist', + extra: profile.userId, + ); + }, ), AdaptiveIconTextButton( label: L10n.of(context).report, icon: Icons.gavel_outlined, - onTap: () async { - Navigator.of(context).pop(); - final reason = await showTextInputDialog( - context: context, - title: L10n.of(context).whyDoYouWantToReportThis, - okLabel: L10n.of(context).report, - cancelLabel: L10n.of(context).cancel, - hintText: L10n.of(context).reason, - ); - if (reason == null || reason.isEmpty) return; - await showFutureLoadingDialog( - context: context, - future: () => Matrix.of( - context, - ).client.reportUser(profile.userId, reason), - ); - }, + onTap: client.userID == profile.userId + ? null + : () async { + Navigator.of(context).pop(); + final reason = await showTextInputDialog( + context: context, + title: L10n.of(context).whyDoYouWantToReportThis, + okLabel: L10n.of(context).report, + cancelLabel: L10n.of(context).cancel, + hintText: L10n.of(context).reason, + ); + if (reason == null || reason.isEmpty) return; + await showFutureLoadingDialog( + context: context, + future: () => Matrix.of( + context, + ).client.reportUser(profile.userId, reason), + ); + }, ), AdaptiveIconTextButton( label: L10n.of(context).share, @@ -236,17 +240,19 @@ class UserDialog extends StatelessWidget { ], ), AdaptiveDialogInkWell( - onTap: () async { - final router = GoRouter.of(context); - final roomIdResult = await showFutureLoadingDialog( - context: context, - future: () => client.startDirectChat(profile.userId), - ); - final roomId = roomIdResult.result; - if (roomId == null) return; - if (context.mounted) Navigator.of(context).pop(); - router.go('/rooms/$roomId'); - }, + onTap: client.userID == profile.userId + ? null + : () async { + final router = GoRouter.of(context); + final roomIdResult = await showFutureLoadingDialog( + context: context, + future: () => client.startDirectChat(profile.userId), + ); + final roomId = roomIdResult.result; + if (roomId == null) return; + if (context.mounted) Navigator.of(context).pop(); + router.go('/rooms/$roomId'); + }, child: Text( directChatRoomId == null ? L10n.of(context).createNewChat