add infinite comment list
This commit is contained in:
parent
379d2204ae
commit
aefcf50fd1
|
@ -18,8 +18,8 @@ import '../util/text_color.dart';
|
||||||
import '../widgets/badge.dart';
|
import '../widgets/badge.dart';
|
||||||
import '../widgets/bottom_modal.dart';
|
import '../widgets/bottom_modal.dart';
|
||||||
import '../widgets/fullscreenable_image.dart';
|
import '../widgets/fullscreenable_image.dart';
|
||||||
import '../widgets/infinite_post_list.dart';
|
|
||||||
import '../widgets/markdown_text.dart';
|
import '../widgets/markdown_text.dart';
|
||||||
|
import '../widgets/sortable_infinite_list.dart';
|
||||||
|
|
||||||
class CommunityPage extends HookWidget {
|
class CommunityPage extends HookWidget {
|
||||||
final CommunityView _community;
|
final CommunityView _community;
|
||||||
|
@ -209,19 +209,27 @@ class CommunityPage extends HookWidget {
|
||||||
body: TabBarView(
|
body: TabBarView(
|
||||||
children: [
|
children: [
|
||||||
InfinitePostList(
|
InfinitePostList(
|
||||||
fetcher: (page, batchSize, sort) =>
|
fetcher: (page, batchSize, sort) =>
|
||||||
LemmyApi(community.instanceUrl).v1.getPosts(
|
LemmyApi(community.instanceUrl).v1.getPosts(
|
||||||
type: PostListingType.community,
|
type: PostListingType.community,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
communityId: community.id,
|
communityId: community.id,
|
||||||
page: page,
|
page: page,
|
||||||
// limit: 10,
|
limit: 10,
|
||||||
)),
|
),
|
||||||
ListView(
|
|
||||||
children: [
|
|
||||||
Center(child: Text('comments go here')),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
|
InfiniteCommentList(
|
||||||
|
fetcher: (page, batchSize, sortType) =>
|
||||||
|
LemmyApi(community.instanceUrl).v1.getComments(
|
||||||
|
communityId: community.id,
|
||||||
|
auth: accountsStore
|
||||||
|
.defaultTokenFor(community.instanceUrl)
|
||||||
|
?.raw,
|
||||||
|
type: CommentListingType.community,
|
||||||
|
sort: sortType,
|
||||||
|
limit: batchSize,
|
||||||
|
page: page,
|
||||||
|
)),
|
||||||
_AboutTab(
|
_AboutTab(
|
||||||
community: community,
|
community: community,
|
||||||
moderators: fullCommunitySnap.data?.moderators,
|
moderators: fullCommunitySnap.data?.moderators,
|
||||||
|
|
|
@ -38,6 +38,7 @@ class InstancePage extends HookWidget {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
final siteSnap = useFuture(siteFuture);
|
final siteSnap = useFuture(siteFuture);
|
||||||
final colorOnCard = textColorBasedOnBackground(theme.cardColor);
|
final colorOnCard = textColorBasedOnBackground(theme.cardColor);
|
||||||
|
final accStore = useAccountsStore();
|
||||||
|
|
||||||
if (!siteSnap.hasData) {
|
if (!siteSnap.hasData) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
@ -220,13 +221,19 @@ class InstancePage extends HookWidget {
|
||||||
// TODO: switch between all and subscribed
|
// TODO: switch between all and subscribed
|
||||||
type: PostListingType.all,
|
type: PostListingType.all,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
|
limit: batchSize,
|
||||||
page: page,
|
page: page,
|
||||||
|
auth: accStore.defaultTokenFor(instanceUrl)?.raw,
|
||||||
|
)),
|
||||||
|
InfiniteCommentList(
|
||||||
|
fetcher: (page, batchSize, sort) =>
|
||||||
|
LemmyApi(instanceUrl).v1.getComments(
|
||||||
|
type: CommentListingType.all,
|
||||||
|
sort: sort,
|
||||||
|
limit: batchSize,
|
||||||
|
page: page,
|
||||||
|
auth: accStore.defaultTokenFor(instanceUrl)?.raw,
|
||||||
)),
|
)),
|
||||||
ListView(
|
|
||||||
children: [
|
|
||||||
Center(child: Text('comments go here')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
_AboutTab(site,
|
_AboutTab(site,
|
||||||
communitiesFuture: communitiesFuture,
|
communitiesFuture: communitiesFuture,
|
||||||
instanceUrl: instanceUrl),
|
instanceUrl: instanceUrl),
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||||
import 'package:lemmur/widgets/post.dart';
|
|
||||||
import 'package:lemmy_api_client/lemmy_api_client.dart';
|
import 'package:lemmy_api_client/lemmy_api_client.dart';
|
||||||
|
|
||||||
|
import '../comment_tree.dart';
|
||||||
import '../hooks/infinite_scroll.dart';
|
import '../hooks/infinite_scroll.dart';
|
||||||
|
import 'comment.dart';
|
||||||
import 'infinite_scroll.dart';
|
import 'infinite_scroll.dart';
|
||||||
|
import 'post.dart';
|
||||||
import 'post_list_options.dart';
|
import 'post_list_options.dart';
|
||||||
|
|
||||||
/// Infinite list of posts
|
/// Infinite list of posts
|
||||||
|
@ -65,3 +67,18 @@ class InfinitePostList extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class InfiniteCommentList extends StatelessWidget {
|
||||||
|
final Future<List<CommentView>> Function(
|
||||||
|
int page, int batchSize, SortType sortType) fetcher;
|
||||||
|
|
||||||
|
InfiniteCommentList({this.fetcher});
|
||||||
|
|
||||||
|
Widget build(BuildContext context) => SortableInfiniteList<CommentView>(
|
||||||
|
builder: (comment) => Comment(
|
||||||
|
CommentTree(comment),
|
||||||
|
postCreatorId: null,
|
||||||
|
),
|
||||||
|
fetcher: fetcher,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue