improve ui

This commit is contained in:
2024-11-17 17:23:43 +08:00
parent 0ee99a8760
commit 708cf83a32
14 changed files with 320 additions and 175 deletions

View File

@@ -43,7 +43,7 @@
"Confirm": "确认", "Confirm": "确认",
"Are you sure you want to delete this comic?": "您确定要删除这部漫画吗?", "Are you sure you want to delete this comic?": "您确定要删除这部漫画吗?",
"Are you sure you want to delete @a selected comics?": "您确定要删除 @a 部漫画吗?", "Are you sure you want to delete @a selected comics?": "您确定要删除 @a 部漫画吗?",
"Add comic source": "添加漫画源", "Add comic source": "添加漫画源",
"Select file": "选择文件", "Select file": "选择文件",
"View list": "查看列表", "View list": "查看列表",
"Open help": "打开帮助", "Open help": "打开帮助",
@@ -102,8 +102,8 @@
"Auto page turning interval": "自动翻页间隔", "Auto page turning interval": "自动翻页间隔",
"Theme Mode": "主题模式", "Theme Mode": "主题模式",
"System": "系统", "System": "系统",
"Light": "明亮", "Light": "浅色",
"Dark": "黑暗", "Dark": "深色",
"Theme Color": "主题颜色", "Theme Color": "主题颜色",
"Red": "红色", "Red": "红色",
"Pink": "粉色", "Pink": "粉色",
@@ -215,7 +215,21 @@
"Authorization Required": "需要身份验证", "Authorization Required": "需要身份验证",
"Sync": "同步", "Sync": "同步",
"The folder is Linked to @source": "文件夹已关联到 @source", "The folder is Linked to @source": "文件夹已关联到 @source",
"Source Folder": "源收藏夹" "Source Folder": "源收藏夹",
"Use a config file": "使用配置文件",
"Comic Source list": "漫画源列表",
"View": "查看",
"Copy": "复制",
"Copied": "已复制",
"Search History": "搜索历史",
"Clear Search History": "清除搜索历史",
"Search in": "搜索于",
"Clear History": "清除历史",
"Are you sure you want to clear your history?": "确定要清除您的历史记录吗?",
"No Explore Pages": "没有探索页面",
"Add a comic source in home page": "在主页添加一个漫画源",
"Please check your settings": "请检查您的设置",
"No Category Pages": "没有分类页面"
}, },
"zh_TW": { "zh_TW": {
"Home": "首頁", "Home": "首頁",
@@ -263,7 +277,7 @@
"Confirm": "確認", "Confirm": "確認",
"Are you sure you want to delete this comic?": "您確定要刪除這部漫畫嗎?", "Are you sure you want to delete this comic?": "您確定要刪除這部漫畫嗎?",
"Are you sure you want to delete @a selected comics?": "您確定要刪除 @a 部漫畫嗎?", "Are you sure you want to delete @a selected comics?": "您確定要刪除 @a 部漫畫嗎?",
"Add comic source": "添加漫畫源", "Add comic source": "添加漫畫源",
"Select file": "選擇文件", "Select file": "選擇文件",
"View list": "查看列表", "View list": "查看列表",
"Open help": "打開幫助", "Open help": "打開幫助",
@@ -320,8 +334,8 @@
"Auto page turning interval": "自動翻頁間隔", "Auto page turning interval": "自動翻頁間隔",
"Theme Mode": "主題模式", "Theme Mode": "主題模式",
"System": "系統", "System": "系統",
"Light": "明亮", "Light": "浅色",
"Dark": "黑暗", "Dark": "深色",
"Theme Color": "主題顏色", "Theme Color": "主題顏色",
"Red": "紅色", "Red": "紅色",
"Pink": "粉色", "Pink": "粉色",
@@ -433,6 +447,20 @@
"Authorization Required": "需要身份驗證", "Authorization Required": "需要身份驗證",
"Sync": "同步", "Sync": "同步",
"The folder is Linked to @source": "文件夾已關聯到 @source", "The folder is Linked to @source": "文件夾已關聯到 @source",
"Source Folder": "源收藏夾" "Source Folder": "源收藏夾",
"Use a config file": "使用配置文件",
"Comic Source list": "漫畫源列表",
"View": "查看",
"Copy": "複製",
"Copied": "已複製",
"Search History": "搜索歷史",
"Clear Search History": "清除搜索歷史",
"Search in": "搜索於",
"Clear History": "清除歷史",
"Are you sure you want to clear your history?": "確定要清除您的歷史記錄嗎?",
"No Explore Pages": "沒有探索頁面",
"Add a comic source in home page": "在主頁添加一個漫畫源",
"Please check your settings": "請檢查您的設定",
"No Category Pages": "沒有分類頁面"
} }
} }

