mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-07-08 01:30:28 +08:00
Use CustomScrollView
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import 'package:eh_downloader_flutter/globals.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../api/file.dart';
|
||||
import '../api/gallery.dart';
|
||||
import 'gallery_basic_info.dart';
|
||||
import 'gallery_info_desktop.dart';
|
||||
import 'thumbnail_gridview.dart';
|
||||
|
||||
class GalleryInfo extends StatefulWidget {
|
||||
const GalleryInfo(this.gData, {Key? key}) : super(key: key);
|
||||
const GalleryInfo(this.gData, {Key? key, this.files}) : super(key: key);
|
||||
final GalleryData gData;
|
||||
final EhFiles? files;
|
||||
|
||||
@override
|
||||
State<GalleryInfo> createState() => _GalleryInfo();
|
||||
@@ -26,23 +29,29 @@ class _GalleryInfo extends State<GalleryInfo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
bool useMobile = MediaQuery.of(context).size.width <= 810;
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
return SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(minHeight: constraints.maxHeight),
|
||||
child: useMobile
|
||||
? Column(
|
||||
children: [
|
||||
GalleryBasicInfo(
|
||||
widget.gData.meta, widget.gData.pages.first),
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: [
|
||||
GalleryInfoDesktop(widget.gData),
|
||||
],
|
||||
)));
|
||||
});
|
||||
final firstPage = widget.gData.pages.first;
|
||||
final int? firstFileId = widget.files != null
|
||||
? widget.files!.files[firstPage.token]!.first.id
|
||||
: null;
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
useMobile
|
||||
? SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
GalleryBasicInfo(widget.gData.meta, firstPage,
|
||||
fileId: firstFileId),
|
||||
]),
|
||||
)
|
||||
: SliverList(
|
||||
delegate: SliverChildListDelegate([
|
||||
GalleryInfoDesktop(widget.gData, fileId: firstFileId),
|
||||
]),
|
||||
),
|
||||
ThumbnailGridView(widget.gData.pages,
|
||||
const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 5),
|
||||
files: widget.files),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user