diff --git a/assets/translation.json b/assets/translation.json index 8997413..dda65ab 100644 --- a/assets/translation.json +++ b/assets/translation.json @@ -57,7 +57,7 @@ "Password": "密码", "Continue": "继续", "Create Account": "创建账户", - "Next": "下一步", + "Next": "前进", "Login with webview": "通过网页登录", "Read": "阅读", "Download": "下载", @@ -122,7 +122,11 @@ "Proxy": "代理", "Venera is a free and open-source app for comic reading.": "Venera是一个免费的开源漫画阅读应用。", "Check for updates": "检查更新", - "Check": "检查" + "Check": "检查", + "Network Favorite Pages": "网络收藏页面", + "Block": "屏蔽", + "Add new favorite to": "添加新收藏到", + "Move favorite after reading": "阅读后移动收藏" }, "zh_TW": { "Home": "首頁", @@ -182,7 +186,7 @@ "Password": "密碼", "Continue": "繼續", "Create Account": "創建帳戶", - "Next": "下一步", + "Next": "前進", "Login with webview": "通過網頁登錄", "Read": "閱讀", "Download": "下載", @@ -247,6 +251,10 @@ "Proxy": "代理", "Venera is a free and open-source app for comic reading.": "Venera是一個免費的開源漫畫閱讀應用。", "Check for updates": "檢查更新", - "Check": "檢查" + "Check": "檢查", + "Network Favorite Pages": "網路收藏頁面", + "Block": "屏蔽", + "Add new favorite to": "添加新收藏到", + "Move favorite after reading": "閱讀後移動收藏" } } \ No newline at end of file diff --git a/lib/components/comic.dart b/lib/components/comic.dart index 7b096d9..3bee958 100644 --- a/lib/components/comic.dart +++ b/lib/components/comic.dart @@ -35,14 +35,14 @@ class ComicTile extends StatelessWidget { var location = renderBox.localToGlobal( Offset(size.width / 2, size.height / 2), ); - showMenu(location); + showMenu(location, context); } - void onSecondaryTap(TapDownDetails details) { - showMenu(details.globalPosition); + void onSecondaryTap(TapDownDetails details, BuildContext context) { + showMenu(details.globalPosition, context); } - void showMenu(Offset location) { + void showMenu(Offset location, BuildContext context) { showMenuX( App.rootContext, location, @@ -70,6 +70,11 @@ class ComicTile extends StatelessWidget { addFavorite(comic); }, ), + MenuEntry( + icon: Icons.block, + text: 'Block'.tl, + onClick: () => block(context), + ), ...?menuOptions, ], ); @@ -172,7 +177,7 @@ class ComicTile extends StatelessWidget { borderRadius: BorderRadius.circular(12), onTap: _onTap, onLongPress: enableLongPressed ? () => onLongPress(context) : null, - onSecondaryTapDown: onSecondaryTap, + onSecondaryTapDown: (detail) => onSecondaryTap(detail, context), child: Padding( padding: const EdgeInsets.fromLTRB(16, 8, 24, 8), child: Row( @@ -272,7 +277,7 @@ class ComicTile extends StatelessWidget { onTap: _onTap, onLongPress: enableLongPressed ? () => onLongPress(context) : null, - onSecondaryTapDown: onSecondaryTap, + onSecondaryTapDown: (detail) => onSecondaryTap(detail, context), borderRadius: BorderRadius.circular(8), child: const SizedBox.expand(), ), @@ -283,6 +288,61 @@ class ComicTile extends StatelessWidget { ), ); } + + void block(BuildContext comicTileContext) { + showDialog( + context: App.rootContext, + builder: (context) { + var words = []; + var all = []; + all.addAll(comic.title.split(' ').where((element) => element != '')); + if(comic.subtitle != null && comic.subtitle != "") { + all.add(comic.subtitle!); + } + all.addAll(comic.tags ?? []); + return StatefulBuilder(builder: (context, setState) { + return ContentDialog( + title: 'Block'.tl, + content: Wrap( + runSpacing: 8, + spacing: 8, + children: [ + for (var word in all) + OptionChip( + text: word, + isSelected: words.contains(word), + onTap: () { + setState(() { + if (!words.contains(word)) { + words.add(word); + } else { + words.remove(word); + } + }); + }, + ), + ], + ).paddingHorizontal(16), + actions: [ + Button.filled( + onPressed: () { + context.pop(); + for (var word in words) { + appdata.settings['blockedWords'].add(word); + } + appdata.saveData(); + context.showMessage(message: 'Blocked'.tl); + comicTileContext.findAncestorStateOfType<_SliverGridComicsState>()! + .update(); + }, + child: Text('Block'.tl), + ), + ], + ); + }); + }, + ); + } } class _ComicDescription extends StatelessWidget { @@ -480,9 +540,7 @@ class _ReadingHistoryPainter extends CustomPainter { } } -class SliverGridComicsController extends StateController {} - -class SliverGridComics extends StatelessWidget { +class SliverGridComics extends StatefulWidget { const SliverGridComics({ super.key, required this.comics, @@ -503,24 +561,41 @@ class SliverGridComics extends StatelessWidget { final void Function(Comic)? onTap; @override - Widget build(BuildContext context) { - return StateBuilder( - init: SliverGridComicsController(), - builder: (controller) { - List comics = []; - for (var comic in this.comics) { - if (isBlocked(comic) == null) { - comics.add(comic); - } + State createState() => _SliverGridComicsState(); +} + +class _SliverGridComicsState extends State { + List comics = []; + + @override + void initState() { + for (var comic in widget.comics) { + if (isBlocked(comic) == null) { + comics.add(comic); + } + } + super.initState(); + } + + void update() { + setState(() { + comics.clear(); + for (var comic in widget.comics) { + if (isBlocked(comic) == null) { + comics.add(comic); } - return _SliverGridComics( - comics: comics, - onLastItemBuild: onLastItemBuild, - badgeBuilder: badgeBuilder, - menuBuilder: menuBuilder, - onTap: onTap, - ); - }, + } + }); + } + + @override + Widget build(BuildContext context) { + return _SliverGridComics( + comics: comics, + onLastItemBuild: widget.onLastItemBuild, + badgeBuilder: widget.badgeBuilder, + menuBuilder: widget.menuBuilder, + onTap: widget.onTap, ); } } diff --git a/lib/pages/settings/explore_settings.dart b/lib/pages/settings/explore_settings.dart index 00a979d..1f3be7b 100644 --- a/lib/pages/settings/explore_settings.dart +++ b/lib/pages/settings/explore_settings.dart @@ -61,7 +61,7 @@ class _ExploreSettingsState extends State { }, ).toSliver(), _PopupWindowSetting( - title: "Explore Pages".tl, + title: "Network Favorite Pages".tl, builder: () { var pages = {}; for (var c in ComicSource.all()) { diff --git a/lib/pages/settings/local_favorites.dart b/lib/pages/settings/local_favorites.dart index 6169b4f..ac056e5 100644 --- a/lib/pages/settings/local_favorites.dart +++ b/lib/pages/settings/local_favorites.dart @@ -13,16 +13,16 @@ class _LocalFavoritesSettingsState extends State { return SmoothCustomScrollView( slivers: [ SliverAppbar(title: Text("Local Favorites".tl)), - const SelectSetting( - title: "Add new favorite to", + SelectSetting( + title: "Add new favorite to".tl, settingKey: "newFavoriteAddTo", - optionTranslation: { + optionTranslation: const { "start": "Start", "end": "End", }, ).toSliver(), - const SelectSetting( - title: "Move favorite after read", + SelectSetting( + title: "Move favorite after reading".tl, settingKey: "moveFavoriteAfterRead", optionTranslation: { "none": "None",