mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Display group posts
This commit is contained in:
parent
e777c4c991
commit
f0a23bcb47
@ -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
|
/// Get a single post information
|
||||||
Future<Post> getSingle(int postID) async {
|
Future<Post> getSingle(int postID) async {
|
||||||
final response = await APIRequest(
|
final response = await APIRequest(
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
|
import 'package:comunic/helpers/posts_helper.dart';
|
||||||
import 'package:comunic/models/advanced_group_info.dart';
|
import 'package:comunic/models/advanced_group_info.dart';
|
||||||
import 'package:comunic/ui/widgets/group_following_widget.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_icon_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/group_membership_widget.dart';
|
import 'package:comunic/ui/widgets/group_membership_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/like_widget.dart';
|
import 'package:comunic/ui/widgets/like_widget.dart';
|
||||||
|
import 'package:comunic/ui/widgets/posts_list_widget.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Authorized group page screen
|
/// Authorized group page screen
|
||||||
@ -34,12 +36,15 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[_buildGroupPageHeader()],
|
children: <Widget>[
|
||||||
|
_buildGroupPageHeader(),
|
||||||
|
Expanded(child: _buildGroupPagePostsList())
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Build group page header
|
/// Build group page header
|
||||||
_buildGroupPageHeader() {
|
Widget _buildGroupPageHeader() {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: Row(
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user