1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-24 22:09:21 +00:00

Can report group

This commit is contained in:
Pierre HUBERT 2022-03-18 20:13:45 +01:00
parent 64bbce2084
commit 49a1098a28
3 changed files with 54 additions and 4 deletions

View File

@ -1,4 +1,8 @@
import 'package:comunic/enums/report_target_type.dart';
import 'package:comunic/models/advanced_group_info.dart';
import 'package:comunic/models/group.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/group_sections/about_group_section.dart';
import 'package:comunic/ui/screens/group_sections/forez_presence_section.dart';
@ -65,7 +69,10 @@ class _AuthorizedGroupPageScreenState
// About the group
_GroupPageTab(
widget: (c) => AboutGroupSection(group: _group),
widget: (c) => AboutGroupSection(
group: _group,
onReportGroup: _reportGroup,
),
label: tr("About")!,
),
@ -197,6 +204,10 @@ class _AuthorizedGroupPageScreenState
),
);
}
/// Report group
void _reportGroup(Group g) => showReportDialog(
ctx: context, target: ReportTarget(ReportTargetType.Group, g.id));
}
class _GroupPageTab {

View File

@ -1,3 +1,4 @@
import 'package:comunic/helpers/server_config_helper.dart';
import 'package:comunic/models/advanced_group_info.dart';
import 'package:comunic/models/group.dart';
import 'package:comunic/utils/date_utils.dart';
@ -11,10 +12,12 @@ import 'package:url_launcher/url_launcher.dart';
class AboutGroupSection extends StatelessWidget {
final AdvancedGroupInfo group;
final Function(Group) onReportGroup;
const AboutGroupSection({
Key? key,
required this.group,
required this.onReportGroup,
}) : super(key: key);
@override
@ -103,6 +106,15 @@ class AboutGroupSection extends StatelessWidget {
subtitle: Text(tr("Forez special features enabled")!),
)
: Container(),
// Report group
srvConfig!.isReportingEnabled
? ListTile(
textColor: Colors.red,
leading: Icon(Icons.flag, color: Colors.red),
title: Text(tr("Report abuse")!),
onTap: () => onReportGroup(group),
)
: Container(),
],
);
}

View File

@ -1,6 +1,10 @@
import 'package:comunic/enums/report_target_type.dart';
import 'package:comunic/helpers/groups_helper.dart';
import 'package:comunic/helpers/server_config_helper.dart';
import 'package:comunic/lists/groups_list.dart';
import 'package:comunic/models/group.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/widgets/group_icon_widget.dart';
import 'package:comunic/ui/widgets/group_membership_widget.dart';
@ -70,9 +74,28 @@ class _GroupsListScreenState extends SafeState<GroupsListScreen> {
group: g,
onUpdated: () => _refreshIndicatorKey.currentState!.show(),
),
trailing: IconButton(
trailing: IntrinsicWidth(
child: Row(
children: [
// Remove membership
IconButton(
icon: Icon(Icons.delete),
onPressed: () => _deleteGroup(g)),
// Report button
srvConfig!.isReportingEnabled
? IconButton(
visualDensity: VisualDensity.compact,
onPressed: () => _reportGroup(g),
icon: Icon(
Icons.flag,
size: 15.0,
),
)
: Container()
],
),
),
onTap: () => MainController.of(context)!.openGroup(g.id),
))
.toList(),
@ -122,6 +145,10 @@ class _GroupsListScreenState extends SafeState<GroupsListScreen> {
_refreshIndicatorKey.currentState!.show();
}
/// Report a group
void _reportGroup(Group g) => showReportDialog(
ctx: context, target: ReportTarget(ReportTargetType.Group, g.id));
/// Add a group
void _createGroup() async {
try {