diff --git a/lib/grpc/reply.dart b/lib/grpc/reply.dart index c2634a580..eb5e8e967 100644 --- a/lib/grpc/reply.dart +++ b/lib/grpc/reply.dart @@ -62,15 +62,14 @@ abstract final class ReplyGrpc { ), MainListReply.fromBuffer, ); - if (res.isSuccess) { - final mainListReply = res.data; + if (res case Success(:final response)) { // keyword filter - if (mainListReply.hasUpTop() && needRemoveGrpc(mainListReply.upTop)) { - mainListReply.clearUpTop(); + if (response.hasUpTop() && needRemoveGrpc(response.upTop)) { + response.clearUpTop(); } - if (mainListReply.replies.isNotEmpty) { - mainListReply.replies.removeWhere((item) { + if (response.replies.isNotEmpty) { + response.replies.removeWhere((item) { final hasMatch = needRemoveGrpc(item); if (!hasMatch && item.replies.isNotEmpty) { item.replies.removeWhere(needRemoveGrpc); diff --git a/lib/pages/video/widgets/header_mixin.dart b/lib/pages/video/widgets/header_mixin.dart index 2a3cbbb50..36130263f 100644 --- a/lib/pages/video/widgets/header_mixin.dart +++ b/lib/pages/video/widgets/header_mixin.dart @@ -1,5 +1,4 @@ import 'package:PiliPlus/common/widgets/button/icon_button.dart'; -import 'package:PiliPlus/pages/setting/widgets/switch_item.dart'; import 'package:PiliPlus/pages/video/introduction/ugc/widgets/menu_row.dart'; import 'package:PiliPlus/plugin/pl_player/controller.dart'; import 'package:PiliPlus/plugin/pl_player/utils/danmaku_options.dart'; @@ -147,6 +146,11 @@ mixin HeaderMixin on State { setOptions(); } + void updateDanmakuWeight(double val) { + plPlayerController.danmakuWeight = val.toInt(); + setState(() {}); + } + void onUpdateBlockType(int blockType, bool blocked) { if (blocked) { DanmakuOptions.blockTypes.remove(blockType); @@ -178,9 +182,9 @@ mixin HeaderMixin on State { const SizedBox(height: 10), if (!isLive) ...[ Row( + mainAxisAlignment: .spaceBetween, children: [ Text('智能云屏蔽 ${plPlayerController.danmakuWeight} 级'), - const Spacer(), TextButton( style: TextButton.styleFrom( padding: EdgeInsets.zero, @@ -214,8 +218,7 @@ mixin HeaderMixin on State { value: plPlayerController.danmakuWeight.toDouble(), divisions: 10, label: '${plPlayerController.danmakuWeight}', - onChanged: (val) => - plPlayerController.danmakuWeight = val.toInt(), + onChanged: updateDanmakuWeight, onChangeEnd: (val) => GStorage.setting.put( SettingBoxKey.danmakuWeight, val.toInt(), @@ -225,50 +228,64 @@ mixin HeaderMixin on State { ), ], const Text('按类型屏蔽'), - Padding( - padding: const EdgeInsets.only(top: 12), - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - spacing: 10, - children: blockTypesList.map( - (e) { - final blocked = DanmakuOptions.blockTypes.contains( - e.value, - ); - return ActionRowLineItem( - onTap: () => onUpdateBlockType(e.value, blocked), - text: e.label, - selectStatus: blocked, - ); - }, - ).toList(), - ), + SingleChildScrollView( + scrollDirection: .horizontal, + padding: const .symmetric(vertical: 10), + child: Row( + spacing: 10, + children: blockTypesList.map( + (e) { + final blocked = DanmakuOptions.blockTypes.contains( + e.value, + ); + return ActionRowLineItem( + onTap: () => onUpdateBlockType(e.value, blocked), + text: e.label, + selectStatus: blocked, + ); + }, + ).toList(), ), ), - SetSwitchItem( - title: '海量弹幕', - contentPadding: EdgeInsets.zero, - titleStyle: const TextStyle(fontSize: 14), - defaultVal: DanmakuOptions.massiveMode, - setKey: SettingBoxKey.danmakuMassiveMode, - onChanged: (value) { - DanmakuOptions.massiveMode = value; - setState(() {}); - setOptions(); - }, - ), - SetSwitchItem( - title: '滚动弹幕固定速度', - contentPadding: EdgeInsets.zero, - titleStyle: const TextStyle(fontSize: 14), - defaultVal: DanmakuOptions.scrollFixedVelocity, - setKey: SettingBoxKey.danmakuFixedV, - onChanged: (value) { - DanmakuOptions.scrollFixedVelocity = value; - setState(() {}); - setOptions(); - }, + const Text('其他'), + SingleChildScrollView( + scrollDirection: .horizontal, + padding: const .symmetric(vertical: 10), + child: Row( + spacing: 10, + children: [ + ActionRowLineItem( + selectStatus: DanmakuOptions.massiveMode, + onTap: () { + DanmakuOptions.massiveMode = + !DanmakuOptions.massiveMode; + setState(() {}); + setOptions(); + }, + text: '海量弹幕', + ), + ActionRowLineItem( + selectStatus: DanmakuOptions.static2Scroll, + onTap: () { + DanmakuOptions.static2Scroll = + !DanmakuOptions.static2Scroll; + setState(() {}); + setOptions(); + }, + text: '固定转滚动', + ), + ActionRowLineItem( + selectStatus: DanmakuOptions.scrollFixedVelocity, + onTap: () { + DanmakuOptions.scrollFixedVelocity = + !DanmakuOptions.scrollFixedVelocity; + setState(() {}); + setOptions(); + }, + text: '滚动弹幕固定速度', + ), + ], + ), ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/pages/whisper_block/view.dart b/lib/pages/whisper_block/view.dart index 6db3da8b5..441e71a27 100644 --- a/lib/pages/whisper_block/view.dart +++ b/lib/pages/whisper_block/view.dart @@ -69,28 +69,26 @@ class _WhisperBlockPageState extends State { ), ), Expanded( - child: Padding( + child: SingleChildScrollView( padding: const EdgeInsets.all(12), - child: SingleChildScrollView( - child: Wrap( - spacing: 12, - runSpacing: 12, - children: response - .map( - (e) => SearchText( - text: e.keyword, - onTap: (keyword) { - showConfirmDialog( - context: context, - title: '删除屏蔽词?', - content: '该屏蔽词将不再生效', - onConfirm: () => _controller.onRemove(e), - ); - }, - ), - ) - .toList(), - ), + child: Wrap( + spacing: 12, + runSpacing: 12, + children: response + .map( + (e) => SearchText( + text: e.keyword, + onTap: (keyword) { + showConfirmDialog( + context: context, + title: '删除屏蔽词?', + content: '该屏蔽词将不再生效', + onConfirm: () => _controller.onRemove(e), + ); + }, + ), + ) + .toList(), ), ), ), diff --git a/lib/plugin/pl_player/utils/danmaku_options.dart b/lib/plugin/pl_player/utils/danmaku_options.dart index 4224a96dc..d78ba7261 100644 --- a/lib/plugin/pl_player/utils/danmaku_options.dart +++ b/lib/plugin/pl_player/utils/danmaku_options.dart @@ -16,6 +16,7 @@ abstract final class DanmakuOptions { static double danmakuStaticDuration = Pref.danmakuStaticDuration; static double danmakuStrokeWidth = Pref.strokeWidth; static bool scrollFixedVelocity = Pref.danmakuFixedV; + static bool static2Scroll = Pref.static2Scroll; static bool massiveMode = Pref.danmakuMassiveMode; static double danmakuLineHeight = Pref.danmakuLineHeight; @@ -38,7 +39,7 @@ abstract final class DanmakuOptions { strokeWidth: danmakuStrokeWidth, scrollFixedVelocity: scrollFixedVelocity, massiveMode: massiveMode, - static2Scroll: true, + static2Scroll: static2Scroll, safeArea: true, lineHeight: danmakuLineHeight, ); diff --git a/lib/utils/storage_key.dart b/lib/utils/storage_key.dart index f260dab1a..cb0f3d622 100644 --- a/lib/utils/storage_key.dart +++ b/lib/utils/storage_key.dart @@ -192,6 +192,7 @@ abstract final class SettingBoxKey { danmakuStaticDuration = 'danmakuStaticDuration', danmakuMassiveMode = 'danmakuMassiveMode', danmakuFixedV = 'danmakuFixedV', + static2Scroll = 'static2Scroll', danmakuLineHeight = 'danmakuLineHeight', strokeWidth = 'strokeWidth', fontWeight = 'fontWeight'; diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index 69966e8f0..748b4c770 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -322,6 +322,9 @@ abstract final class Pref { static bool get danmakuFixedV => _setting.get(SettingBoxKey.danmakuFixedV, defaultValue: false); + static bool get static2Scroll => + _setting.get(SettingBoxKey.static2Scroll, defaultValue: false); + static double get subtitleFontScale => _setting.get(SettingBoxKey.subtitleFontScale, defaultValue: 1.0);