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

Add group create post form

This commit is contained in:
Pierre HUBERT 2020-04-16 08:52:26 +02:00
parent d6f0147339
commit f5914a8d34
2 changed files with 60 additions and 35 deletions

View File

@ -58,4 +58,10 @@ class Group {
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
membershipLevel == GroupMembershipLevel.MODERATOR ||
membershipLevel == GroupMembershipLevel.MEMBER;
bool get canCreatePost =>
membershipLevel == GroupMembershipLevel.ADMINISTRATOR ||
membershipLevel == GroupMembershipLevel.MODERATOR ||
(membershipLevel == GroupMembershipLevel.MEMBER &&
postCreationLevel == GroupPostCreationLevel.MEMBERS);
}

View File

@ -1,9 +1,11 @@
import 'package:comunic/enums/post_target.dart';
import 'package:comunic/helpers/posts_helper.dart';
import 'package:comunic/models/advanced_group_info.dart';
import 'package:comunic/ui/widgets/group_following_widget.dart';
import 'package:comunic/ui/widgets/group_icon_widget.dart';
import 'package:comunic/ui/widgets/group_membership_widget.dart';
import 'package:comunic/ui/widgets/like_widget.dart';
import 'package:comunic/ui/widgets/post_create_form_widget.dart';
import 'package:comunic/ui/widgets/posts_list_widget.dart';
import 'package:flutter/material.dart';
@ -38,14 +40,20 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
return RefreshIndicator(
onRefresh: () => widget.needRefresh(),
child: ListView(
children: <Widget>[_buildGroupPageHeader(), _buildGroupPagePostsList()],
children: <Widget>[
_buildGroupPageHeader(),
_buildPostCreationArea(),
_buildGroupPagePostsList()
],
),
);
}
/// Build group page header
Widget _buildGroupPageHeader() {
return Padding(
return Container(
color: Colors.black45,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
@ -80,9 +88,20 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
)
],
),
),
);
}
/// Add create post target
Widget _buildPostCreationArea() {
if (!_group.canCreatePost) return Container();
return PostCreateFormWidget(
postTarget: PostTarget.GROUP_PAGE,
targetID: _group.id,
onCreated: () => widget.needRefresh());
}
/// Build the list of posts of the group
Widget _buildGroupPagePostsList() {
return PostsListWidget(