From 935d7dbb63ef42127f01aa0d974a413291fff9f8 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 8 May 2020 09:44:41 +0200 Subject: [PATCH] Improve groups page performances --- .../screens/authorized_group_page_screen.dart | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lib/ui/screens/authorized_group_page_screen.dart b/lib/ui/screens/authorized_group_page_screen.dart index 670d1e6..28f4b2a 100644 --- a/lib/ui/screens/authorized_group_page_screen.dart +++ b/lib/ui/screens/authorized_group_page_screen.dart @@ -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/post_create_form_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:flutter/material.dart'; @@ -42,30 +41,13 @@ class AuthorizedGroupPageScreen extends StatefulWidget { class _AuthorizedGroupPageScreenState extends State { AdvancedGroupInfo get _group => widget.advancedGroupInfo; - // Allows load older posts when we reach the bottom of the page final _postsKey = GlobalKey(); - ScrollWatcher _postsController; - - @override - void initState() { - _postsController = ScrollWatcher( - onReachBottom: () => _postsKey.currentState.reachedPostsBottom()); - super.initState(); - } @override Widget build(BuildContext context) { return RefreshIndicator( onRefresh: () => widget.needRefresh(), - child: ListView( - physics: AlwaysScrollableScrollPhysics(), - controller: _postsController, - children: [ - _buildGroupPageHeader(), - _buildPostCreationArea(), - _buildGroupPagePostsList() - ], - ), + child: _buildGroupPagePostsList(), ); } @@ -141,11 +123,14 @@ class _AuthorizedGroupPageScreenState extends State { Widget _buildGroupPagePostsList() { return PostsListWidget( key: _postsKey, + topWidgets: [ + _buildGroupPageHeader(), + _buildPostCreationArea(), + ], getPostsList: () => PostsHelper().getGroupPosts(_group.id), showPostsTarget: false, userNamesClickable: true, getOlder: (from) => PostsHelper().getGroupPosts(_group.id, from: from), - buildListView: false, ); }