mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-21 20:39:22 +00:00
Can report conversation
This commit is contained in:
parent
e80232931e
commit
1bd7840be6
@ -1,6 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:comunic/enums/load_error_level.dart';
|
||||
import 'package:comunic/enums/report_target_type.dart';
|
||||
import 'package:comunic/helpers/conversations_helper.dart';
|
||||
import 'package:comunic/helpers/events_helper.dart';
|
||||
import 'package:comunic/helpers/groups_helper.dart';
|
||||
@ -9,6 +10,8 @@ import 'package:comunic/lists/conversations_list.dart';
|
||||
import 'package:comunic/lists/groups_list.dart';
|
||||
import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/models/report_target.dart';
|
||||
import 'package:comunic/ui/dialogs/report_dialog.dart';
|
||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/ui/screens/create_conversation_screen.dart';
|
||||
import 'package:comunic/ui/tiles/conversation_tile.dart';
|
||||
@ -160,6 +163,11 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
_loadConversationsList(false);
|
||||
}
|
||||
|
||||
/// Handle conversation report request
|
||||
void _reportConversation(Conversation conversation) => showReportDialog(
|
||||
ctx: context,
|
||||
target: ReportTarget(ReportTargetType.Conversation, conversation.id!));
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_error == LoadErrorLevel.MAJOR) return _buildErrorCard();
|
||||
@ -201,6 +209,7 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
},
|
||||
onRequestUpdate: _updateConversation,
|
||||
onRequestLeave: _requestLeaveConversation,
|
||||
onReport: _reportConversation,
|
||||
);
|
||||
},
|
||||
itemCount: max(_list!.length, 1),
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:comunic/helpers/conversations_helper.dart';
|
||||
import 'package:comunic/helpers/server_config_helper.dart';
|
||||
import 'package:comunic/lists/groups_list.dart';
|
||||
import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/config.dart';
|
||||
@ -18,7 +19,7 @@ typedef OpenConversationCallback = void Function(Conversation);
|
||||
typedef RequestLeaveConversationCallback = void Function(Conversation);
|
||||
typedef RequestUpdateConversationCallback = void Function(Conversation);
|
||||
|
||||
enum _PopupMenuChoices { UPDATE, LEAVE }
|
||||
enum _PopupMenuChoices { UPDATE, LEAVE, REPORT }
|
||||
|
||||
class ConversationTile extends StatelessWidget {
|
||||
final Conversation conversation;
|
||||
@ -27,6 +28,7 @@ class ConversationTile extends StatelessWidget {
|
||||
final OpenConversationCallback onOpen;
|
||||
final RequestUpdateConversationCallback onRequestUpdate;
|
||||
final RequestLeaveConversationCallback onRequestLeave;
|
||||
final Function(Conversation) onReport;
|
||||
|
||||
const ConversationTile({
|
||||
Key? key,
|
||||
@ -36,6 +38,7 @@ class ConversationTile extends StatelessWidget {
|
||||
required this.onOpen,
|
||||
required this.onRequestUpdate,
|
||||
required this.onRequestLeave,
|
||||
required this.onReport,
|
||||
}) : super(key: key);
|
||||
|
||||
_buildSubInformation(IconData icon, String content) {
|
||||
@ -127,7 +130,15 @@ class ConversationTile extends StatelessWidget {
|
||||
child: Text(tr("Leave")!),
|
||||
value: _PopupMenuChoices.LEAVE,
|
||||
)
|
||||
]).then(_conversationMenuCallback);
|
||||
]..addAll(srvConfig!.isReportingEnabled
|
||||
? [
|
||||
PopupMenuItem(
|
||||
child: Text(tr("Report")!),
|
||||
value: _PopupMenuChoices.REPORT,
|
||||
)
|
||||
]
|
||||
: []))
|
||||
.then(_conversationMenuCallback);
|
||||
},
|
||||
);
|
||||
|
||||
@ -158,7 +169,11 @@ class ConversationTile extends StatelessWidget {
|
||||
onRequestLeave(conversation);
|
||||
break;
|
||||
|
||||
default:
|
||||
case _PopupMenuChoices.REPORT:
|
||||
onReport(conversation);
|
||||
break;
|
||||
|
||||
case null:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user