mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-26 06:49:22 +00:00
Can load older posts on user page
This commit is contained in:
parent
c7502e6a04
commit
302e5f22ce
@ -67,10 +67,9 @@ class PostsHelper {
|
|||||||
|
|
||||||
/// Get the list of posts of a user
|
/// Get the list of posts of a user
|
||||||
Future<PostsList> getUserPosts(int userID, {int from = 0}) async {
|
Future<PostsList> getUserPosts(int userID, {int from = 0}) async {
|
||||||
final response = await APIRequest(
|
final response = await (APIRequest(uri: "posts/get_user", needLogin: true)
|
||||||
uri: "posts/get_user",
|
..addInt("userID", userID)
|
||||||
needLogin: true,
|
..addInt("startFrom", from == 0 ? 0 : from - 1))
|
||||||
args: {"userID": userID.toString(), "startFrom": from.toString()})
|
|
||||||
.exec();
|
.exec();
|
||||||
|
|
||||||
if (response.code != 200) return null;
|
if (response.code != 200) return null;
|
||||||
|
@ -7,6 +7,7 @@ import 'package:comunic/ui/routes/user_access_denied_route.dart';
|
|||||||
import 'package:comunic/ui/widgets/network_image_widget.dart';
|
import 'package:comunic/ui/widgets/network_image_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/conversations_utils.dart';
|
import 'package:comunic/utils/conversations_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
@ -43,8 +44,19 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
|||||||
GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
GlobalKey<RefreshIndicatorState> _refreshIndicatorKey =
|
||||||
GlobalKey<RefreshIndicatorState>();
|
GlobalKey<RefreshIndicatorState>();
|
||||||
|
|
||||||
|
// Scroll detection (to load more user posts automatically)
|
||||||
|
final _postListKey = GlobalKey<PostsListWidgetState>();
|
||||||
|
ScrollWatcher _scrollWatcher;
|
||||||
|
|
||||||
_setStatus(_PageStatus s) => setState(() => _status = s);
|
_setStatus(_PageStatus s) => setState(() => _status = s);
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_scrollWatcher = ScrollWatcher(
|
||||||
|
onReachBottom: () => _postListKey.currentState.reachedPostsBottom());
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
super.didChangeDependencies();
|
super.didChangeDependencies();
|
||||||
@ -88,6 +100,7 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
|||||||
child: CustomScrollView(
|
child: CustomScrollView(
|
||||||
slivers: <Widget>[_buildHeader(), _buildBody()],
|
slivers: <Widget>[_buildHeader(), _buildBody()],
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
physics: AlwaysScrollableScrollPhysics(),
|
||||||
|
controller: _scrollWatcher,
|
||||||
),
|
),
|
||||||
onRefresh: _getUserInfo,
|
onRefresh: _getUserInfo,
|
||||||
),
|
),
|
||||||
@ -192,7 +205,10 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
|||||||
|
|
||||||
// Posts list
|
// Posts list
|
||||||
PostsListWidget(
|
PostsListWidget(
|
||||||
|
key: _postListKey,
|
||||||
getPostsList: () => _postsHelper.getUserPosts(widget.userID),
|
getPostsList: () => _postsHelper.getUserPosts(widget.userID),
|
||||||
|
getOlder: (from) =>
|
||||||
|
_postsHelper.getUserPosts(widget.userID, from: from),
|
||||||
showPostsTarget: false,
|
showPostsTarget: false,
|
||||||
buildListView: false,
|
buildListView: false,
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user