mirror of
https://github.com/wgh136/pixes.git
synced 2025-09-27 04:57:23 +00:00
block tags
This commit is contained in:
@@ -23,6 +23,7 @@ class _Appdata {
|
||||
"readingFontSize": 16.0,
|
||||
"readingLineHeight": 1.5,
|
||||
"readingParagraphSpacing": 8.0,
|
||||
"blockTags": [],
|
||||
};
|
||||
|
||||
bool lock = false;
|
||||
|
@@ -108,7 +108,7 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
Widget? buildFrame(BuildContext context, Widget child) => null;
|
||||
|
||||
Widget buildContent(BuildContext context, final List<S> data);
|
||||
Widget buildContent(BuildContext context, List<S> data);
|
||||
|
||||
bool get isLoading => _isLoading || _isFirstLoading;
|
||||
|
||||
|
@@ -181,6 +181,7 @@ class Illust {
|
||||
bool isBookmarked;
|
||||
final bool isAi;
|
||||
final bool isUgoira;
|
||||
final bool isBlocked;
|
||||
|
||||
bool get isR18 => tags.contains(const Tag("R-18", null));
|
||||
|
||||
@@ -227,7 +228,8 @@ class Illust {
|
||||
totalBookmarks = json['total_bookmarks'],
|
||||
isBookmarked = json['is_bookmarked'],
|
||||
isAi = json['illust_ai_type'] == 2,
|
||||
isUgoira = json['type'] == "ugoira";
|
||||
isUgoira = json['type'] == "ugoira",
|
||||
isBlocked = json['is_muted'] ?? false;
|
||||
}
|
||||
|
||||
class TrendingTag {
|
||||
|
@@ -2,6 +2,7 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/batch_download.dart';
|
||||
@@ -27,7 +28,10 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
children: [
|
||||
buildTab(),
|
||||
Expanded(
|
||||
child: _OneFollowingPage(restrict, key: Key(restrict),),
|
||||
child: _OneFollowingPage(
|
||||
restrict,
|
||||
key: Key(restrict),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -38,8 +42,11 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
title: "Following".tl,
|
||||
action: Row(
|
||||
children: [
|
||||
BatchDownloadButton(request: () => Network().getFollowingArtworks(restrict)),
|
||||
const SizedBox(width: 8,),
|
||||
BatchDownloadButton(
|
||||
request: () => Network().getFollowingArtworks(restrict)),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
SegmentedButton(
|
||||
options: [
|
||||
SegmentedButtonOption("all", "All".tl),
|
||||
@@ -47,7 +54,7 @@ class _FollowingArtworksPageState extends State<FollowingArtworksPage> {
|
||||
SegmentedButtonOption("private", "Private".tl),
|
||||
],
|
||||
onPressed: (key) {
|
||||
if(key != restrict) {
|
||||
if (key != restrict) {
|
||||
setState(() {
|
||||
restrict = key;
|
||||
});
|
||||
@@ -70,27 +77,26 @@ class _OneFollowingPage extends StatefulWidget {
|
||||
State<_OneFollowingPage> createState() => _OneFollowingPageState();
|
||||
}
|
||||
|
||||
class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
||||
class _OneFollowingPageState
|
||||
extends MultiPageLoadingState<_OneFollowingPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
return LayoutBuilder(builder: (context, constrains){
|
||||
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
+ EdgeInsets.only(bottom: context.padding.bottom),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
EdgeInsets.only(bottom: context.padding.bottom),
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
),
|
||||
itemCount: data.length,
|
||||
itemBuilder: (context, index) {
|
||||
if(index == data.length - 1){
|
||||
if (index == data.length - 1) {
|
||||
nextPage();
|
||||
}
|
||||
return IllustWidget(data[index], onTap: () {
|
||||
context.to(() => IllustGalleryPage(
|
||||
illusts: data,
|
||||
initialPage: index,
|
||||
nextUrl: nextUrl
|
||||
));
|
||||
illusts: data, initialPage: index, nextUrl: nextUrl));
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -100,16 +106,15 @@ class _OneFollowingPageState extends MultiPageLoadingState<_OneFollowingPage, Il
|
||||
String? nextUrl;
|
||||
|
||||
@override
|
||||
Future<Res<List<Illust>>> loadData(page) async{
|
||||
if(nextUrl == "end") {
|
||||
Future<Res<List<Illust>>> loadData(page) async {
|
||||
if (nextUrl == "end") {
|
||||
return Res.error("No more data");
|
||||
}
|
||||
var res = await Network().getFollowingArtworks(widget.restrict, nextUrl);
|
||||
if(!res.error) {
|
||||
if (!res.error) {
|
||||
nextUrl = res.subData;
|
||||
nextUrl ??= "end";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/batch_download.dart';
|
||||
@@ -86,6 +87,7 @@ class _OneRankingPage extends StatefulWidget {
|
||||
class _OneRankingPageState extends MultiPageLoadingState<_OneRankingPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains){
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8)
|
||||
|
@@ -6,6 +6,7 @@ import 'package:pixes/components/title_bar.dart';
|
||||
import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/grid.dart';
|
||||
@@ -75,6 +76,7 @@ class _RecommendationArtworksPageState
|
||||
extends MultiPageLoadingState<_RecommendationArtworksPage, Illust> {
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return LayoutBuilder(builder: (context, constrains) {
|
||||
return MasonryGridView.builder(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8) +
|
||||
|
@@ -11,6 +11,7 @@ import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/illust_page.dart';
|
||||
import 'package:pixes/pages/novel_page.dart';
|
||||
import 'package:pixes/pages/user_info_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
|
||||
import '../components/animated_image.dart';
|
||||
@@ -456,6 +457,7 @@ class _SearchResultPageState
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
buildSearchBar(),
|
||||
|
@@ -13,6 +13,7 @@ import 'package:pixes/foundation/app.dart';
|
||||
import 'package:pixes/foundation/image_provider.dart';
|
||||
import 'package:pixes/network/network.dart';
|
||||
import 'package:pixes/pages/following_users_page.dart';
|
||||
import 'package:pixes/utils/block.dart';
|
||||
import 'package:pixes/utils/translation.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
@@ -360,7 +361,8 @@ class _UserArtworksState extends MultiPageLoadingState<_UserArtworks, Illust> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget buildContent(BuildContext context, final List<Illust> data) {
|
||||
Widget buildContent(BuildContext context, List<Illust> data) {
|
||||
checkIllusts(data);
|
||||
return SliverMasonryGrid(
|
||||
gridDelegate: const SliverSimpleGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 240,
|
||||
|
22
lib/utils/block.dart
Normal file
22
lib/utils/block.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:pixes/appdata.dart';
|
||||
import 'package:pixes/network/models.dart';
|
||||
|
||||
void checkIllusts(List<Illust> illusts) {
|
||||
illusts.removeWhere((illust) {
|
||||
if (illust.isBlocked) {
|
||||
return true;
|
||||
}
|
||||
if (appdata.settings["blockTags"] == null) {
|
||||
return false;
|
||||
}
|
||||
if (appdata.settings["blockTags"].contains(illust.author.name)) {
|
||||
return true;
|
||||
}
|
||||
for (var tag in illust.tags) {
|
||||
if ((appdata.settings["blockTags"] as List).contains(tag.name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user