mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 04:49:21 +00:00
Add group create post form
This commit is contained in:
parent
d6f0147339
commit
f5914a8d34
@ -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);
|
||||
}
|
||||
|
@ -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,51 +40,68 @@ 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(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
GroupIcon(
|
||||
group: _group,
|
||||
),
|
||||
Text(
|
||||
" ${_group.displayName}",
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
GroupMembershipWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
),
|
||||
Container(
|
||||
height: 4,
|
||||
),
|
||||
GroupFollowingWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
),
|
||||
Container(
|
||||
height: 2,
|
||||
),
|
||||
LikeWidget(
|
||||
likeElement: _group,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
return Container(
|
||||
color: Colors.black45,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
GroupIcon(
|
||||
group: _group,
|
||||
),
|
||||
Text(
|
||||
" ${_group.displayName}",
|
||||
style: TextStyle(fontSize: 20),
|
||||
),
|
||||
Spacer(),
|
||||
Column(
|
||||
children: <Widget>[
|
||||
GroupMembershipWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
),
|
||||
Container(
|
||||
height: 4,
|
||||
),
|
||||
GroupFollowingWidget(
|
||||
group: _group,
|
||||
onUpdated: () => widget.needRefresh(),
|
||||
),
|
||||
Container(
|
||||
height: 2,
|
||||
),
|
||||
LikeWidget(
|
||||
likeElement: _group,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 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(
|
||||
|
Loading…
Reference in New Issue
Block a user