Smooth scroll for comments page.

This commit is contained in:
2025-04-03 11:53:43 +08:00
parent 3da00595b7
commit 276e23354d

View File

@@ -99,61 +99,67 @@ class _CommentsPageState extends State<CommentsPage> {
return Column( return Column(
children: [ children: [
Expanded( Expanded(
child: ListView.builder( child: SmoothScrollProvider(
primary: false, builder: (context, controller, physics) {
padding: EdgeInsets.zero, return ListView.builder(
itemCount: _comments!.length + 2, controller: controller,
itemBuilder: (context, index) { physics: physics,
if (index == 0) { primary: false,
if (widget.replyComment != null) { padding: EdgeInsets.zero,
return Column( itemCount: _comments!.length + 2,
children: [ itemBuilder: (context, index) {
_CommentTile( if (index == 0) {
comment: widget.replyComment!, if (widget.replyComment != null) {
source: widget.source, return Column(
comic: widget.data, children: [
showAvatar: showAvatar, _CommentTile(
showActions: false, comment: widget.replyComment!,
), source: widget.source,
const SizedBox(height: 8), comic: widget.data,
Container( showAvatar: showAvatar,
alignment: Alignment.centerLeft, showActions: false,
padding: const EdgeInsets.all(16), ),
decoration: BoxDecoration( const SizedBox(height: 8),
border: Border( Container(
top: BorderSide( alignment: Alignment.centerLeft,
color: context.colorScheme.outlineVariant, padding: const EdgeInsets.all(16),
width: 0.6, decoration: BoxDecoration(
border: Border(
top: BorderSide(
color: context.colorScheme.outlineVariant,
width: 0.6,
),
),
),
child: Text(
"Replies".tl,
style: ts.s18,
), ),
), ),
), ],
child: Text( );
"Replies".tl, } else {
style: ts.s18, return const SizedBox();
), }
), }
], index--;
if (index == _comments!.length) {
if (_page < (maxPage ?? _page + 1)) {
loadMore();
return const ListLoadingIndicator();
} else {
return const SizedBox();
}
}
return _CommentTile(
comment: _comments![index],
source: widget.source,
comic: widget.data,
showAvatar: showAvatar,
); );
} else { },
return const SizedBox();
}
}
index--;
if (index == _comments!.length) {
if (_page < (maxPage ?? _page + 1)) {
loadMore();
return const ListLoadingIndicator();
} else {
return const SizedBox();
}
}
return _CommentTile(
comment: _comments![index],
source: widget.source,
comic: widget.data,
showAvatar: showAvatar,
); );
}, },
), ),