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();
|
||||||
@ -69,8 +81,8 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
|||||||
Navigator.of(context).pushReplacement(
|
Navigator.of(context).pushReplacement(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (c) => UserAccessDeniedRoute(
|
builder: (c) => UserAccessDeniedRoute(
|
||||||
userID: widget.userID,
|
userID: widget.userID,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -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,
|
||||||
),
|
),
|
||||||
@ -165,12 +178,12 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
|||||||
),
|
),
|
||||||
PopupMenuButton<_MenuOptions>(
|
PopupMenuButton<_MenuOptions>(
|
||||||
itemBuilder: (c) => [
|
itemBuilder: (c) => [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(tr("Friends")),
|
child: Text(tr("Friends")),
|
||||||
enabled: _userInfo != null,
|
enabled: _userInfo != null,
|
||||||
value: _MenuOptions.FRIENDS_LIST,
|
value: _MenuOptions.FRIENDS_LIST,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
onSelected: _selectedMenuOption,
|
onSelected: _selectedMenuOption,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -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,
|
||||||
),
|
),
|
||||||
@ -208,8 +224,8 @@ class _UserPageRouteState extends State<UserPageRoute> {
|
|||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (c) => OtherUserFriendsListRoute(
|
builder: (c) => OtherUserFriendsListRoute(
|
||||||
user: _userInfo,
|
user: _userInfo,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user