mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Improve user page performances
This commit is contained in:
@ -6,7 +6,6 @@ import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||
import 'package:comunic/ui/widgets/account_image_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/conversations_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
@ -42,19 +41,8 @@ class _UserPageScreenState extends State<UserPageScreen> {
|
||||
GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
||||
GlobalKey<RefreshIndicatorState>();
|
||||
|
||||
// Scroll detection (to load more user posts automatically)
|
||||
final _postListKey = GlobalKey<PostsListWidgetState>();
|
||||
ScrollWatcher _scrollWatcher;
|
||||
|
||||
_setStatus(_PageStatus s) => setState(() => _status = s);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_scrollWatcher = ScrollWatcher(
|
||||
onReachBottom: () => _postListKey.currentState.reachedPostsBottom());
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
@ -92,13 +80,7 @@ class _UserPageScreenState extends State<UserPageScreen> {
|
||||
return Scaffold(
|
||||
body: RefreshIndicator(
|
||||
key: _refreshIndicatorKey,
|
||||
child: ListView(
|
||||
children: <Widget>[]
|
||||
..add(_buildHeader())
|
||||
..addAll(_buildBody()),
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
controller: _scrollWatcher,
|
||||
),
|
||||
child: _buildBody(),
|
||||
onRefresh: _getUserInfo,
|
||||
),
|
||||
);
|
||||
@ -161,27 +143,22 @@ class _UserPageScreenState extends State<UserPageScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildBody() {
|
||||
return <Widget>[
|
||||
// Posts create form
|
||||
_userInfo.canPostTexts
|
||||
? PostCreateFormWidget(
|
||||
postTarget: PostTarget.USER_PAGE,
|
||||
targetID: _userInfo.id,
|
||||
onCreated: _postCreated,
|
||||
)
|
||||
: Container(),
|
||||
|
||||
// Posts list
|
||||
PostsListWidget(
|
||||
key: _postListKey,
|
||||
getPostsList: () => _postsHelper.getUserPosts(widget.userID),
|
||||
getOlder: (from) =>
|
||||
_postsHelper.getUserPosts(widget.userID, from: from),
|
||||
showPostsTarget: false,
|
||||
buildListView: false,
|
||||
),
|
||||
];
|
||||
Widget _buildBody() {
|
||||
return PostsListWidget(
|
||||
topWidgets: [
|
||||
_buildHeader(),
|
||||
_userInfo.canPostTexts
|
||||
? PostCreateFormWidget(
|
||||
postTarget: PostTarget.USER_PAGE,
|
||||
targetID: _userInfo.id,
|
||||
onCreated: _postCreated,
|
||||
)
|
||||
: Container()
|
||||
],
|
||||
getPostsList: () => _postsHelper.getUserPosts(widget.userID),
|
||||
getOlder: (from) => _postsHelper.getUserPosts(widget.userID, from: from),
|
||||
showPostsTarget: false,
|
||||
);
|
||||
}
|
||||
|
||||
/// Method called each time a menu option is selected
|
||||
|
Reference in New Issue
Block a user