1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-26 12:58:51 +00:00

Display group posts

This commit is contained in:
Pierre HUBERT 2020-04-16 08:24:34 +02:00
parent e777c4c991
commit f0a23bcb47
2 changed files with 35 additions and 2 deletions

View File

@ -84,6 +84,24 @@ class PostsHelper {
}
}
/// Get the list of posts of a group
Future<PostsList> getGroupPosts(int groupID, {int from = 0}) async {
final response = await (APIRequest(uri: "posts/get_group", needLogin: true)
..addInt("groupID", groupID)
..addInt("startFrom", from == 0 ? 0 : from - 1))
.exec();
if (response.code != 200) return null;
try {
// Parse & return the list of posts
return PostsList()..addAll(response.getArray().map((f) => _apiToPost(f)));
} catch (e) {
print(e.toString());
return null;
}
}
/// Get a single post information
Future<Post> getSingle(int postID) async {
final response = await APIRequest(

View File

@ -1,8 +1,10 @@
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/posts_list_widget.dart';
import 'package:flutter/material.dart';
/// Authorized group page screen
@ -34,12 +36,15 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[_buildGroupPageHeader()],
children: <Widget>[
_buildGroupPageHeader(),
Expanded(child: _buildGroupPagePostsList())
],
);
}
/// Build group page header
_buildGroupPageHeader() {
Widget _buildGroupPageHeader() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
@ -77,4 +82,14 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
),
);
}
/// Build the list of posts of the group
Widget _buildGroupPagePostsList() {
return PostsListWidget(
getPostsList: () => PostsHelper().getGroupPosts(_group.id),
showPostsTarget: false,
userNamesClickable: true,
getOlder: (from) => PostsHelper().getGroupPosts(_group.id, from: from),
);
}
}