-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2529 from gtalha07/chat_ng-message-actions
Chat-NG: Message Actions
- Loading branch information
Showing
28 changed files
with
1,145 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Labs] Chat-NG: | ||
|
||
- [Feature] Now you can do message actions on message .i.e. edit/reply/copy/delete/report. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter/services.dart'; | ||
import 'package:flutter_easyloading/flutter_easyloading.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
|
||
Future<void> copyMessageAction( | ||
BuildContext context, | ||
String body, | ||
) async { | ||
String msg = body.trim(); | ||
await Clipboard.setData( | ||
ClipboardData(text: msg), | ||
); | ||
if (context.mounted) { | ||
EasyLoading.showToast(L10n.of(context).messageCopiedToClipboard); | ||
Navigator.pop(context); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
app/lib/features/chat_ng/actions/redact_message_action.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import 'package:acter/common/providers/chat_providers.dart'; | ||
import 'package:acter/common/toolkit/buttons/primary_action_button.dart'; | ||
import 'package:acter/common/widgets/default_dialog.dart'; | ||
import 'package:acter/features/chat_ng/providers/chat_room_messages_provider.dart'; | ||
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart' | ||
show RoomEventItem; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_easyloading/flutter_easyloading.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
final _log = Logger('a3::chat::message_actions_redact'); | ||
|
||
Future<void> redactMessageAction( | ||
BuildContext context, | ||
WidgetRef ref, | ||
RoomEventItem item, | ||
String messageId, | ||
String roomId, | ||
) async { | ||
final chatEditorNotifier = ref.watch(chatEditorStateProvider.notifier); | ||
final lang = L10n.of(context); | ||
final senderId = item.sender(); | ||
// pop message action options | ||
Navigator.pop(context); | ||
await showAdaptiveDialog( | ||
context: context, | ||
builder: (context) => DefaultDialog( | ||
title: Text(lang.areYouSureYouWantToDeleteThisMessage), | ||
actions: <Widget>[ | ||
OutlinedButton( | ||
onPressed: () => Navigator.pop(context), | ||
child: Text(lang.no), | ||
), | ||
ActerPrimaryActionButton( | ||
onPressed: () async { | ||
try { | ||
final convo = await ref.read(chatProvider(roomId).future); | ||
await convo?.redactMessage( | ||
messageId, | ||
senderId, | ||
null, | ||
null, | ||
); | ||
chatEditorNotifier.unsetActions(); | ||
if (context.mounted) { | ||
Navigator.pop(context); | ||
} | ||
} catch (e, s) { | ||
_log.severe('Redacting message failed', e, s); | ||
if (!context.mounted) return; | ||
EasyLoading.showError( | ||
lang.redactionFailed(e), | ||
duration: const Duration(seconds: 3), | ||
); | ||
Navigator.pop(context); | ||
} | ||
}, | ||
child: Text(lang.yes), | ||
), | ||
], | ||
), | ||
); | ||
} |
25 changes: 25 additions & 0 deletions
25
app/lib/features/chat_ng/actions/report_message_action.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:acter/common/actions/report_content.dart'; | ||
import 'package:acter_flutter_sdk/acter_flutter_sdk_ffi.dart' | ||
show RoomEventItem; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
|
||
Future<void> reportMessageAction( | ||
BuildContext context, | ||
RoomEventItem item, | ||
String messageId, | ||
String roomId, | ||
) async { | ||
final lang = L10n.of(context); | ||
final senderId = item.sender(); | ||
// pop message action options | ||
Navigator.pop(context); | ||
await openReportContentDialog( | ||
context, | ||
title: lang.reportThisMessage, | ||
description: lang.reportMessageContent, | ||
senderId: senderId, | ||
roomId: roomId, | ||
eventId: messageId, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.