diff --git a/assets/translation.json b/assets/translation.json index 7612940..d2dc8bc 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -43,7 +43,7 @@ "Confirm": "确认", "Are you sure you want to delete this comic?": "您确定要删除这部漫画吗?", "Are you sure you want to delete @a selected comics?": "您确定要删除 @a 部漫画吗?", - "Add comic source": "添加漫画来源", + "Add comic source": "添加漫画源", "Select file": "选择文件", "View list": "查看列表", "Open help": "打开帮助", @@ -102,8 +102,8 @@ "Auto page turning interval": "自动翻页间隔", "Theme Mode": "主题模式", "System": "系统", - "Light": "明亮", - "Dark": "黑暗", + "Light": "浅色", + "Dark": "深色", "Theme Color": "主题颜色", "Red": "红色", "Pink": "粉色", @@ -215,7 +215,21 @@ "Authorization Required": "需要身份验证", "Sync": "同步", "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": { "Home": "首頁", @@ -263,7 +277,7 @@ "Confirm": "確認", "Are you sure you want to delete this comic?": "您確定要刪除這部漫畫嗎?", "Are you sure you want to delete @a selected comics?": "您確定要刪除 @a 部漫畫嗎?", - "Add comic source": "添加漫畫來源", + "Add comic source": "添加漫畫源", "Select file": "選擇文件", "View list": "查看列表", "Open help": "打開幫助", @@ -320,8 +334,8 @@ "Auto page turning interval": "自動翻頁間隔", "Theme Mode": "主題模式", "System": "系統", - "Light": "明亮", - "Dark": "黑暗", + "Light": "浅色", + "Dark": "深色", "Theme Color": "主題顏色", "Red": "紅色", "Pink": "粉色", @@ -433,6 +447,20 @@ "Authorization Required": "需要身份驗證", "Sync": "同步", "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": "沒有分類頁面" } } \ No newline at end of file diff --git a/lib/components/comic.dart b/lib/components/comic.dart index 11d994b..92258cb 100644 --- a/lib/components/comic.dart +++ b/lib/components/comic.dart @@ -25,7 +25,8 @@ class ComicTile extends StatelessWidget { onTap!(); 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) { @@ -50,7 +51,8 @@ class ComicTile extends StatelessWidget { icon: Icons.chrome_reader_mode_outlined, text: 'Details'.tl, onClick: () { - App.mainNavigatorKey?.currentContext?.to(() => ComicPage(id: comic.id, sourceKey: comic.sourceKey)); + App.mainNavigatorKey?.currentContext + ?.to(() => ComicPage(id: comic.id, sourceKey: comic.sourceKey)); }, ), MenuEntry( @@ -82,13 +84,17 @@ class ComicTile extends StatelessWidget { Widget build(BuildContext context) { 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'] - ? LocalFavoritesManager().isExist(comic.id, ComicType(comic.sourceKey.hashCode)) + ? LocalFavoritesManager() + .isExist(comic.id, ComicType(comic.sourceKey.hashCode)) : false; var history = appdata.settings['showHistoryStatusOnTile'] - ? HistoryManager().findSync(comic.id, ComicType(comic.sourceKey.hashCode)) + ? HistoryManager() + .findSync(comic.id, ComicType(comic.sourceKey.hashCode)) : null; if (history?.page == 0) { history!.page = 1; @@ -132,7 +138,8 @@ class ComicTile extends StatelessWidget { constraints: const BoxConstraints(minWidth: 24), padding: const EdgeInsets.symmetric(horizontal: 4), 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, tags: comic.tags, maxLines: 2, - enableTranslate: ComicSource.find(comic.sourceKey)?.enableTagsTranslate ?? false, + enableTranslate: ComicSource.find(comic.sourceKey) + ?.enableTagsTranslate ?? + false, rating: comic.stars, ), ), @@ -237,7 +246,9 @@ class ComicTile extends StatelessWidget { Positioned.fill( child: Container( decoration: BoxDecoration( - color: Theme.of(context).colorScheme.secondaryContainer, + color: Theme.of(context) + .colorScheme + .secondaryContainer, borderRadius: BorderRadius.circular(8), ), clipBehavior: Clip.antiAlias, @@ -338,7 +349,9 @@ class ComicTile extends StatelessWidget { } appdata.saveData(); context.showMessage(message: 'Blocked'.tl); - comicTileContext.findAncestorStateOfType<_SliverGridComicsState>()!.update(); + comicTileContext + .findAncestorStateOfType<_SliverGridComicsState>()! + .update(); }, child: Text('Block'.tl), ), @@ -379,7 +392,8 @@ class _ComicDescription extends StatelessWidget { s = s.replaceAll("\n", " "); } } - var enableTranslate = App.locale.languageCode == 'zh' && this.enableTranslate; + var enableTranslate = + App.locale.languageCode == 'zh' && this.enableTranslate; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -396,7 +410,9 @@ class _ComicDescription extends StatelessWidget { if (subtitle != "") Text( 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, softWrap: true, overflow: TextOverflow.ellipsis, @@ -433,13 +449,18 @@ class _ComicDescription extends StatelessWidget { decoration: BoxDecoration( color: s == "Unavailable" ? Theme.of(context).colorScheme.errorContainer - : Theme.of(context).colorScheme.secondaryContainer, - borderRadius: const BorderRadius.all(Radius.circular(8)), + : Theme.of(context) + .colorScheme + .secondaryContainer, + borderRadius: + const BorderRadius.all(Radius.circular(8)), ), child: Center( widthFactor: 1, child: Text( - enableTranslate ? TagsTranslation.translateTag(s) : s.split(':').last, + enableTranslate + ? TagsTranslation.translateTag(s) + : s.split(':').last, style: const TextStyle(fontSize: 12), softWrap: true, overflow: TextOverflow.ellipsis, @@ -510,17 +531,20 @@ class _ReadingHistoryPainter extends CustomPainter { textDirection: TextDirection.ltr, ); 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) { // 在中央绘制勾 final paint = Paint() ..color = Colors.white ..strokeWidth = 2 ..style = PaintingStyle.stroke; - canvas.drawLine( - Offset(size.width * 0.2, size.height * 0.5), Offset(size.width * 0.45, size.height * 0.75), paint); - canvas.drawLine( - Offset(size.width * 0.45, size.height * 0.75), Offset(size.width * 0.85, size.height * 0.3), paint); + canvas.drawLine(Offset(size.width * 0.2, size.height * 0.5), + Offset(size.width * 0.45, size.height * 0.75), paint); + canvas.drawLine(Offset(size.width * 0.45, size.height * 0.75), + Offset(size.width * 0.85, size.height * 0.3), paint); } else { // 在左上角绘制page, 在右下角绘制maxPage final textPainter = TextPainter( @@ -546,13 +570,18 @@ class _ReadingHistoryPainter extends CustomPainter { textDirection: TextDirection.ltr, ); 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 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(); } 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( comic: comics[index], badge: badge, menuOptions: menuBuilder?.call(comics[index]), onTap: onTap != null ? () => onTap!(comics[index]) : null, ); + if(selection == null) { + return comic; + } return Container( decoration: BoxDecoration( - color: isSelected ? Theme.of(context).colorScheme.surfaceContainer : null, + color: isSelected + ? Theme.of(context).colorScheme.surfaceContainer + : null, borderRadius: BorderRadius.circular(12), ), margin: const EdgeInsets.all(4), @@ -797,7 +832,9 @@ class ComicListState extends State { decoration: InputDecoration( labelText: "Page".tl, ), - inputFormatters: [FilteringTextInputFormatter.digitsOnly], + inputFormatters: [ + FilteringTextInputFormatter.digitsOnly + ], onChanged: (v) { value = v; }, @@ -810,13 +847,15 @@ class ComicListState extends State { if (page == null) { context.showMessage(message: "Invalid page".tl); } else { - if (page > 0 && (_maxPage == null || page <= _maxPage!)) { + if (page > 0 && + (_maxPage == null || page <= _maxPage!)) { setState(() { _error = null; _page = page; }); } else { - context.showMessage(message: "Invalid page".tl); + context.showMessage( + message: "Invalid page".tl); } } }, @@ -828,7 +867,8 @@ class ComicListState extends State { ); }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + padding: + const EdgeInsets.symmetric(horizontal: 16, vertical: 6), child: Text("Page $_page / ${_maxPage ?? '?'}"), ), ), @@ -959,7 +999,8 @@ class ComicListState extends State { comics: _data[_page] ?? const [], 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!, ], ); @@ -1120,15 +1161,20 @@ class _RatingWidgetState extends State { if (!widget.selectable) { 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; } else { 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); break; - } else if (dx > widget.size * (i - 1) + widget.padding * (i - 1) && dx < widget.size * i + widget.padding * i) { - value = (dx - widget.padding * (i - 1)) / (widget.size * widget.count) * widget.maxRating; + } else if (dx > widget.size * (i - 1) + widget.padding * (i - 1) && + dx < widget.size * i + widget.padding * i) { + value = (dx - widget.padding * (i - 1)) / + (widget.size * widget.count) * + widget.maxRating; break; } } @@ -1156,7 +1202,8 @@ class _RatingWidgetState extends State { if (widget.count / fullStars() == widget.maxRating / value) { return 0; } - return (value % (widget.maxRating / widget.count)) / (widget.maxRating / widget.count); + return (value % (widget.maxRating / widget.count)) / + (widget.maxRating / widget.count); } List buildRow() { diff --git a/lib/components/select.dart b/lib/components/select.dart index 66c746e..e2b9e05 100644 --- a/lib/components/select.dart +++ b/lib/components/select.dart @@ -31,8 +31,9 @@ class Select extends StatelessWidget { var size = renderBox.size; showMenu( elevation: 3, - color: context.colorScheme.surface, - surfaceTintColor: Colors.transparent, + color: context.brightness == Brightness.light + ? const Color(0xFFF6F6F6) + : const Color(0xFF1E1E1E), context: context, useRootNavigator: true, constraints: BoxConstraints( @@ -41,8 +42,8 @@ class Select extends StatelessWidget { ), position: RelativeRect.fromLTRB( offset.dx, - offset.dy + size.height, - offset.dx + size.height, + offset.dy + size.height + 2, + offset.dx + size.height + 2, offset.dy, ), items: values diff --git a/lib/foundation/comic_source/comic_source.dart b/lib/foundation/comic_source/comic_source.dart index 758d8f3..a537918 100644 --- a/lib/foundation/comic_source/comic_source.dart +++ b/lib/foundation/comic_source/comic_source.dart @@ -136,6 +136,8 @@ class ComicSource { notifyListeners(); } + static bool get isEmpty => _sources.isEmpty; + /// Name of this source. final String name; diff --git a/lib/network/cloudflare.dart b/lib/network/cloudflare.dart index 7d8c5f2..ff22041 100644 --- a/lib/network/cloudflare.dart +++ b/lib/network/cloudflare.dart @@ -1,7 +1,6 @@ import 'dart:io' as io; import 'package:dio/dio.dart'; -import 'package:flutter_qjs/flutter_qjs.dart'; import 'package:venera/foundation/app.dart'; import 'package:venera/foundation/appdata.dart'; import 'package:venera/foundation/consts.dart'; diff --git a/lib/pages/categories_page.dart b/lib/pages/categories_page.dart index c55d1ac..fe2bb45 100644 --- a/lib/pages/categories_page.dart +++ b/lib/pages/categories_page.dart @@ -30,8 +30,15 @@ class CategoriesPage extends StatelessWidget { .toList(); 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( - message: "No Category Pages".tl, + message: msg, retry: () { controller.update(); }, @@ -248,36 +255,19 @@ class _CategoryPage extends StatelessWidget { Widget buildTag(String tag, ClickTagCallback onClick, [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( padding: const EdgeInsets.fromLTRB(8, 6, 8, 6), child: Builder( builder: (context) { return Material( - elevation: 0.6, - borderRadius: const BorderRadius.all(Radius.circular(4)), - color: context.colorScheme.surfaceContainerLow, - surfaceTintColor: Colors.transparent, + borderRadius: const BorderRadius.all(Radius.circular(8)), + color: context.colorScheme.primaryContainer.withOpacity(0.72), child: InkWell( - borderRadius: const BorderRadius.all(Radius.circular(4)), + borderRadius: const BorderRadius.all(Radius.circular(8)), onTap: () => onClick(tag, param), child: Padding( padding: const EdgeInsets.fromLTRB(16, 8, 16, 8), - child: Text(translateTag(tag)), + child: Text(tag), ), ), ); diff --git a/lib/pages/comic_page.dart b/lib/pages/comic_page.dart index fac9c64..081ad0f 100644 --- a/lib/pages/comic_page.dart +++ b/lib/pages/comic_page.dart @@ -327,7 +327,7 @@ class _ComicPageState extends LoadingState } Widget buildDescription() { - if (comic.description == null) { + if (comic.description == null || comic.description!.trim().isEmpty) { return const SliverPadding(padding: EdgeInsets.zero); } return SliverToBoxAdapter( @@ -392,6 +392,27 @@ class _ComicPageState extends LoadingState child: InkWell( borderRadius: borderRadius, 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), ), ); @@ -406,6 +427,26 @@ class _ComicPageState extends LoadingState } } + 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 children}) { return Wrap( runSpacing: 8, @@ -464,14 +505,14 @@ class _ComicPageState extends LoadingState buildWrap( children: [ buildTag(text: 'Upload Time'.tl, isTitle: true), - buildTag(text: comic.uploadTime!), + buildTag(text: formatTime(comic.uploadTime!)), ], ), if (comic.updateTime != null) buildWrap( children: [ buildTag(text: 'Update Time'.tl, isTitle: true), - buildTag(text: comic.updateTime!), + buildTag(text: formatTime(comic.updateTime!)), ], ), const SizedBox(height: 12), @@ -575,7 +616,7 @@ abstract mixin class _ComicPageActions { void quickFavorite() { var folder = appdata.settings['quickFavorite']; - if(folder is! String) { + if (folder is! String) { return; } LocalFavoritesManager().addComic( @@ -1037,7 +1078,7 @@ class _ComicThumbnailsState extends State<_ComicThumbnails> { if (!isInitialLoading && next == null) { return; } - if(isLoading) return; + if (isLoading) return; Future.microtask(() { setState(() { isLoading = true; @@ -1610,10 +1651,12 @@ class _SelectDownloadChapterState extends State<_SelectDownloadChapter> { const SizedBox(width: 16), Expanded( child: FilledButton( - onPressed: selected.isEmpty ? null : () { - widget.finishSelect(selected); - context.pop(); - }, + onPressed: selected.isEmpty + ? null + : () { + widget.finishSelect(selected); + context.pop(); + }, child: Text("Download Selected".tl), ), ), diff --git a/lib/pages/comic_source_page.dart b/lib/pages/comic_source_page.dart index 2657339..2ae6a71 100644 --- a/lib/pages/comic_source_page.dart +++ b/lib/pages/comic_source_page.dart @@ -40,7 +40,7 @@ class ComicSourcePage extends StatefulWidget { } controller?.close(); if (shouldUpdate.isEmpty) { - if(!implicit) { + if (!implicit) { App.rootContext.showMessage(message: "No Update Available".tl); } return; @@ -95,24 +95,12 @@ class _BodyState extends State<_Body> { return SmoothCustomScrollView( slivers: [ buildCard(context), - buildSettings(), for (var source in ComicSource.all()) buildSource(context, source), 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) { return SliverToBoxAdapter( child: Column( @@ -181,11 +169,12 @@ class _BodyState extends State<_Body> { trailing: Select( current: (current as String).ts(source.key), values: (item.value['options'] as List) - .map( - (e) => ((e['text'] ?? e['value']) as String).ts(source.key)) + .map((e) => + ((e['text'] ?? e['value']) as String).ts(source.key)) .toList(), onTap: (i) { - source.data['settings'][key] = item.value['options'][i]['value']; + source.data['settings'][key] = + item.value['options'][i]['value']; source.saveData(); setState(() {}); }, @@ -209,7 +198,8 @@ class _BodyState extends State<_Body> { source.data['settings'][key] ?? item.value['default'] ?? ''; yield ListTile( 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( icon: const Icon(Icons.edit), 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"); } } @@ -305,55 +294,73 @@ class _BodyState extends State<_Body> { } Widget buildCard(BuildContext context) { + Widget buildButton({required Widget child, required VoidCallback onPressed}) { + return Button.normal( + onPressed: onPressed, + child: child, + ).fixHeight(32); + } return SliverToBoxAdapter( - child: Card.outlined( - child: SizedBox( - width: double.infinity, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - ListTile( - title: Text("Add comic source".tl), - leading: const Icon(Icons.dashboard_customize), + child: SizedBox( + width: double.infinity, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + ListTile( + title: Text("Add comic source".tl), + leading: const Icon(Icons.dashboard_customize), + ), + TextField( + decoration: InputDecoration( + hintText: "URL", + border: const UnderlineInputBorder(), + contentPadding: const EdgeInsets.symmetric(horizontal: 12), + suffix: IconButton( + onPressed: () => handleAddSource(url), + icon: const Icon(Icons.check))), + onChanged: (value) { + url = value; + }, + onSubmitted: handleAddSource, + ).paddingHorizontal(16).paddingBottom(8), + ListTile( + title: Text("Comic Source list".tl), + trailing: buildButton( + child: Text("View".tl), + onPressed: () { + showPopUpWidget( + App.rootContext, + _ComicSourceList(handleAddSource), + ); + }, ), - TextField( - decoration: InputDecoration( - hintText: "URL", - border: const UnderlineInputBorder(), - contentPadding: - const EdgeInsets.symmetric(horizontal: 12), - suffix: IconButton( - onPressed: () => handleAddSource(url), - icon: const Icon(Icons.check))), - onChanged: (value) { - url = value; - }, - onSubmitted: handleAddSource) - .paddingHorizontal(16) - .paddingBottom(32), - Row( - children: [ - TextButton( - onPressed: _selectFile, child: Text("Select file".tl)) - .paddingLeft(8), - const Spacer(), - TextButton( - onPressed: () { - showPopUpWidget( - App.rootContext, _ComicSourceList(handleAddSource)); - }, - child: Text("View list".tl)), - const Spacer(), - TextButton(onPressed: help, child: Text("Open help".tl)) - .paddingRight(8), - ], + ), + ListTile( + title: Text("Use a config file".tl), + trailing: buildButton( + onPressed: _selectFile, + child: Text("Select".tl), ), - const SizedBox(height: 8), - ], - ), + ), + 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), + ], ), - ).paddingHorizontal(12), + ), ); } @@ -372,8 +379,7 @@ class _BodyState extends State<_Body> { } void help() { - launchUrlString( - "https://github.com/venera-app/venera/blob/master/doc/comic_source.md"); + launchUrlString("https://github.com/venera-app/venera-configs"); } Future handleAddSource(String url) async { diff --git a/lib/pages/explore_page.dart b/lib/pages/explore_page.dart index d575b7f..125bd7d 100644 --- a/lib/pages/explore_page.dart +++ b/lib/pages/explore_page.dart @@ -93,8 +93,15 @@ class _ExplorePageState extends State Widget buildBody(String i) => _SingleExplorePage(i, key: Key(i)); 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( - message: "No Explore Pages".tl, + message: msg, retry: () { setState(() { pages = ComicSource.all() diff --git a/lib/pages/favorites/local_favorites_page.dart b/lib/pages/favorites/local_favorites_page.dart index ec9e070..460aedd 100644 --- a/lib/pages/favorites/local_favorites_page.dart +++ b/lib/pages/favorites/local_favorites_page.dart @@ -187,7 +187,7 @@ class _LocalFavoritesPageState extends State<_LocalFavoritesPage> { }); }), MenuEntry( - icon: Icons.update, + icon: Icons.download, text: "Download All".tl, onClick: () async { int count = 0; diff --git a/lib/pages/search_page.dart b/lib/pages/search_page.dart index 6bfc070..735c7e5 100644 --- a/lib/pages/search_page.dart +++ b/lib/pages/search_page.dart @@ -305,13 +305,24 @@ class _SearchPageState extends State { ), ); } - return ListTile( - contentPadding: const EdgeInsets.symmetric(horizontal: 12), - title: Text(appdata.searchHistory[index - 2]), + return InkWell( onTap: () { 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, ), @@ -490,7 +501,7 @@ class SearchOptionWidget extends StatelessWidget { contentPadding: EdgeInsets.zero, title: Text(option.label.ts(sourceKey)), ), - if(option.type == 'select') + if (option.type == 'select') Wrap( runSpacing: 8, spacing: 8, @@ -504,7 +515,7 @@ class SearchOptionWidget extends StatelessWidget { ); }).toList(), ), - if(option.type == 'multi-select') + if (option.type == 'multi-select') Wrap( runSpacing: 8, spacing: 8, @@ -514,7 +525,7 @@ class SearchOptionWidget extends StatelessWidget { isSelected: (jsonDecode(value) as List).contains(e.key), onTap: () { var list = jsonDecode(value) as List; - if(list.contains(e.key)) { + if (list.contains(e.key)) { list.remove(e.key); } else { list.add(e.key); @@ -524,7 +535,7 @@ class SearchOptionWidget extends StatelessWidget { ); }).toList(), ), - if(option.type == 'dropdown') + if (option.type == 'dropdown') Select( current: option.options[value], values: option.options.values.toList(), diff --git a/lib/pages/settings/setting_components.dart b/lib/pages/settings/setting_components.dart index 6472ca8..6e43be1 100644 --- a/lib/pages/settings/setting_components.dart +++ b/lib/pages/settings/setting_components.dart @@ -134,7 +134,9 @@ class _DoubleLineSelectSettingsState extends State<_DoubleLineSelectSettings> { builder: (context) { return ContentDialog( title: "Help".tl, - content: Text(widget.help!).paddingHorizontal(16).fixWidth(double.infinity), + content: Text(widget.help!) + .paddingHorizontal(16) + .fixWidth(double.infinity), actions: [ Button.filled( onPressed: context.pop, @@ -159,8 +161,9 @@ class _DoubleLineSelectSettingsState extends State<_DoubleLineSelectSettings> { var rect = offset & size; showMenu( elevation: 3, - color: context.colorScheme.surface, - surfaceTintColor: Colors.transparent, + color: context.brightness == Brightness.light + ? const Color(0xFFF6F6F6) + : const Color(0xFF1E1E1E), context: context, position: RelativeRect.fromRect( rect, @@ -230,7 +233,9 @@ class _EndSelectorSelectSettingState extends State<_EndSelectorSelectSetting> { builder: (context) { return ContentDialog( title: "Help".tl, - content: Text(widget.help!).paddingHorizontal(16).fixWidth(double.infinity), + content: Text(widget.help!) + .paddingHorizontal(16) + .fixWidth(double.infinity), actions: [ Button.filled( onPressed: context.pop, @@ -459,24 +464,31 @@ class _MultiPagesFilterState extends State<_MultiPagesFilter> { } }); showDialog( - context: context, - builder: (context) { - return SimpleDialog( - title: const Text("Add"), + context: context, + builder: (context) { + return ContentDialog( + title: "Add".tl, + content: Column( + mainAxisSize: MainAxisSize.min, children: canAdd.entries - .map((e) => InkWell( - child: ListTile(title: Text(e.value), key: Key(e.key)), - onTap: () { - context.pop(); - setState(() { - keys.add(e.key); - }); - updateSetting(); - }, - )) + .map( + (e) => ListTile( + title: Text(e.value), + key: Key(e.key), + onTap: () { + context.pop(); + setState(() { + keys.add(e.key); + }); + updateSetting(); + }, + ), + ) .toList(), - ); - }); + ), + ); + }, + ); } void updateSetting() { diff --git a/lib/utils/io.dart b/lib/utils/io.dart index 8ddf9c6..5e41265 100644 --- a/lib/utils/io.dart +++ b/lib/utils/io.dart @@ -190,7 +190,6 @@ class IOSDirectoryPicker { final String? path = await _channel.invokeMethod('selectDirectory'); return path; } catch (e) { - print("Error selecting directory: $e"); // 返回报错信息 return e.toString(); } diff --git a/pubspec.yaml b/pubspec.yaml index 19e08db..d061be5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ version: 1.0.5+105 environment: sdk: '>=3.5.0 <4.0.0' - flutter: 3.24.4 + flutter: 3.24.5 dependencies: flutter: