diff --git a/lib/pages/chat_details/participant_list_item/participant_list_item.dart b/lib/pages/chat_details/participant_list_item/participant_list_item.dart index 20b751dc75..82bc93f237 100644 --- a/lib/pages/chat_details/participant_list_item/participant_list_item.dart +++ b/lib/pages/chat_details/participant_list_item/participant_list_item.dart @@ -112,6 +112,7 @@ class ParticipantListItem extends StatelessWidget { builder: (ctx) => ProfileInfoPage( roomId: member.room.id, userId: member.id, + onUpdatedMembers: onUpdatedMembers, ), ), ); @@ -126,6 +127,7 @@ class ParticipantListItem extends StatelessWidget { return ProfileInfoPage( roomId: member.room.id, userId: member.id, + onUpdatedMembers: onUpdatedMembers, onNewChatOpen: () { dialogContext.pop(); }, diff --git a/lib/pages/profile_info/profile_info_body/profile_info_body.dart b/lib/pages/profile_info/profile_info_body/profile_info_body.dart index 894b79c94d..b9cad46666 100644 --- a/lib/pages/profile_info/profile_info_body/profile_info_body.dart +++ b/lib/pages/profile_info/profile_info_body/profile_info_body.dart @@ -1,6 +1,5 @@ import 'dart:async'; -import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:dartz/dartz.dart' hide State; import 'package:fluffychat/app_state/failure.dart'; import 'package:fluffychat/app_state/success.dart'; @@ -13,6 +12,7 @@ import 'package:fluffychat/presentation/enum/profile_info/profile_info_body_enum import 'package:fluffychat/presentation/model/presentation_contact_constant.dart'; import 'package:fluffychat/presentation/model/search/presentation_search.dart'; import 'package:fluffychat/utils/dialog/twake_dialog.dart'; +import 'package:fluffychat/utils/dialog/warning_dialog.dart'; import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/twake_snackbar.dart'; import 'package:fluffychat/widgets/matrix.dart'; @@ -131,32 +131,32 @@ class ProfileInfoBodyController extends State { } } - void leaveFromChat() async { + Future removeFromGroupChat() async { if (user == null) return; - if (await showOkCancelAlertDialog( - useRootNavigator: false, - context: context, - title: L10n.of(context)!.removeUser, - okLabel: L10n.of(context)!.remove, - cancelLabel: L10n.of(context)!.cancel, - message: L10n.of(context)!.removeReason( - user?.displayName ?? '', - ), - ) == - OkCancelResult.ok) { - final result = await TwakeDialog.showFutureLoadingDialogFullScreen( - future: () => user!.kick(), - ); - if (result.error != null) { - TwakeSnackBar.show( - context, - result.error!.message, + WarningDialog.showCancelable( + context, + message: L10n.of(context)!.removeReason( + user?.displayName ?? '', + ), + title: L10n.of(context)!.removeUser, + acceptText: L10n.of(context)!.remove, + cancelText: L10n.of(context)!.cancel, + acceptTextColor: LinagoraSysColors.material().error, + onAccept: () async { + WarningDialog.hideWarningDialog(context); + final result = await TwakeDialog.showFutureLoadingDialogFullScreen( + future: () => user!.kick(), ); - return; - } - Navigator.of(context).pop(); - widget.onUpdatedMembers?.call(); - } + if (result.error != null) { + TwakeSnackBar.show( + context, + result.error!.message, + ); + return; + } + widget.onUpdatedMembers?.call(); + }, + ); } List profileInfoActions() { @@ -172,7 +172,7 @@ class ProfileInfoBodyController extends State { openNewChat(); break; case ProfileInfoActions.removeFromGroup: - leaveFromChat(); + removeFromGroupChat(); break; default: break; diff --git a/lib/pages/profile_info/profile_info_page.dart b/lib/pages/profile_info/profile_info_page.dart index a803dc242d..e6a7aa1927 100644 --- a/lib/pages/profile_info/profile_info_page.dart +++ b/lib/pages/profile_info/profile_info_page.dart @@ -9,11 +9,13 @@ class ProfileInfoPage extends StatefulWidget { required this.roomId, required this.userId, this.onNewChatOpen, + this.onUpdatedMembers, }); final String roomId; final String userId; final void Function()? onNewChatOpen; + final VoidCallback? onUpdatedMembers; @override State createState() => ProfileInfoPageState(); @@ -25,5 +27,8 @@ class ProfileInfoPageState extends State { User? get user => room?.unsafeGetUserFromMemoryOrFallback(widget.userId); @override - Widget build(BuildContext context) => ProfileInfoView(this); + Widget build(BuildContext context) => ProfileInfoView( + this, + onUpdatedMembers: widget.onUpdatedMembers, + ); } diff --git a/lib/pages/profile_info/profile_info_view.dart b/lib/pages/profile_info/profile_info_view.dart index ef19fcde71..5fec66f637 100644 --- a/lib/pages/profile_info/profile_info_view.dart +++ b/lib/pages/profile_info/profile_info_view.dart @@ -11,10 +11,13 @@ class ProfileInfoView extends StatelessWidget { const ProfileInfoView( this.controller, { super.key, + this.onUpdatedMembers, }); final ProfileInfoPageState controller; + final VoidCallback? onUpdatedMembers; + @override Widget build(BuildContext context) { return Scaffold( @@ -58,6 +61,7 @@ class ProfileInfoView extends StatelessWidget { body: ProfileInfoBody( user: controller.user, onNewChatOpen: controller.widget.onNewChatOpen, + onUpdatedMembers: onUpdatedMembers, ), ); } diff --git a/lib/pages/settings_dashboard/settings_security/settings_security.dart b/lib/pages/settings_dashboard/settings_security/settings_security.dart index 97f3e100b8..e4a3830e56 100644 --- a/lib/pages/settings_dashboard/settings_security/settings_security.dart +++ b/lib/pages/settings_dashboard/settings_security/settings_security.dart @@ -137,7 +137,7 @@ class SettingsSecurityController extends State { file.result?.downloadFile(context); } - void copyPublicKey() { + Future copyPublicKey() async { Clipboard.setData( ClipboardData(text: Matrix.of(context).client.fingerprintKey.beautified), ); diff --git a/lib/utils/dialog/warning_dialog.dart b/lib/utils/dialog/warning_dialog.dart index 8c3802c9c1..3778b1b3eb 100644 --- a/lib/utils/dialog/warning_dialog.dart +++ b/lib/utils/dialog/warning_dialog.dart @@ -27,8 +27,10 @@ class WarningDialog { String? title, String? message, String? acceptText, + Color? acceptTextColor, OnAcceptButton? onAccept, String? cancelText, + Color? cancelTextColor, OnAcceptButton? onCancel, }) { showDialog( @@ -40,6 +42,7 @@ class WarningDialog { actions: [ DialogAction( text: cancelText ?? L10n.of(context)!.cancel, + textColor: cancelTextColor, onPressed: () { Navigator.pop(context); onCancel?.call(); @@ -47,6 +50,7 @@ class WarningDialog { ), DialogAction( text: acceptText ?? L10n.of(context)!.ok, + textColor: acceptTextColor, onPressed: () { Navigator.pop(context); onAccept?.call(); diff --git a/lib/utils/warning_dialog.dart b/lib/utils/warning_dialog.dart index 5d7c06fc7c..2f0c1e7618 100644 --- a/lib/utils/warning_dialog.dart +++ b/lib/utils/warning_dialog.dart @@ -59,16 +59,19 @@ class WarningDialogWidget extends StatelessWidget { class DialogAction { final String text; + final Color? textColor; final VoidCallback? onPressed; DialogAction({ required this.text, this.onPressed, + this.textColor, }); } class _WarningTextButton extends StatelessWidget { final DialogAction action; + const _WarningTextButton({ required this.action, }); @@ -85,7 +88,8 @@ class _WarningTextButton extends StatelessWidget { child: Text( action.text, style: Theme.of(context).textTheme.labelLarge?.copyWith( - color: Theme.of(context).colorScheme.primary, + color: + action.textColor ?? Theme.of(context).colorScheme.primary, ), ), ),