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