mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Improve comic display
This commit is contained in:
@@ -235,110 +235,109 @@ class ComicTile extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildBriefMode(BuildContext context) {
|
Widget _buildBriefMode(BuildContext context) {
|
||||||
return Padding(
|
return LayoutBuilder(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 8),
|
builder: (context, constraints) {
|
||||||
child: LayoutBuilder(
|
return InkWell(
|
||||||
builder: (context, constraints) {
|
borderRadius: BorderRadius.circular(8),
|
||||||
return InkWell(
|
onTap: _onTap,
|
||||||
borderRadius: BorderRadius.circular(8),
|
onLongPress: enableLongPressed ? () => _onLongPressed(context) : null,
|
||||||
onTap: _onTap,
|
onSecondaryTapDown: (detail) => onSecondaryTap(detail, context),
|
||||||
onLongPress:
|
child: Column(
|
||||||
enableLongPressed ? () => _onLongPressed(context) : null,
|
children: [
|
||||||
onSecondaryTapDown: (detail) => onSecondaryTap(detail, context),
|
Expanded(
|
||||||
child: Column(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Positioned.fill(
|
||||||
child: SizedBox(
|
child: Container(
|
||||||
child: Stack(
|
decoration: BoxDecoration(
|
||||||
children: [
|
color: context.colorScheme.secondaryContainer,
|
||||||
Positioned.fill(
|
borderRadius: BorderRadius.circular(8),
|
||||||
child: Container(
|
boxShadow: [
|
||||||
decoration: BoxDecoration(
|
BoxShadow(
|
||||||
color: Theme.of(context)
|
color: Colors.black.toOpacity(0.2),
|
||||||
.colorScheme
|
blurRadius: 2,
|
||||||
.secondaryContainer,
|
offset: const Offset(0, 2),
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
clipBehavior: Clip.antiAlias,
|
|
||||||
child: buildImage(context),
|
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
Align(
|
),
|
||||||
alignment: Alignment.bottomRight,
|
clipBehavior: Clip.antiAlias,
|
||||||
child: (() {
|
child: buildImage(context),
|
||||||
final subtitle =
|
|
||||||
comic.subtitle?.replaceAll('\n', '').trim();
|
|
||||||
final text = comic.description.isNotEmpty
|
|
||||||
? comic.description.split('|').join('\n')
|
|
||||||
: (subtitle?.isNotEmpty == true
|
|
||||||
? subtitle
|
|
||||||
: null);
|
|
||||||
final scale =
|
|
||||||
(appdata.settings['comicTileScale'] as num)
|
|
||||||
.toDouble();
|
|
||||||
final fortSize = scale < 0.85
|
|
||||||
? 8.0 // 小尺寸
|
|
||||||
: (scale < 1.0 ? 10.0 : 12.0);
|
|
||||||
|
|
||||||
if (text == null) {
|
|
||||||
return const SizedBox
|
|
||||||
.shrink(); // 如果没有文本,则不显示任何内容
|
|
||||||
}
|
|
||||||
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 2, vertical: 2),
|
|
||||||
child: ClipRRect(
|
|
||||||
borderRadius: const BorderRadius.all(
|
|
||||||
Radius.circular(10.0),
|
|
||||||
),
|
|
||||||
child: Container(
|
|
||||||
color: Colors.black.toOpacity(0.5),
|
|
||||||
child: Padding(
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.fromLTRB(8, 6, 8, 6),
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxWidth: constraints.maxWidth,
|
|
||||||
),
|
|
||||||
child: Text(
|
|
||||||
text,
|
|
||||||
style: TextStyle(
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
fontSize: fortSize,
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.right,
|
|
||||||
maxLines: 2,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
})(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Align(
|
||||||
Padding(
|
alignment: Alignment.bottomRight,
|
||||||
padding: const EdgeInsets.fromLTRB(8, 4, 8, 0),
|
child: (() {
|
||||||
child: Text(
|
final subtitle =
|
||||||
comic.title.replaceAll('\n', ''),
|
comic.subtitle?.replaceAll('\n', '').trim();
|
||||||
style: const TextStyle(
|
final text = comic.description.isNotEmpty
|
||||||
fontWeight: FontWeight.w500,
|
? comic.description.split('|').join('\n')
|
||||||
),
|
: (subtitle?.isNotEmpty == true ? subtitle : null);
|
||||||
maxLines: 1,
|
final fortSize = constraints.maxWidth < 80
|
||||||
overflow: TextOverflow.ellipsis,
|
? 8.0
|
||||||
|
: constraints.maxWidth < 150
|
||||||
|
? 10.0
|
||||||
|
: 12.0;
|
||||||
|
|
||||||
|
if (text == null) {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
|
|
||||||
|
var children = <Widget>[];
|
||||||
|
for (var line in text.split('\n')) {
|
||||||
|
children.add(Container(
|
||||||
|
margin: const EdgeInsets.fromLTRB(2, 0, 2, 2),
|
||||||
|
padding: constraints.maxWidth < 80
|
||||||
|
? const EdgeInsets.fromLTRB(3, 1, 3, 1)
|
||||||
|
: constraints.maxWidth < 150
|
||||||
|
? const EdgeInsets.fromLTRB(4, 2, 4, 2)
|
||||||
|
: const EdgeInsets.fromLTRB(5, 2, 5, 2),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
color: Colors.black.toOpacity(0.5),
|
||||||
|
),
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: constraints.maxWidth,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
line,
|
||||||
|
style: TextStyle(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
fontSize: fortSize,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.right,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: children,
|
||||||
|
);
|
||||||
|
})(),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
Padding(
|
||||||
},
|
padding: const EdgeInsets.fromLTRB(4, 4, 4, 0),
|
||||||
));
|
child: TextScroll(
|
||||||
|
comic.title.replaceAll('\n', ''),
|
||||||
|
mode: TextScrollMode.endless,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
delayBefore: Duration(milliseconds: 500),
|
||||||
|
velocity: const Velocity(pixelsPerSecond: Offset(40, 0)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
).paddingHorizontal(6).paddingVertical(8),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> _splitText(String text) {
|
List<String> _splitText(String text) {
|
||||||
@@ -807,7 +806,10 @@ class _SliverGridComics extends StatelessWidget {
|
|||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isSelected
|
color: isSelected
|
||||||
? Theme.of(context).colorScheme.secondaryContainer.toOpacity(0.72)
|
? Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.secondaryContainer
|
||||||
|
.toOpacity(0.72)
|
||||||
: null,
|
: null,
|
||||||
borderRadius: BorderRadius.circular(12),
|
borderRadius: BorderRadius.circular(12),
|
||||||
),
|
),
|
||||||
@@ -901,13 +903,13 @@ class ComicListState extends State<ComicList> {
|
|||||||
late bool enablePageStorage = widget.enablePageStorage;
|
late bool enablePageStorage = widget.enablePageStorage;
|
||||||
|
|
||||||
Map<String, dynamic> get state => {
|
Map<String, dynamic> get state => {
|
||||||
'maxPage': _maxPage,
|
'maxPage': _maxPage,
|
||||||
'data': _data,
|
'data': _data,
|
||||||
'page': _page,
|
'page': _page,
|
||||||
'error': _error,
|
'error': _error,
|
||||||
'loading': _loading,
|
'loading': _loading,
|
||||||
'nextUrl': _nextUrl,
|
'nextUrl': _nextUrl,
|
||||||
};
|
};
|
||||||
|
|
||||||
void restoreState(Map<String, dynamic>? state) {
|
void restoreState(Map<String, dynamic>? state) {
|
||||||
if (state == null || !enablePageStorage) {
|
if (state == null || !enablePageStorage) {
|
||||||
@@ -924,7 +926,7 @@ class ComicListState extends State<ComicList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void storeState() {
|
void storeState() {
|
||||||
if(enablePageStorage) {
|
if (enablePageStorage) {
|
||||||
PageStorage.of(context).writeState(context, state);
|
PageStorage.of(context).writeState(context, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1094,11 +1096,11 @@ class ComicListState extends State<ComicList> {
|
|||||||
while (_data[page] == null) {
|
while (_data[page] == null) {
|
||||||
await _fetchNext();
|
await _fetchNext();
|
||||||
}
|
}
|
||||||
if(mounted) {
|
if (mounted) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if(mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_error = e.toString();
|
_error = e.toString();
|
||||||
});
|
});
|
||||||
|
@@ -9,6 +9,7 @@ import 'package:flutter/rendering.dart';
|
|||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:syntax_highlight/syntax_highlight.dart';
|
import 'package:syntax_highlight/syntax_highlight.dart';
|
||||||
|
import 'package:text_scroll/text_scroll.dart';
|
||||||
import 'package:venera/foundation/app.dart';
|
import 'package:venera/foundation/app.dart';
|
||||||
import 'package:venera/foundation/app_page_route.dart';
|
import 'package:venera/foundation/app_page_route.dart';
|
||||||
import 'package:venera/foundation/appdata.dart';
|
import 'package:venera/foundation/appdata.dart';
|
||||||
|
@@ -73,6 +73,7 @@ class FavoriteItem implements Comic {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String get description {
|
String get description {
|
||||||
|
var time = this.time.substring(0, 10);
|
||||||
return appdata.settings['comicDisplayMode'] == 'detailed'
|
return appdata.settings['comicDisplayMode'] == 'detailed'
|
||||||
? "$time | ${type == ComicType.local ? 'local' : type.comicSource?.name ?? "Unknown"}"
|
? "$time | ${type == ComicType.local ? 'local' : type.comicSource?.name ?? "Unknown"}"
|
||||||
: "${type.comicSource?.name ?? "Unknown"} | $time";
|
: "${type.comicSource?.name ?? "Unknown"} | $time";
|
||||||
|
@@ -968,6 +968,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.3"
|
version: "0.7.3"
|
||||||
|
text_scroll:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: text_scroll
|
||||||
|
sha256: "7869d86a6fdd725dee56bdd150216a99f0372b82fbfcac319214dbd5f36e1908"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@@ -72,6 +72,7 @@ dependencies:
|
|||||||
shimmer: ^3.0.0
|
shimmer: ^3.0.0
|
||||||
flutter_memory_info: ^0.0.1
|
flutter_memory_info: ^0.0.1
|
||||||
syntax_highlight: ^0.4.0
|
syntax_highlight: ^0.4.0
|
||||||
|
text_scroll: ^0.2.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user