View File

@@ -25,7 +25,8 @@ class ComicTile extends StatelessWidget {
onTap!(); onTap!();
return; return;
} }
App.mainNavigatorKey?.currentContext?.to(() => ComicPage(id: comic.id, sourceKey: comic.sourceKey)); App.mainNavigatorKey?.currentContext
?.to(() => ComicPage(id: comic.id, sourceKey: comic.sourceKey));
} }
void onLongPress(BuildContext context) { void onLongPress(BuildContext context) {
@@ -50,7 +51,8 @@ class ComicTile extends StatelessWidget {
icon: Icons.chrome_reader_mode_outlined, icon: Icons.chrome_reader_mode_outlined,
text: 'Details'.tl, text: 'Details'.tl,
onClick: () { onClick: () {
App.mainNavigatorKey?.currentContext?.to(() => ComicPage(id: comic.id, sourceKey: comic.sourceKey)); App.mainNavigatorKey?.currentContext
?.to(() => ComicPage(id: comic.id, sourceKey: comic.sourceKey));
}, },
), ),
MenuEntry( MenuEntry(
@@ -82,13 +84,17 @@ class ComicTile extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
var type = appdata.settings['comicDisplayMode']; var type = appdata.settings['comicDisplayMode'];
Widget child = type == 'detailed' ? _buildDetailedMode(context) : _buildBriefMode(context); Widget child = type == 'detailed'
? _buildDetailedMode(context)
: _buildBriefMode(context);
var isFavorite = appdata.settings['showFavoriteStatusOnTile'] var isFavorite = appdata.settings['showFavoriteStatusOnTile']
? LocalFavoritesManager().isExist(comic.id, ComicType(comic.sourceKey.hashCode)) ? LocalFavoritesManager()
.isExist(comic.id, ComicType(comic.sourceKey.hashCode))
: false; : false;
var history = appdata.settings['showHistoryStatusOnTile'] var history = appdata.settings['showHistoryStatusOnTile']
? HistoryManager().findSync(comic.id, ComicType(comic.sourceKey.hashCode)) ? HistoryManager()
.findSync(comic.id, ComicType(comic.sourceKey.hashCode))
: null; : null;
if (history?.page == 0) { if (history?.page == 0) {
history!.page = 1; history!.page = 1;
@@ -132,7 +138,8 @@ class ComicTile extends StatelessWidget {
constraints: const BoxConstraints(minWidth: 24), constraints: const BoxConstraints(minWidth: 24),
padding: const EdgeInsets.symmetric(horizontal: 4), padding: const EdgeInsets.symmetric(horizontal: 4),
child: CustomPaint( child: CustomPaint(
painter: _ReadingHistoryPainter(history.page, history.maxPage), painter:
_ReadingHistoryPainter(history.page, history.maxPage),
), ),
) )
], ],
@@ -205,7 +212,9 @@ class ComicTile extends StatelessWidget {
badge: badge ?? comic.language, badge: badge ?? comic.language,
tags: comic.tags, tags: comic.tags,
maxLines: 2, maxLines: 2,
enableTranslate: ComicSource.find(comic.sourceKey)?.enableTagsTranslate ?? false, enableTranslate: ComicSource.find(comic.sourceKey)
?.enableTagsTranslate ??
false,
rating: comic.stars, rating: comic.stars,
), ),
), ),
@@ -237,7 +246,9 @@ class ComicTile extends StatelessWidget {
Positioned.fill( Positioned.fill(
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).colorScheme.secondaryContainer, color: Theme.of(context)
.colorScheme
.secondaryContainer,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
clipBehavior: Clip.antiAlias, clipBehavior: Clip.antiAlias,
@@ -338,7 +349,9 @@ class ComicTile extends StatelessWidget {
} }
appdata.saveData(); appdata.saveData();
context.showMessage(message: 'Blocked'.tl); context.showMessage(message: 'Blocked'.tl);
comicTileContext.findAncestorStateOfType<_SliverGridComicsState>()!.update(); comicTileContext
.findAncestorStateOfType<_SliverGridComicsState>()!
.update();
}, },
child: Text('Block'.tl), child: Text('Block'.tl),
), ),
@@ -379,7 +392,8 @@ class _ComicDescription extends StatelessWidget {
s = s.replaceAll("\n", " "); s = s.replaceAll("\n", " ");
} }
} }
var enableTranslate = App.locale.languageCode == 'zh' && this.enableTranslate; var enableTranslate =
App.locale.languageCode == 'zh' && this.enableTranslate;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
@@ -396,7 +410,9 @@ class _ComicDescription extends StatelessWidget {
if (subtitle != "") if (subtitle != "")
Text( Text(
subtitle, subtitle,
style: TextStyle(fontSize: 10.0, color: context.colorScheme.onSurface.withOpacity(0.7)), style: TextStyle(
fontSize: 10.0,
color: context.colorScheme.onSurface.withOpacity(0.7)),
maxLines: 1, maxLines: 1,
softWrap: true, softWrap: true,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -433,13 +449,18 @@ class _ComicDescription extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
color: s == "Unavailable" color: s == "Unavailable"
? Theme.of(context).colorScheme.errorContainer ? Theme.of(context).colorScheme.errorContainer
: Theme.of(context).colorScheme.secondaryContainer, : Theme.of(context)
borderRadius: const BorderRadius.all(Radius.circular(8)), .colorScheme
.secondaryContainer,
borderRadius:
const BorderRadius.all(Radius.circular(8)),
), ),
child: Center( child: Center(
widthFactor: 1, widthFactor: 1,
child: Text( child: Text(
enableTranslate ? TagsTranslation.translateTag(s) : s.split(':').last, enableTranslate
? TagsTranslation.translateTag(s)
: s.split(':').last,
style: const TextStyle(fontSize: 12), style: const TextStyle(fontSize: 12),
softWrap: true, softWrap: true,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -510,17 +531,20 @@ class _ReadingHistoryPainter extends CustomPainter {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
); );
textPainter.layout(); textPainter.layout();
textPainter.paint(canvas, Offset((size.width - textPainter.width) / 2, (size.height - textPainter.height) / 2)); textPainter.paint(
canvas,
Offset((size.width - textPainter.width) / 2,
(size.height - textPainter.height) / 2));
} else if (page == maxPage) { } else if (page == maxPage) {
// 在中央绘制勾 // 在中央绘制勾
final paint = Paint() final paint = Paint()
..color = Colors.white ..color = Colors.white
..strokeWidth = 2 ..strokeWidth = 2
..style = PaintingStyle.stroke; ..style = PaintingStyle.stroke;
canvas.drawLine( canvas.drawLine(Offset(size.width * 0.2, size.height * 0.5),
Offset(size.width * 0.2, size.height * 0.5), Offset(size.width * 0.45, size.height * 0.75), paint); Offset(size.width * 0.45, size.height * 0.75), paint);
canvas.drawLine( canvas.drawLine(Offset(size.width * 0.45, size.height * 0.75),
Offset(size.width * 0.45, size.height * 0.75), Offset(size.width * 0.85, size.height * 0.3), paint); Offset(size.width * 0.85, size.height * 0.3), paint);
} else { } else {
// 在左上角绘制page, 在右下角绘制maxPage // 在左上角绘制page, 在右下角绘制maxPage
final textPainter = TextPainter( final textPainter = TextPainter(
@@ -546,13 +570,18 @@ class _ReadingHistoryPainter extends CustomPainter {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
); );
textPainter2.layout(); textPainter2.layout();
textPainter2.paint(canvas, Offset(size.width - textPainter2.width, size.height - textPainter2.height)); textPainter2.paint(
canvas,
Offset(size.width - textPainter2.width,
size.height - textPainter2.height));
} }
} }
@override @override
bool shouldRepaint(covariant CustomPainter oldDelegate) { bool shouldRepaint(covariant CustomPainter oldDelegate) {
return oldDelegate is! _ReadingHistoryPainter || oldDelegate.page != page || oldDelegate.maxPage != maxPage; return oldDelegate is! _ReadingHistoryPainter ||
oldDelegate.page != page ||
oldDelegate.maxPage != maxPage;
} }
} }
@@ -663,16 +692,22 @@ class _SliverGridComics extends StatelessWidget {
onLastItemBuild?.call(); onLastItemBuild?.call();
} }
var badge = badgeBuilder?.call(comics[index]); var badge = badgeBuilder?.call(comics[index]);
var isSelected = selection == null ? false : selection![comics[index]] ?? false; var isSelected =
selection == null ? false : selection![comics[index]] ?? false;
var comic = ComicTile( var comic = ComicTile(
comic: comics[index], comic: comics[index],
badge: badge, badge: badge,
menuOptions: menuBuilder?.call(comics[index]), menuOptions: menuBuilder?.call(comics[index]),
onTap: onTap != null ? () => onTap!(comics[index]) : null, onTap: onTap != null ? () => onTap!(comics[index]) : null,
); );
if(selection == null) {
return comic;
}
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: isSelected ? Theme.of(context).colorScheme.surfaceContainer : null, color: isSelected
? Theme.of(context).colorScheme.surfaceContainer
: null,
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
), ),
margin: const EdgeInsets.all(4), margin: const EdgeInsets.all(4),
@@ -797,7 +832,9 @@ class ComicListState extends State<ComicList> {
decoration: InputDecoration( decoration: InputDecoration(
labelText: "Page".tl, labelText: "Page".tl,
), ),
inputFormatters: <TextInputFormatter>[FilteringTextInputFormatter.digitsOnly], inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly
],
onChanged: (v) { onChanged: (v) {
value = v; value = v;
}, },
@@ -810,13 +847,15 @@ class ComicListState extends State<ComicList> {
if (page == null) { if (page == null) {
context.showMessage(message: "Invalid page".tl); context.showMessage(message: "Invalid page".tl);
} else { } else {
if (page > 0 && (_maxPage == null || page <= _maxPage!)) { if (page > 0 &&
(_maxPage == null || page <= _maxPage!)) {
setState(() { setState(() {
_error = null; _error = null;
_page = page; _page = page;
}); });
} else { } else {
context.showMessage(message: "Invalid page".tl); context.showMessage(
message: "Invalid page".tl);
} }
} }
}, },
@@ -828,7 +867,8 @@ class ComicListState extends State<ComicList> {
); );
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
child: Text("Page $_page / ${_maxPage ?? '?'}"), child: Text("Page $_page / ${_maxPage ?? '?'}"),
), ),
), ),
@@ -959,7 +999,8 @@ class ComicListState extends State<ComicList> {
comics: _data[_page] ?? const [], comics: _data[_page] ?? const [],
menuBuilder: widget.menuBuilder, menuBuilder: widget.menuBuilder,
), ),
if (_data[_page]!.length > 6 && _maxPage != 1) _buildSliverPageSelector(), if (_data[_page]!.length > 6 && _maxPage != 1)
_buildSliverPageSelector(),
if (widget.trailingSliver != null) widget.trailingSliver!, if (widget.trailingSliver != null) widget.trailingSliver!,
], ],
); );
@@ -1120,15 +1161,20 @@ class _RatingWidgetState extends State<RatingWidget> {
if (!widget.selectable) { if (!widget.selectable) {
return; return;
} }
if (dx >= widget.size * widget.count + widget.padding * (widget.count - 1)) { if (dx >=
widget.size * widget.count + widget.padding * (widget.count - 1)) {
value = widget.maxRating; value = widget.maxRating;
} else { } else {
for (double i = 1; i < widget.count + 1; i++) { for (double i = 1; i < widget.count + 1; i++) {
if (dx > widget.size * i + widget.padding * (i - 1) && dx < widget.size * i + widget.padding * i) { if (dx > widget.size * i + widget.padding * (i - 1) &&
dx < widget.size * i + widget.padding * i) {
value = i * (widget.maxRating / widget.count); value = i * (widget.maxRating / widget.count);
break; break;
} else if (dx > widget.size * (i - 1) + widget.padding * (i - 1) && dx < widget.size * i + widget.padding * i) { } else if (dx > widget.size * (i - 1) + widget.padding * (i - 1) &&
value = (dx - widget.padding * (i - 1)) / (widget.size * widget.count) * widget.maxRating; dx < widget.size * i + widget.padding * i) {
value = (dx - widget.padding * (i - 1)) /
(widget.size * widget.count) *
widget.maxRating;
break; break;
} }
} }
@@ -1156,7 +1202,8 @@ class _RatingWidgetState extends State<RatingWidget> {
if (widget.count / fullStars() == widget.maxRating / value) { if (widget.count / fullStars() == widget.maxRating / value) {
return 0; return 0;
} }
return (value % (widget.maxRating / widget.count)) / (widget.maxRating / widget.count); return (value % (widget.maxRating / widget.count)) /
(widget.maxRating / widget.count);
} }
List<Widget> buildRow() { List<Widget> buildRow() {

View File

@@ -31,8 +31,9 @@ class Select extends StatelessWidget {
var size = renderBox.size; var size = renderBox.size;
showMenu( showMenu(
elevation: 3, elevation: 3,
color: context.colorScheme.surface, color: context.brightness == Brightness.light
surfaceTintColor: Colors.transparent, ? const Color(0xFFF6F6F6)
: const Color(0xFF1E1E1E),
context: context, context: context,
useRootNavigator: true, useRootNavigator: true,
constraints: BoxConstraints( constraints: BoxConstraints(
@@ -41,8 +42,8 @@ class Select extends StatelessWidget {
), ),
position: RelativeRect.fromLTRB( position: RelativeRect.fromLTRB(
offset.dx, offset.dx,
offset.dy + size.height, offset.dy + size.height + 2,
offset.dx + size.height, offset.dx + size.height + 2,
offset.dy, offset.dy,
), ),
items: values items: values

View File

@@ -136,6 +136,8 @@ class ComicSource {
notifyListeners(); notifyListeners();
} }
static bool get isEmpty => _sources.isEmpty;
/// Name of this source. /// Name of this source.
final String name; final String name;

View File

@@ -1,7 +1,6 @@
import 'dart:io' as io; import 'dart:io' as io;
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter_qjs/flutter_qjs.dart';
import 'package:venera/foundation/app.dart'; import 'package:venera/foundation/app.dart';
import 'package:venera/foundation/appdata.dart'; import 'package:venera/foundation/appdata.dart';
import 'package:venera/foundation/consts.dart'; import 'package:venera/foundation/consts.dart';

View File

@@ -30,8 +30,15 @@ class CategoriesPage extends StatelessWidget {
.toList(); .toList();
if(categories.isEmpty) { if(categories.isEmpty) {
var msg = "No Category Pages".tl;
msg += '\n';
if(ComicSource.isEmpty) {
msg += "Add a comic source in home page".tl;
} else {
msg += "Please check your settings".tl;
}
return NetworkError( return NetworkError(
message: "No Category Pages".tl, message: msg,
retry: () { retry: () {
controller.update(); controller.update();
}, },
@@ -248,36 +255,19 @@ class _CategoryPage extends StatelessWidget {
Widget buildTag(String tag, ClickTagCallback onClick, Widget buildTag(String tag, ClickTagCallback onClick,
[String? namespace, String? param]) { [String? namespace, String? param]) {
String translateTag(String tag) {
/*
// TODO: Implement translation
if (enableTranslation) {
if (namespace != null) {
tag = TagsTranslation.translationTagWithNamespace(tag, namespace);
} else {
tag = tag.translateTagsToCN;
}
}
*/
return tag;
}
return Padding( return Padding(
padding: const EdgeInsets.fromLTRB(8, 6, 8, 6), padding: const EdgeInsets.fromLTRB(8, 6, 8, 6),
child: Builder( child: Builder(
builder: (context) { builder: (context) {
return Material( return Material(
elevation: 0.6, borderRadius: const BorderRadius.all(Radius.circular(8)),
borderRadius: const BorderRadius.all(Radius.circular(4)), color: context.colorScheme.primaryContainer.withOpacity(0.72),
color: context.colorScheme.surfaceContainerLow,
surfaceTintColor: Colors.transparent,
child: InkWell( child: InkWell(
borderRadius: const BorderRadius.all(Radius.circular(4)), borderRadius: const BorderRadius.all(Radius.circular(8)),
onTap: () => onClick(tag, param), onTap: () => onClick(tag, param),
child: Padding( child: Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
child: Text(translateTag(tag)), child: Text(tag),
), ),
), ),
); );

View File

@@ -327,7 +327,7 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
} }
Widget buildDescription() { Widget buildDescription() {
if (comic.description == null) { if (comic.description == null || comic.description!.trim().isEmpty) {
return const SliverPadding(padding: EdgeInsets.zero); return const SliverPadding(padding: EdgeInsets.zero);
} }
return SliverToBoxAdapter( return SliverToBoxAdapter(
@@ -392,6 +392,27 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
child: InkWell( child: InkWell(
borderRadius: borderRadius, borderRadius: borderRadius,
onTap: onTap, onTap: onTap,
onLongPress: () {
Clipboard.setData(ClipboardData(text: text));
context.showMessage(message: "Copied".tl);
},
onSecondaryTapDown: (details) {
showMenuX(context, details.globalPosition, [
MenuEntry(
icon: Icons.remove_red_eye,
text: "View".tl,
onClick: onTap,
),
MenuEntry(
icon: Icons.copy,
text: "Copy".tl,
onClick: () {
Clipboard.setData(ClipboardData(text: text));
context.showMessage(message: "Copied".tl);
},
),
]);
},
child: Text(text).padding(padding), child: Text(text).padding(padding),
), ),
); );
@@ -406,6 +427,26 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
} }
} }
String formatTime(String time) {
if (int.tryParse(time) != null) {
var t = int.tryParse(time);
if (t! > 1000000000000) {
return DateTime.fromMillisecondsSinceEpoch(t)
.toString()
.substring(0, 19);
} else {
return DateTime.fromMillisecondsSinceEpoch(t * 1000)
.toString()
.substring(0, 19);
}
}
if (time.contains('T') || time.contains('Z')) {
var t = DateTime.parse(time);
return t.toString().substring(0, 19);
}
return time;
}
Widget buildWrap({required List<Widget> children}) { Widget buildWrap({required List<Widget> children}) {
return Wrap( return Wrap(
runSpacing: 8, runSpacing: 8,
@@ -464,14 +505,14 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
buildWrap( buildWrap(
children: [ children: [
buildTag(text: 'Upload Time'.tl, isTitle: true), buildTag(text: 'Upload Time'.tl, isTitle: true),
buildTag(text: comic.uploadTime!), buildTag(text: formatTime(comic.uploadTime!)),
], ],
), ),
if (comic.updateTime != null) if (comic.updateTime != null)
buildWrap( buildWrap(
children: [ children: [
buildTag(text: 'Update Time'.tl, isTitle: true), buildTag(text: 'Update Time'.tl, isTitle: true),
buildTag(text: comic.updateTime!), buildTag(text: formatTime(comic.updateTime!)),
], ],
), ),
const SizedBox(height: 12), const SizedBox(height: 12),
@@ -1610,7 +1651,9 @@ class _SelectDownloadChapterState extends State<_SelectDownloadChapter> {
const SizedBox(width: 16), const SizedBox(width: 16),
Expanded( Expanded(
child: FilledButton( child: FilledButton(
onPressed: selected.isEmpty ? null : () { onPressed: selected.isEmpty
? null
: () {
widget.finishSelect(selected); widget.finishSelect(selected);
context.pop(); context.pop();
}, },

View File

@@ -95,24 +95,12 @@ class _BodyState extends State<_Body> {
return SmoothCustomScrollView( return SmoothCustomScrollView(
slivers: [ slivers: [
buildCard(context), buildCard(context),
buildSettings(),
for (var source in ComicSource.all()) buildSource(context, source), for (var source in ComicSource.all()) buildSource(context, source),
SliverPadding(padding: EdgeInsets.only(bottom: context.padding.bottom)), SliverPadding(padding: EdgeInsets.only(bottom: context.padding.bottom)),
], ],
); );
} }
Widget buildSettings() {
return SliverToBoxAdapter(
child: ListTile(
leading: const Icon(Icons.update_outlined),
title: Text("Check updates".tl),
onTap: () => ComicSourcePage.checkComicSourceUpdate(false),
trailing: const Icon(Icons.arrow_right),
),
);
}
Widget buildSource(BuildContext context, ComicSource source) { Widget buildSource(BuildContext context, ComicSource source) {
return SliverToBoxAdapter( return SliverToBoxAdapter(
child: Column( child: Column(
@@ -181,11 +169,12 @@ class _BodyState extends State<_Body> {
trailing: Select( trailing: Select(
current: (current as String).ts(source.key), current: (current as String).ts(source.key),
values: (item.value['options'] as List) values: (item.value['options'] as List)
.map<String>( .map<String>((e) =>
(e) => ((e['text'] ?? e['value']) as String).ts(source.key)) ((e['text'] ?? e['value']) as String).ts(source.key))
.toList(), .toList(),
onTap: (i) { onTap: (i) {
source.data['settings'][key] = item.value['options'][i]['value']; source.data['settings'][key] =
item.value['options'][i]['value'];
source.saveData(); source.saveData();
setState(() {}); setState(() {});
}, },
@@ -209,7 +198,8 @@ class _BodyState extends State<_Body> {
source.data['settings'][key] ?? item.value['default'] ?? ''; source.data['settings'][key] ?? item.value['default'] ?? '';
yield ListTile( yield ListTile(
title: Text((item.value['title'] as String).ts(source.key)), title: Text((item.value['title'] as String).ts(source.key)),
subtitle: Text(current, maxLines: 1, overflow: TextOverflow.ellipsis), subtitle:
Text(current, maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: IconButton( trailing: IconButton(
icon: const Icon(Icons.edit), icon: const Icon(Icons.edit),
onPressed: () { onPressed: () {
@@ -231,8 +221,7 @@ class _BodyState extends State<_Body> {
), ),
); );
} }
} } catch (e, s) {
catch(e, s) {
Log.error("ComicSourcePage", "Failed to build a setting\n$e\n$s"); Log.error("ComicSourcePage", "Failed to build a setting\n$e\n$s");
} }
} }
@@ -305,8 +294,13 @@ class _BodyState extends State<_Body> {
} }
Widget buildCard(BuildContext context) { Widget buildCard(BuildContext context) {
Widget buildButton({required Widget child, required VoidCallback onPressed}) {
return Button.normal(
onPressed: onPressed,
child: child,
).fixHeight(32);
}
return SliverToBoxAdapter( return SliverToBoxAdapter(
child: Card.outlined(
child: SizedBox( child: SizedBox(
width: double.infinity, width: double.infinity,
child: Column( child: Column(
@@ -321,39 +315,52 @@ class _BodyState extends State<_Body> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: "URL", hintText: "URL",
border: const UnderlineInputBorder(), border: const UnderlineInputBorder(),
contentPadding: contentPadding: const EdgeInsets.symmetric(horizontal: 12),
const EdgeInsets.symmetric(horizontal: 12),
suffix: IconButton( suffix: IconButton(
onPressed: () => handleAddSource(url), onPressed: () => handleAddSource(url),
icon: const Icon(Icons.check))), icon: const Icon(Icons.check))),
onChanged: (value) { onChanged: (value) {
url = value; url = value;
}, },
onSubmitted: handleAddSource) onSubmitted: handleAddSource,
.paddingHorizontal(16) ).paddingHorizontal(16).paddingBottom(8),
.paddingBottom(32), ListTile(
Row( title: Text("Comic Source list".tl),
children: [ trailing: buildButton(
TextButton( child: Text("View".tl),
onPressed: _selectFile, child: Text("Select file".tl))
.paddingLeft(8),
const Spacer(),
TextButton(
onPressed: () { onPressed: () {
showPopUpWidget( showPopUpWidget(
App.rootContext, _ComicSourceList(handleAddSource)); App.rootContext,
_ComicSourceList(handleAddSource),
);
}, },
child: Text("View list".tl)), ),
const Spacer(), ),
TextButton(onPressed: help, child: Text("Open help".tl)) ListTile(
.paddingRight(8), title: Text("Use a config file".tl),
], trailing: buildButton(
onPressed: _selectFile,
child: Text("Select".tl),
),
),
ListTile(
title: Text("Help".tl),
trailing: buildButton(
onPressed: help,
child: Text("Open".tl),
),
),
ListTile(
title: Text("Check updates".tl),
trailing: buildButton(
onPressed: () => ComicSourcePage.checkComicSourceUpdate(false),
child: Text("Check".tl),
),
), ),
const SizedBox(height: 8), const SizedBox(height: 8),
], ],
), ),
), ),
).paddingHorizontal(12),
); );
} }
@@ -372,8 +379,7 @@ class _BodyState extends State<_Body> {
} }
void help() { void help() {
launchUrlString( launchUrlString("https://github.com/venera-app/venera-configs");
"https://github.com/venera-app/venera/blob/master/doc/comic_source.md");
} }
Future<void> handleAddSource(String url) async { Future<void> handleAddSource(String url) async {

View File

@@ -93,8 +93,15 @@ class _ExplorePageState extends State<ExplorePage>
Widget buildBody(String i) => _SingleExplorePage(i, key: Key(i)); Widget buildBody(String i) => _SingleExplorePage(i, key: Key(i));
Widget buildEmpty() { Widget buildEmpty() {
var msg = "No Explore Pages".tl;
msg += '\n';
if(ComicSource.isEmpty) {
msg += "Add a comic source in home page".tl;
} else {
msg += "Please check your settings".tl;
}
return NetworkError( return NetworkError(
message: "No Explore Pages".tl, message: msg,
retry: () { retry: () {
setState(() { setState(() {
pages = ComicSource.all() pages = ComicSource.all()

View File

@@ -187,7 +187,7 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> {
}); });
}), }),
MenuEntry( MenuEntry(
icon: Icons.update, icon: Icons.download,
text: "Download All".tl, text: "Download All".tl,
onClick: () async { onClick: () async {
int count = 0; int count = 0;

View File

@@ -305,13 +305,24 @@ class _SearchPageState extends State<SearchPage> {
), ),
); );
} }
return ListTile( return InkWell(
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
title: Text(appdata.searchHistory[index - 2]),
onTap: () { onTap: () {
search(appdata.searchHistory[index - 2]); search(appdata.searchHistory[index - 2]);
}, },
); child: Container(
decoration: BoxDecoration(
// color: context.colorScheme.surfaceContainer,
border: Border(
left: BorderSide(
color: context.colorScheme.outlineVariant,
width: 2,
),
),
),
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
child: Text(appdata.searchHistory[index - 2], style: ts.s14),
),
).paddingBottom(8).paddingHorizontal(4);
}, },
childCount: 2 + appdata.searchHistory.length, childCount: 2 + appdata.searchHistory.length,
), ),

View File

@@ -134,7 +134,9 @@ class _DoubleLineSelectSettingsState extends State<_DoubleLineSelectSettings> {
builder: (context) { builder: (context) {
return ContentDialog( return ContentDialog(
title: "Help".tl, title: "Help".tl,
content: Text(widget.help!).paddingHorizontal(16).fixWidth(double.infinity), content: Text(widget.help!)
.paddingHorizontal(16)
.fixWidth(double.infinity),
actions: [ actions: [
Button.filled( Button.filled(
onPressed: context.pop, onPressed: context.pop,
@@ -159,8 +161,9 @@ class _DoubleLineSelectSettingsState extends State<_DoubleLineSelectSettings> {
var rect = offset & size; var rect = offset & size;
showMenu( showMenu(
elevation: 3, elevation: 3,
color: context.colorScheme.surface, color: context.brightness == Brightness.light
surfaceTintColor: Colors.transparent, ? const Color(0xFFF6F6F6)
: const Color(0xFF1E1E1E),
context: context, context: context,
position: RelativeRect.fromRect( position: RelativeRect.fromRect(
rect, rect,
@@ -230,7 +233,9 @@ class _EndSelectorSelectSettingState extends State<_EndSelectorSelectSetting> {
builder: (context) { builder: (context) {
return ContentDialog( return ContentDialog(
title: "Help".tl, title: "Help".tl,
content: Text(widget.help!).paddingHorizontal(16).fixWidth(double.infinity), content: Text(widget.help!)
.paddingHorizontal(16)
.fixWidth(double.infinity),
actions: [ actions: [
Button.filled( Button.filled(
onPressed: context.pop, onPressed: context.pop,
@@ -461,11 +466,15 @@ class _MultiPagesFilterState extends State<_MultiPagesFilter> {
showDialog( showDialog(
context: context, context: context,
builder: (context) { builder: (context) {
return SimpleDialog( return ContentDialog(
title: const Text("Add"), title: "Add".tl,
content: Column(
mainAxisSize: MainAxisSize.min,
children: canAdd.entries children: canAdd.entries
.map((e) => InkWell( .map(
child: ListTile(title: Text(e.value), key: Key(e.key)), (e) => ListTile(
title: Text(e.value),
key: Key(e.key),
onTap: () { onTap: () {
context.pop(); context.pop();
setState(() { setState(() {
@@ -473,10 +482,13 @@ class _MultiPagesFilterState extends State<_MultiPagesFilter> {
}); });
updateSetting(); updateSetting();
}, },
)) ),
)
.toList(), .toList(),
),
);
},
); );
});
} }
void updateSetting() { void updateSetting() {

View File

@@ -190,7 +190,6 @@ class IOSDirectoryPicker {
final String? path = await _channel.invokeMethod('selectDirectory'); final String? path = await _channel.invokeMethod('selectDirectory');
return path; return path;
} catch (e) { } catch (e) {
print("Error selecting directory: $e");
// 返回报错信息 // 返回报错信息
return e.toString(); return e.toString();
} }

View File

@@ -6,7 +6,7 @@ version: 1.0.5+105
environment: environment:
sdk: '>=3.5.0 <4.0.0' sdk: '>=3.5.0 <4.0.0'
flutter: 3.24.4 flutter: 3.24.5
dependencies: dependencies:
flutter: flutter: