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

Improve groups page performances

This commit is contained in:
Pierre HUBERT 2020-05-08 09:44:41 +02:00
parent ccb1547523
commit 935d7dbb63

View File

@ -10,7 +10,6 @@ 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/post_create_form_widget.dart'; import 'package:comunic/ui/widgets/post_create_form_widget.dart';
import 'package:comunic/ui/widgets/posts_list_widget.dart'; import 'package:comunic/ui/widgets/posts_list_widget.dart';
import 'package:comunic/ui/widgets/scroll_watcher.dart';
import 'package:comunic/utils/intl_utils.dart'; import 'package:comunic/utils/intl_utils.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -42,30 +41,13 @@ class AuthorizedGroupPageScreen extends StatefulWidget {
class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> { class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
AdvancedGroupInfo get _group => widget.advancedGroupInfo; AdvancedGroupInfo get _group => widget.advancedGroupInfo;
// Allows load older posts when we reach the bottom of the page
final _postsKey = GlobalKey<PostsListWidgetState>(); final _postsKey = GlobalKey<PostsListWidgetState>();
ScrollWatcher _postsController;
@override
void initState() {
_postsController = ScrollWatcher(
onReachBottom: () => _postsKey.currentState.reachedPostsBottom());
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return RefreshIndicator( return RefreshIndicator(
onRefresh: () => widget.needRefresh(), onRefresh: () => widget.needRefresh(),
child: ListView( child: _buildGroupPagePostsList(),
physics: AlwaysScrollableScrollPhysics(),
controller: _postsController,
children: <Widget>[
_buildGroupPageHeader(),
_buildPostCreationArea(),
_buildGroupPagePostsList()
],
),
); );
} }
@ -141,11 +123,14 @@ class _AuthorizedGroupPageScreenState extends State<AuthorizedGroupPageScreen> {
Widget _buildGroupPagePostsList() { Widget _buildGroupPagePostsList() {
return PostsListWidget( return PostsListWidget(
key: _postsKey, key: _postsKey,
topWidgets: <Widget>[
_buildGroupPageHeader(),
_buildPostCreationArea(),
],
getPostsList: () => PostsHelper().getGroupPosts(_group.id), getPostsList: () => PostsHelper().getGroupPosts(_group.id),
showPostsTarget: false, showPostsTarget: false,
userNamesClickable: true, userNamesClickable: true,
getOlder: (from) => PostsHelper().getGroupPosts(_group.id, from: from), getOlder: (from) => PostsHelper().getGroupPosts(_group.id, from: from),
buildListView: false,
); );
} }