mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Improve comic page performance
This commit is contained in:
@@ -148,3 +148,18 @@ class SliverGridDelegateWithComics extends SliverGridDelegate {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class SliverLazyToBoxAdapter extends StatelessWidget {
|
||||
/// Creates a sliver that contains a single box widget which can be lazy loaded.
|
||||
const SliverLazyToBoxAdapter({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverList.list(children: [
|
||||
SizedBox(),
|
||||
child,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -206,7 +206,8 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
||||
|
||||
yield const SliverPadding(padding: EdgeInsets.only(top: 8));
|
||||
|
||||
yield Row(
|
||||
yield SliverLazyToBoxAdapter(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(width: 16),
|
||||
@@ -255,13 +256,14 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
||||
),
|
||||
),
|
||||
],
|
||||
).toSliver();
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildActions() {
|
||||
bool isMobile = context.width < changePoint;
|
||||
bool hasHistory = history != null && (history!.ep > 1 || history!.page > 1);
|
||||
return SliverToBoxAdapter(
|
||||
return SliverLazyToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
ListView(
|
||||
@@ -354,7 +356,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
||||
if (comic.description == null || comic.description!.trim().isEmpty) {
|
||||
return const SliverPadding(padding: EdgeInsets.zero);
|
||||
}
|
||||
return SliverToBoxAdapter(
|
||||
return SliverLazyToBoxAdapter(
|
||||
child: Column(
|
||||
children: [
|
||||
ListTile(
|
||||
@@ -482,7 +484,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
||||
bool enableTranslation =
|
||||
App.locale.languageCode == 'zh' && comicSource.enableTagsTranslate;
|
||||
|
||||
return SliverToBoxAdapter(
|
||||
return SliverLazyToBoxAdapter(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -1875,7 +1877,7 @@ class _CommentsPartState extends State<_CommentsPart> {
|
||||
Widget build(BuildContext context) {
|
||||
return MultiSliver(
|
||||
children: [
|
||||
SliverToBoxAdapter(
|
||||
SliverLazyToBoxAdapter(
|
||||
child: ListTile(
|
||||
title: Text("Comments".tl),
|
||||
trailing: Row(
|
||||
|
Reference in New Issue
Block a user