Skip to content

Commit

Permalink
Allow hiding comments below custom threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
3003h committed Oct 30, 2023
1 parent 61c836d commit 9b46fb5
Show file tree
Hide file tree
Showing 24 changed files with 249 additions and 65 deletions.
2 changes: 1 addition & 1 deletion jsons/block_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"filter_comments_by_score?": false,
"filtering_threshold?": 0
"score_filtering_threshold?": -20
}
2 changes: 1 addition & 1 deletion lib/common/controller/block_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import 'package:fehviewer/common/service/ehsetting_service.dart';
import 'package:get/get.dart';

class BlockController extends GetxController {
final EhSettingService ehSettingService = Get.find();
EhSettingService get ehSettingService => Get.find();
}
2 changes: 1 addition & 1 deletion lib/common/global.dart
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class Global {

// 持久化Profile信息
static void saveProfile() {
// logger.d(profile.layoutConfig?.toJson());
// logger.d(profile.blockConfig?.toJson());
hiveHelper.profile = profile;
}

Expand Down
30 changes: 27 additions & 3 deletions lib/common/service/ehsetting_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -746,19 +746,43 @@ class EhSettingService extends ProfileService {
});
}

void _initBlockConfig() {}
// _filterCommentsByScore
final _filterCommentsByScore = false.obs;
bool get filterCommentsByScore => _filterCommentsByScore.value;
set filterCommentsByScore(bool val) => _filterCommentsByScore.value = val;

// _scoreFilteringThreshold
final _scoreFilteringThreshold = (-20).obs;
int get scoreFilteringThreshold => _scoreFilteringThreshold.value;
set scoreFilteringThreshold(int val) => _scoreFilteringThreshold.value = val;

void _initBlockConfig() {
// _filterCommentsByScore
filterCommentsByScore =
blockConfig.filterCommentsByScore ?? filterCommentsByScore;
everProfile<bool>(_filterCommentsByScore, (val) {
blockConfig = blockConfig.copyWith(filterCommentsByScore: val);
});

// _scoreFilteringThreshold
scoreFilteringThreshold =
blockConfig.scoreFilteringThreshold ?? scoreFilteringThreshold;
everProfile<int>(_scoreFilteringThreshold, (val) {
blockConfig = blockConfig.copyWith(scoreFilteringThreshold: val);
});
}

@override
void onInit() {
super.onInit();

_initEhConfig();

_initDownloadConfig();

_initLayoutConfig();

_initBlockConfig();

_initEhConfig();
}

