1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 21:09:21 +00:00
comunicmobile/lib/ui/screens/group_sections/about_group_section.dart

121 lines
4.0 KiB
Dart
Raw Permalink Normal View History

2022-03-18 19:13:45 +00:00
import 'package:comunic/helpers/server_config_helper.dart';
2021-03-16 18:01:50 +00:00
import 'package:comunic/models/advanced_group_info.dart';
import 'package:comunic/models/group.dart';
import 'package:comunic/utils/date_utils.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart';
2022-06-11 13:04:11 +00:00
import 'package:url_launcher/url_launcher_string.dart';
2021-03-16 18:01:50 +00:00
/// About group section
///
/// @author Pierre Hubert
class AboutGroupSection extends StatelessWidget {
final AdvancedGroupInfo group;
2022-03-18 19:13:45 +00:00
final Function(Group) onReportGroup;
2021-03-16 18:01:50 +00:00
const AboutGroupSection({
Key? key,
required this.group,
2022-03-18 19:13:45 +00:00
required this.onReportGroup,
2022-03-11 16:02:06 +00:00
}) : super(key: key);
2021-03-16 18:01:50 +00:00
@override
Widget build(BuildContext context) => ListView(
children: [
// URL, if any
group.hasURL
? ListTile(
leading: Icon(Icons.link),
title: Text(tr("URL")!),
2021-03-16 18:01:50 +00:00
subtitle: Text(group.url),
2022-06-11 13:04:11 +00:00
onTap: () => launchUrlString(group.url),
2021-03-16 18:01:50 +00:00
)
: Container(),
// Description, if any
group.hasDescription
? ListTile(
leading: Icon(Icons.note),
title: Text(tr("Description")!),
2021-03-16 18:01:50 +00:00
subtitle: Text(group.description),
)
: Container(),
// Time create
ListTile(
leading: Icon(Icons.access_time),
title: Text("Created"),
subtitle: Text(diffTimeFromNowToStr(group.timeCreate!)!),
2021-03-16 18:01:50 +00:00
),
// Number of members
ListTile(
leading: Icon(Icons.group),
title: Text(tr("Members")!),
2022-03-11 16:02:06 +00:00
subtitle: Text(tr("%1% members",
args: {"1": group.numberMembers.toString()})!),
2021-03-16 18:01:50 +00:00
),
// Who can create posts
ListTile(
leading: Icon(Icons.add),
title: Text(tr("Who can create posts")!),
2021-03-16 18:01:50 +00:00
subtitle: Text(
group.postCreationLevel == GroupPostCreationLevel.MEMBERS
? tr("Every members")!
: tr("Only moderators and administrators")!),
2021-03-16 18:01:50 +00:00
),
// Registration process
ListTile(
leading: Icon(Icons.login),
title: Text(tr("Registration process")!),
2021-03-16 18:01:50 +00:00
subtitle: Text(group.registrationLevel ==
GroupRegistrationLevel.CLOSED
? tr("On invitation only")!
2021-03-16 18:01:50 +00:00
: (group.registrationLevel == GroupRegistrationLevel.MODERATED
? tr("A moderator has to approve requests")!
: tr("Anyone can join the group without approval")!)),
2021-03-16 18:01:50 +00:00
),
// Group visibility
ListTile(
leading: Icon(Icons.remove_red_eye),
title: Text(tr("Visibility")!),
2021-03-16 18:01:50 +00:00
subtitle: Text(group.visibilityLevel == GroupVisibilityLevel.SECRETE
? tr("Secrete group")!
2021-03-16 18:01:50 +00:00
: (group.visibilityLevel == GroupVisibilityLevel.PRIVATE
? tr("Private group")!
: tr("Open group")!)),
2021-03-16 18:01:50 +00:00
),
// Group members visibility
ListTile(
leading: Icon(Icons.remove_red_eye),
title: Text(tr("Members list visibility")!),
2022-03-11 16:02:06 +00:00
subtitle: Text(
group.isMembersListPublic! ? tr("Public")! : tr("Private")!),
),
2021-04-22 13:58:11 +00:00
group.isForezGroup
? // Group members visibility
ListTile(
leading: Icon(Icons.info_outline),
title: Text(tr("Forez group")!),
subtitle: Text(tr("Forez special features enabled")!),
2021-04-22 13:58:11 +00:00
)
: Container(),
2022-03-18 19:13:45 +00:00
// Report group
srvConfig!.isReportingEnabled
? ListTile(
textColor: Colors.red,
leading: Icon(Icons.flag, color: Colors.red),
title: Text(tr("Report abuse")!),
onTap: () => onReportGroup(group),
)
: Container(),
2021-03-16 18:01:50 +00:00
],
);
}