mirror of
https://github.com/lifegpc/eh_downloader_flutter.git
synced 2026-06-06 05:49:03 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../api/file.dart';
|
||||
import '../api/gallery.dart';
|
||||
import '../globals.dart';
|
||||
import '../main.dart';
|
||||
import 'rate.dart';
|
||||
import 'thumbnail.dart';
|
||||
|
||||
class GalleryListNormalCard extends StatefulWidget {
|
||||
@@ -30,46 +34,106 @@ class _GalleryListNormalCard extends State<GalleryListNormalCard> {
|
||||
final maxWidth = MediaQuery.of(context).size.width;
|
||||
bool useMobile = maxWidth <= 810;
|
||||
final max =
|
||||
((useMobile ? 300 : 400) * MediaQuery.of(context).devicePixelRatio)
|
||||
((useMobile ? 150 : 200) * MediaQuery.of(context).devicePixelRatio)
|
||||
.toInt();
|
||||
final fileId =
|
||||
_pMeta != null ? _files?.files[_pMeta!.token]?.firstOrNull?.id : null;
|
||||
final card = Card(
|
||||
child: Row(children: [
|
||||
Expanded(
|
||||
flex: useMobile ? 2 : 3,
|
||||
child: _pMeta != null
|
||||
? Thumbnail(_pMeta!,
|
||||
key: Key("thumbnail-conver-${widget.gMeta.gid}-$max"),
|
||||
files: _files,
|
||||
gid: widget.gMeta.gid,
|
||||
fileId: fileId,
|
||||
max: max)
|
||||
: Container()),
|
||||
Expanded(
|
||||
flex: useMobile ? 3 : 7,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(widget.gMeta.title),
|
||||
Text(widget.gMeta.titleJpn),
|
||||
Text(widget.gMeta.uploader),
|
||||
Text(widget.gMeta.category),
|
||||
Text(widget.gMeta.filecount.toString()),
|
||||
Text(widget.gMeta.rating.toString()),
|
||||
])))
|
||||
]));
|
||||
final box = SizedBox(
|
||||
height: useMobile ? 300 : 400,
|
||||
width: useMobile ? null : 600,
|
||||
child: card);
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push('/gallery/${widget.gMeta.gid}',
|
||||
extra: GalleryPageExtra(title: widget.gMeta.preferredTitle));
|
||||
},
|
||||
child: box);
|
||||
final locale = MainApp.of(context).lang.toLocale().toString();
|
||||
final cs = Theme.of(context).colorScheme;
|
||||
final thumbnailWidget = _pMeta != null
|
||||
? Thumbnail(_pMeta!,
|
||||
key: Key("thumbnail-conver-${widget.gMeta.gid}-$max"),
|
||||
files: _files,
|
||||
gid: widget.gMeta.gid,
|
||||
fileId: fileId,
|
||||
height: max)
|
||||
: Container();
|
||||
final mainWidget = Padding(
|
||||
padding: useMobile
|
||||
? const EdgeInsets.symmetric(vertical: 2, horizontal: 8)
|
||||
: const EdgeInsets.all(16),
|
||||
child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
||||
SelectableText(
|
||||
useMobile ? widget.gMeta.preferredTitle : widget.gMeta.title,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold, fontSize: 16, color: cs.primary),
|
||||
textAlign: TextAlign.center,
|
||||
minLines: useMobile ? 1 : 1,
|
||||
maxLines: useMobile
|
||||
? 3
|
||||
: widget.gMeta.titleJpn.isEmpty
|
||||
? 4
|
||||
: 2),
|
||||
useMobile || widget.gMeta.titleJpn.isEmpty
|
||||
? Container()
|
||||
: SelectableText(
|
||||
widget.gMeta.titleJpn,
|
||||
style: TextStyle(color: cs.secondary),
|
||||
textAlign: TextAlign.center,
|
||||
maxLines: 2,
|
||||
minLines: 1,
|
||||
),
|
||||
Expanded(child: Container()),
|
||||
Row(crossAxisAlignment: CrossAxisAlignment.end, children: [
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
SelectableText.rich(TextSpan(
|
||||
text: widget.gMeta.uploader,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: cs.primary),
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
context.pushNamed("/galleries",
|
||||
queryParameters: {"uploader": widget.gMeta.uploader});
|
||||
})),
|
||||
Rate(widget.gMeta.rating, fontSize: 14, selectable: true),
|
||||
SelectableText.rich(TextSpan(
|
||||
text: widget.gMeta.category,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: cs.primary),
|
||||
mouseCursor: SystemMouseCursors.click,
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
context.pushNamed("/galleries",
|
||||
queryParameters: {"category": widget.gMeta.category});
|
||||
}))
|
||||
]),
|
||||
Expanded(child: Container()),
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.end, children: [
|
||||
SelectableText("${widget.gMeta.filecount}P",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: cs.primary,
|
||||
fontWeight: FontWeight.bold)),
|
||||
SelectableText(
|
||||
DateFormat.yMd(locale)
|
||||
.add_jms()
|
||||
.format(widget.gMeta.posted.toLocal()),
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: cs.primary,
|
||||
fontWeight: FontWeight.bold))
|
||||
]),
|
||||
]),
|
||||
]));
|
||||
final box = Container(
|
||||
alignment: Alignment.center,
|
||||
child: SizedBox(
|
||||
height: useMobile ? 150 : 200,
|
||||
width: useMobile ? null : 800,
|
||||
child: Row(children: [
|
||||
useMobile
|
||||
? ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: maxWidth / 2),
|
||||
child: thumbnailWidget)
|
||||
: thumbnailWidget,
|
||||
Expanded(child: mainWidget),
|
||||
])));
|
||||
final card = Card(child: box);
|
||||
return card;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,9 +237,15 @@ class _GalleriesPage extends State<GalleriesPage>
|
||||
final displayMode = GalleryListDisplayMode
|
||||
.values[prefs.getInt("galleryListDisplayMode") ?? 1];
|
||||
if (displayMode == GalleryListDisplayMode.normal) {
|
||||
return GalleryListNormalCard(item,
|
||||
files: _files,
|
||||
pMeta: _thumbnails.thumbnails[item.gid]?.unwrapOrNull());
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.push("/gallery/${item.gid}",
|
||||
extra: GalleryPageExtra(title: item.preferredTitle));
|
||||
},
|
||||
mouseCursor: SystemMouseCursors.basic,
|
||||
child: GalleryListNormalCard(item,
|
||||
files: _files,
|
||||
pMeta: _thumbnails.thumbnails[item.gid]?.unwrapOrNull()));
|
||||
}
|
||||
return ListTile(
|
||||
title: Text(item.preferredTitle),
|
||||
|
||||
Reference in New Issue
Block a user