Future<void> setProxy() async {
Expand Down
21 changes: 14 additions & 7 deletions lib/component/setting_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const double kCupertinoItemHeight = 36.0;

const double kDividerHeight = 1.0;

const double kSummaryFontSize = 12.0;

class BarsItem extends StatelessWidget {
const BarsItem({
Key? key,
Expand All @@ -33,7 +35,9 @@ class BarsItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
const _kDescStyle = TextStyle(
fontSize: 12.5, height: 1.1, color: CupertinoColors.systemGrey);
fontSize: kSummaryFontSize,
height: 1.1,
color: CupertinoColors.systemGrey);

return Column(
children: [
Expand Down Expand Up @@ -147,7 +151,9 @@ class _SelectorSettingItemState extends State<SelectorSettingItem> {
}

const _kDescStyle = TextStyle(
fontSize: 12.5, height: 1.1, color: CupertinoColors.systemGrey);
fontSize: kSummaryFontSize,
height: 1.1,
color: CupertinoColors.systemGrey);

Widget titleWidget = Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down Expand Up @@ -358,7 +364,7 @@ class _SlidingSegmentedItemState<T> extends State<SlidingSegmentedItem<T>> {
Text(
_desc ?? widget.desc ?? '',
style: const TextStyle(
fontSize: 12.5,
fontSize: kSummaryFontSize,
color: CupertinoColors.systemGrey),
).paddingOnly(top: 2.0),
]),
Expand Down Expand Up @@ -503,7 +509,7 @@ class _TextSwitchItemState extends State<TextSwitchItem> {
Text(
_desc ?? widget.desc ?? '',
style: const TextStyle(
fontSize: 12.5,
fontSize: kSummaryFontSize,
color: CupertinoColors.systemGrey),
).paddingOnly(top: 2.0),
]),
Expand Down Expand Up @@ -630,7 +636,8 @@ class _TextItemState extends State<TextItem> {
Text(
widget.subTitle ?? '',
style: const TextStyle(
fontSize: 12.5, color: CupertinoColors.systemGrey),
fontSize: kSummaryFontSize,
color: CupertinoColors.systemGrey),
).paddingOnly(top: 2.0),
]),
),
Expand Down Expand Up @@ -995,7 +1002,7 @@ class GroupItem extends StatelessWidget {
child: Text(
descTop!,
style: TextStyle(
fontSize: 12.5,
fontSize: kSummaryFontSize,
color: CupertinoDynamicColor.resolve(
CupertinoColors.secondaryLabel, context),
),
Expand All @@ -1015,7 +1022,7 @@ class GroupItem extends StatelessWidget {
child: Text(
desc!,
style: TextStyle(
fontSize: 12.5,
fontSize: kSummaryFontSize,
color: CupertinoDynamicColor.resolve(
CupertinoColors.secondaryLabel, context),
),
Expand Down
6 changes: 6 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class MessageLookup extends MessageLookupByLibrary {
"automatic": MessageLookupByLibrary.simpleMessage("Automatic"),
"avatar": MessageLookupByLibrary.simpleMessage("Avatar"),
"back": MessageLookupByLibrary.simpleMessage("Back"),
"blockers": MessageLookupByLibrary.simpleMessage("Blockers"),
"blurring_cover_background": MessageLookupByLibrary.simpleMessage(
"Blurring of cover background"),
"cancel": MessageLookupByLibrary.simpleMessage("Cancel"),
Expand Down Expand Up @@ -163,6 +164,11 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Use Favorited"),
"favorites_order_Use_posted":
MessageLookupByLibrary.simpleMessage("Use Posted"),
"filter_comments_by_score":
MessageLookupByLibrary.simpleMessage("Filter Comments By Score"),
"filter_comments_by_score_summary":
MessageLookupByLibrary.simpleMessage(
"Comments below/equal to this score will be hidden"),
"fixed_height_of_list_items":
MessageLookupByLibrary.simpleMessage("Fixed height of list items"),
"follow_system": MessageLookupByLibrary.simpleMessage("Follow System"),
Expand Down
6 changes: 6 additions & 0 deletions lib/generated/intl/messages_ko_KR.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class MessageLookup extends MessageLookupByLibrary {
"automatic": MessageLookupByLibrary.simpleMessage("Automatic"),
"avatar": MessageLookupByLibrary.simpleMessage("Avatar"),
"back": MessageLookupByLibrary.simpleMessage("뒤로"),
"blockers": MessageLookupByLibrary.simpleMessage("Blockers"),
"blurring_cover_background": MessageLookupByLibrary.simpleMessage(
"Blurring of cover background"),
"cancel": MessageLookupByLibrary.simpleMessage("취소"),
Expand Down Expand Up @@ -151,6 +152,11 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("즐겨찾기된 순"),
"favorites_order_Use_posted":
MessageLookupByLibrary.simpleMessage("게시된 순"),
"filter_comments_by_score":
MessageLookupByLibrary.simpleMessage("Filter Comments By Score"),
"filter_comments_by_score_summary":
MessageLookupByLibrary.simpleMessage(
"Comments below/equal to this score will be hidden"),
"fixed_height_of_list_items":
MessageLookupByLibrary.simpleMessage("Fixed height of list items"),
"follow_system": MessageLookupByLibrary.simpleMessage("시스템 기본값"),
Expand Down
6 changes: 6 additions & 0 deletions lib/generated/intl/messages_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class MessageLookup extends MessageLookupByLibrary {
"automatic": MessageLookupByLibrary.simpleMessage("Automatic"),
"avatar": MessageLookupByLibrary.simpleMessage("Аватар"),
"back": MessageLookupByLibrary.simpleMessage("Назад"),
"blockers": MessageLookupByLibrary.simpleMessage("Blockers"),
"blurring_cover_background":
MessageLookupByLibrary.simpleMessage("Размытие фона обложки"),
"cancel": MessageLookupByLibrary.simpleMessage("Отмена"),
Expand Down Expand Up @@ -169,6 +170,11 @@ class MessageLookup extends MessageLookupByLibrary {
"По дате добавления в избранное"),
"favorites_order_Use_posted":
MessageLookupByLibrary.simpleMessage("По дате обновления галереи"),
"filter_comments_by_score":
MessageLookupByLibrary.simpleMessage("Filter Comments By Score"),
"filter_comments_by_score_summary":
MessageLookupByLibrary.simpleMessage(
"Comments below/equal to this score will be hidden"),
"fixed_height_of_list_items": MessageLookupByLibrary.simpleMessage(
"Фиксированная высота элементов списка"),
"follow_system": MessageLookupByLibrary.simpleMessage("Как в системе"),
Expand Down
5 changes: 5 additions & 0 deletions lib/generated/intl/messages_zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class MessageLookup extends MessageLookupByLibrary {
"automatic": MessageLookupByLibrary.simpleMessage("自动"),
"avatar": MessageLookupByLibrary.simpleMessage("头像"),
"back": MessageLookupByLibrary.simpleMessage("返回"),
"blockers": MessageLookupByLibrary.simpleMessage("本地屏蔽"),
"blurring_cover_background":
MessageLookupByLibrary.simpleMessage("封面背景模糊化"),
"cancel": MessageLookupByLibrary.simpleMessage("取消"),
Expand Down Expand Up @@ -136,6 +137,10 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("按照收藏时间"),
"favorites_order_Use_posted":
MessageLookupByLibrary.simpleMessage("按照发布时间"),
"filter_comments_by_score":
MessageLookupByLibrary.simpleMessage("根据评分过滤评论"),
"filter_comments_by_score_summary":
MessageLookupByLibrary.simpleMessage("低于/等于此分数的评论将被隐藏"),
"fixed_height_of_list_items":
MessageLookupByLibrary.simpleMessage("固定列表项高度"),
"follow_system": MessageLookupByLibrary.simpleMessage("跟随系统"),
Expand Down
6 changes: 6 additions & 0 deletions lib/generated/intl/messages_zh_TW.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class MessageLookup extends MessageLookupByLibrary {
"automatic": MessageLookupByLibrary.simpleMessage("自動"),
"avatar": MessageLookupByLibrary.simpleMessage("Avatar"),
"back": MessageLookupByLibrary.simpleMessage("退回"),
"blockers": MessageLookupByLibrary.simpleMessage("Blockers"),
"blurring_cover_background": MessageLookupByLibrary.simpleMessage(
"Blurring of cover background"),
"cancel": MessageLookupByLibrary.simpleMessage("取消"),
Expand Down Expand Up @@ -140,6 +141,11 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("依照收藏時間"),
"favorites_order_Use_posted":
MessageLookupByLibrary.simpleMessage("依照發佈時間"),
"filter_comments_by_score":
MessageLookupByLibrary.simpleMessage("Filter Comments By Score"),
"filter_comments_by_score_summary":
MessageLookupByLibrary.simpleMessage(
"Comments below/equal to this score will be hidden"),
"fixed_height_of_list_items":
MessageLookupByLibrary.simpleMessage("Fixed height of list items"),
"follow_system": MessageLookupByLibrary.simpleMessage("跟隨系統"),
Expand Down
30 changes: 30 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion lib/get_init.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:fehviewer/common/controller/block_controller.dart';
import 'package:fehviewer/common/controller/image_hide_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
Expand Down Expand Up @@ -67,7 +68,7 @@ void getinit() {
Get.put(ArchiverDownloadController());
}

debugPrint('getinit');
debugPrint('getInit');
Get.put(TabHomeController(), permanent: true);

Get.lazyPut(() => PopularViewController(), fenix: true);
Expand All @@ -91,4 +92,5 @@ void getinit() {
Get.lazyPut(() => EhMyTagsController(), fenix: true);
Get.lazyPut(() => TagController(), fenix: true);
Get.lazyPut(() => SearchImageController(), fenix: true);
Get.lazyPut(() => BlockController(), fenix: true);
}
5 changes: 4 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,8 @@
"webdav_max_connections": "WebDAV Max Connections",
"native_http_client_adapter": "Native HTTP Client Adapter",
"japanese_title_in_gallery": "Japanese Title in Gallery",
"japanese_title_in_gallery_summary": "Only effective in gallery page"
"japanese_title_in_gallery_summary": "Only effective in gallery page",
"blockers": "Blockers",
"filter_comments_by_score": "Filter Comments By Score",
"filter_comments_by_score_summary": "Comments below/equal to this score will be hidden"
}
5 changes: 4 additions & 1 deletion lib/l10n/intl_ko_KR.arb
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,8 @@
"webdav_max_connections": "WebDAV Max Connections",
"native_http_client_adapter": "Native HTTP Client Adapter",
"japanese_title_in_gallery": "Japanese Title in Gallery",
"japanese_title_in_gallery_summary": "Only effective in gallery page"
"japanese_title_in_gallery_summary": "Only effective in gallery page",
"blockers": "Blockers",
"filter_comments_by_score": "Filter Comments By Score",
"filter_comments_by_score_summary": "Comments below/equal to this score will be hidden"
}
5 changes: 4 additions & 1 deletion lib/l10n/intl_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,8 @@
"webdav_max_connections": "WebDAV Max Connections",
"native_http_client_adapter": "Native HTTP Client Adapter",
"japanese_title_in_gallery": "Japanese Title in Gallery",
"japanese_title_in_gallery_summary": "Only effective in gallery page"
"japanese_title_in_gallery_summary": "Only effective in gallery page",
"blockers": "Blockers",
"filter_comments_by_score": "Filter Comments By Score",
"filter_comments_by_score_summary": "Comments below/equal to this score will be hidden"
}
5 changes: 4 additions & 1 deletion lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,8 @@
"webdav_max_connections": "WebDAV 最大连接数",
"native_http_client_adapter": "使用原生 HTTP 客户端",
"japanese_title_in_gallery": "画廊页面显示日文标题",
"japanese_title_in_gallery_summary": "仅在画廊页面有效"
"japanese_title_in_gallery_summary": "仅在画廊页面有效",
"blockers": "本地屏蔽",
"filter_comments_by_score": "根据评分过滤评论",
"filter_comments_by_score_summary": "低于/等于此分数的评论将被隐藏"
}
5 changes: 4 additions & 1 deletion lib/l10n/intl_zh_TW.arb
Original file line number Diff line number Diff line change
Expand Up @@ -420,5 +420,8 @@
"webdav_max_connections": "WebDAV 最大連接數",
"native_http_client_adapter": "Native HTTP Client Adapter",
"japanese_title_in_gallery": "在畫廊中顯示日文標題",
"japanese_title_in_gallery_summary": "Only effective in gallery page"
"japanese_title_in_gallery_summary": "Only effective in gallery page",
"blockers": "Blockers",
"filter_comments_by_score": "Filter Comments By Score",
"filter_comments_by_score_summary": "Comments below/equal to this score will be hidden"
}
Loading

0 comments on commit 9b46fb5

Please sign in to comment.